Math Is Fun Forum
  Discussion about math, puzzles, games and fun.   Useful symbols: √ ∞ ≠ ≤ ≥ ≈ ⇒ ∈ Δ θ ∴ ∑ ∫ π -

Login

Username

Password

Not registered yet?

Post a reply

Go back

Write your message and submit
:) :| :( :D :o ;) :/ :P :lol: :mad: :rolleyes: :cool: | :dizzy :eek :kiss :roflol :rolleyes :shame :down :up :touched :sleep :wave :swear :tongue :what :faint :dunno
Options

Go back

Topic review (newest first)

n872yt3r
2013-01-25 08:03:22

I didn't get that last part; but thanks for the explanation on ElseIfs.

muxdemux
2013-01-25 02:05:06

Here's your main problem:

Code:

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:

Code:

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:

Code:

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:

Code:

ElseIf test = "Testing Reply 2" Then

Finally, with all that thinking, we get this:

Code:

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!"

n872yt3r
2013-01-24 23:04:28

ElseIfs... Sure! It was like this...

Code:

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!

muxdemux
2013-01-23 01:42:45

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?

n872yt3r
2013-01-23 01:19:01

C'mon, it was just an example. As I said, look at post #3.

bobbym
2013-01-23 01:11:34

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

Agnishom
2013-01-23 01:06:15

Have you understood what gAr said?

n872yt3r
2013-01-23 00:57:07

I'll try it, but the Microsoft Small Basic Curriculum were downloaded directly from the Microsoft official website.

Agnishom
2013-01-23 00:41:11

Try 2 = signs anyway

n872yt3r
2013-01-23 00:35:17

2 = signs? According to Microsoft Small Basic Curriculum Lesson 1.4, (here is just an example:) you can do

Code:

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. neutral

Agnishom
2013-01-23 00:25:07

Hey n872yt3r
Use the following line instead

Code:

If test == "Testing Reply" Then

Put two equal signs there

n872yt3r
2013-01-22 23:58:15

I never recall posting a "newline character," I copied it right off my Microsoft Small Basic program.

gAr
2013-01-22 23:29:09

Hi,

I was talking about "newline character", you can't see that on the screen..

n872yt3r
2013-01-22 23:26:01

\n? I don't see \n. Maybe your browser uses Latex differently... sad Do you guys use Small Basic? smile I learned it over the summer.

gAr
2013-01-22 23:09:41

Hi,

Maybe it's taking \n character as well, strip your input of "\n" and try again.

Board footer

Powered by FluxBB