You are not logged in.
Pages: 1
Someone help me! This glitch keeps bothering me... Ugh! Every time I encounter it,
In Microsoft Small Basic (here is just a simple example,)
TextWindow.WriteLine("Testing")
test = TextWindow.Read()
If test = "Testing Reply" Then
TextWindow.WriteLine("This is text.")
Else
TextWindow.WriteLine("Sorry, this operation did not perform correctly.")
EndIf
it always displays the Else even when I type in "Testing Reply."
And also , whenever I try to group Ifs into ElseIfs, Small Basic keeps saying there is an error in the program.
Someone help!
Last edited by n872yt3r (2013-01-21 08:47:05)
- n872yt3r
Math Is Fun Rocks!
By the power of the exponent, I square and cube you!
Offline
hi n872yt3r
Welcome to the forum.
If test = "Testing Reply" Then
"Testing Reply."
If that is literal then they aren't the same. The input has a full stop.
Sometimes little things can keep you guesing for a long time.
I had a tester who occasionally hit the caps lock and I'd only allowed for small letters in my program.
If that's not it, try a variable dump.
Bob
Children are not defined by school ...........The Fonz
You cannot teach a man anything; you can only help him find it within himself..........Galileo Galilei
Sometimes I deliberately make mistakes, just to test you! …………….Bob
Offline
No, the period was marked as the end of a sentence. Anyway, that was just an example, if I do it in real time and enter it exactly correctly, so yeah, it's got to be a variable dump.
- n872yt3r
Math Is Fun Rocks!
By the power of the exponent, I square and cube you!
Offline
Hi,
Maybe it's taking \n character as well, strip your input of "\n" and try again.
"Believe nothing, no matter where you read it, or who said it, no matter if I have said it, unless it agrees with your own reason and your own common sense" - Buddha?
"Data! Data! Data!" he cried impatiently. "I can't make bricks without clay."
Offline
\n? I don't see \n. Maybe your browser uses Latex differently... Do you guys use Small Basic? I learned it over the summer.
- n872yt3r
Math Is Fun Rocks!
By the power of the exponent, I square and cube you!
Offline
Hi,
I was talking about "newline character", you can't see that on the screen..
"Believe nothing, no matter where you read it, or who said it, no matter if I have said it, unless it agrees with your own reason and your own common sense" - Buddha?
"Data! Data! Data!" he cried impatiently. "I can't make bricks without clay."
Offline
I never recall posting a "newline character," I copied it right off my Microsoft Small Basic program.
- n872yt3r
Math Is Fun Rocks!
By the power of the exponent, I square and cube you!
Offline
Hey n872yt3r
Use the following line instead
If test == "Testing Reply" Then
Put two equal signs there
'And fun? If maths is fun, then getting a tooth extraction is fun. A viral infection is fun. Rabies shots are fun.'
'God exists because Mathematics is consistent, and the devil exists because we cannot prove it'
I'm not crazy, my mother had me tested.
Offline
2 = signs? According to Microsoft Small Basic Curriculum Lesson 1.4, (here is just an example:) you can do
If Clock.Day = 1 And Clock.Month = 1 Then
TextWindow.WriteLine("Happy New Year!")
EndIf
'Ya see? Clock.Day = 1 and Month = 1. 1 equals sign.
- n872yt3r
Math Is Fun Rocks!
By the power of the exponent, I square and cube you!
Offline
Try 2 = signs anyway
'And fun? If maths is fun, then getting a tooth extraction is fun. A viral infection is fun. Rabies shots are fun.'
'God exists because Mathematics is consistent, and the devil exists because we cannot prove it'
I'm not crazy, my mother had me tested.
Offline
I'll try it, but the Microsoft Small Basic Curriculum were downloaded directly from the Microsoft official website.
- n872yt3r
Math Is Fun Rocks!
By the power of the exponent, I square and cube you!
Offline
Have you understood what gAr said?
'And fun? If maths is fun, then getting a tooth extraction is fun. A viral infection is fun. Rabies shots are fun.'
'God exists because Mathematics is consistent, and the devil exists because we cannot prove it'
I'm not crazy, my mother had me tested.
Offline
Hi;
If you downloaded it exactly from Microsoft then you should email them if the code does not work.
Have you tried changing line 3 to If test = "ok" Then
Or even shorter
If test = "k" Then
In mathematics, you don't understand things. You just get used to them.
If it ain't broke, fix it until it is.
Always satisfy the Prime Directive of getting the right answer above all else.
Offline
C'mon, it was just an example. As I said, look at post #3.
- n872yt3r
Math Is Fun Rocks!
By the power of the exponent, I square and cube you!
Offline
Works fine over here. Your problem could be that you're entering "testing reply" instead of "Testing Reply".
Can you post some of your code involving ElseIf's?
Offline
ElseIfs... Sure! It was like this...
TextWindow.WriteLine("Testing")
test = TextWindow.Read()
If test = "Testing Reply" Then
TextWindow.WriteLine("This is text.")
ElseIf
test2 = TextWindow.Read()
If test2 = "Testing Reply 2" Then
TextWindow.WriteLine("This is also text.")
Else
TextWindow.WriteLine("Sorry, this operation did not perform correctly.")
EndIf
And it never works!
- n872yt3r
Math Is Fun Rocks!
By the power of the exponent, I square and cube you!
Offline
Here's your main problem:
ElseIf
test2 = TextWindow.Read()
If test2 = "Testing Reply 2" Then
You need to put your test on the same line as the 'ElseIf' like this:
ElseIf test2 = TextWindow.Read()
If test2 = "Testing Reply 2" Then
And immediately after the test, Small Basic is expecting a "Then," just like with the if statements:
ElseIf test2 = TextWindow.Read() Then
If test2 = "Testing Reply 2" Then
Also, you can't test if TextWindow.Read() is equal to the variable 'test2' because you haven't set it to anything yet. But you already set the "test" variable to TextWindow.Read() on the second line of your program. What I think you meant to do is something like this:
ElseIf test = "Testing Reply 2" Then
Finally, with all that thinking, we get this:
TextWindow.WriteLine("Testing")
test = TextWindow.Read()
If test = "Testing Reply" Then
TextWindow.WriteLine("This is text.")
ElseIf test = "Testing Reply 2" Then
TextWindow.WriteLine("This is also text.")
Else
TextWindow.WriteLine("Sorry, this operation did not perform correctly.")
EndIf
Line by line, the program says this:
1. Show the user "Testing" (print it out on the screen).
2. Set the variable "test" to whatever the user types.
3. Check if the "test" variable is equal to "Testing Reply" (without quotes). If it is, go to step 4, otherwise go to step 5.
4. Show the user "This is text." (Without quotes, of course!) Then go to step 8.
5. Check if the "test" variable is equal to "Testing Reply 2" (without quotes). If it is, go to step 6, otherwise go to step 7.
6. Show the user "This is also text." Then go to step 8.
7. Show the user "Sorry, this operation did not perform correctly." Then go to step 8.
8. This is the "EndIf." It pretty much says "quit asking all these 'if' questions!"
Last edited by muxdemux (2013-01-24 03:19:46)
Offline
I didn't get that last part; but thanks for the explanation on ElseIfs.
- n872yt3r
Math Is Fun Rocks!
By the power of the exponent, I square and cube you!
Offline
Pages: 1