Answered by:
assigning values
Question

Is it possible to assign a variable the value of infinity? Ifso, how can it be done? (this is fora loop program for the turtle so that it turns left when drawing a shape when the number of sides is typed as negative). i = (any number) to sides does not work well enough. Or am i asking the wrong question?Thursday, November 24, 2011 4:30 PM
Answers

Short answer No.
There is usually a maximum number that can be stored, depending on whether 4 or 8 (or other) bytes is used to store the number. Often this number is very large with perhaps 15 significant figures and maximum power of 10 in the hundreds, for example:
1.2345678912345e120, where e120 stands for (exponent) 10^120 or 1 with 120 zeros after it!. A much bigger than the number of atoms in the universe.
However in Small Basic there is no exponent notation and maximum numbers are probably around 15 or 20 digits.
An interesting test is to write a program to find the maximum number that SmallBasic can handle, perhaps one for the Challenge of the Month!
An infinite loop can easily be performed by:
While ("True")
...
EndWhile
To be specific to your case, you would need to post your code and what you are trying to do.
 Marked as answer by keg504 Saturday, November 26, 2011 3:38 AM
Thursday, November 24, 2011 7:03 PM
All replies

Short answer No.
There is usually a maximum number that can be stored, depending on whether 4 or 8 (or other) bytes is used to store the number. Often this number is very large with perhaps 15 significant figures and maximum power of 10 in the hundreds, for example:
1.2345678912345e120, where e120 stands for (exponent) 10^120 or 1 with 120 zeros after it!. A much bigger than the number of atoms in the universe.
However in Small Basic there is no exponent notation and maximum numbers are probably around 15 or 20 digits.
An interesting test is to write a program to find the maximum number that SmallBasic can handle, perhaps one for the Challenge of the Month!
An infinite loop can easily be performed by:
While ("True")
...
EndWhile
To be specific to your case, you would need to post your code and what you are trying to do.
 Marked as answer by keg504 Saturday, November 26, 2011 3:38 AM
Thursday, November 24, 2011 7:03 PM 
GraphicsWindow.MouseDown = OnMouseDown Sub OnMouseDown Program.End() EndSub begin: TextWindow.WriteLine("Would you like the turtle to turn or move and how much or would you like it to draw a shape? ") action = TextWindow.Read() number = TextWindow.ReadNumber() If action = "move" Then Turtle.Move(number) ElseIf action = "turn" then Turtle.Turn(number) Elseif action = "shape" then TextWindow.WriteLine("dotted or single line ") type = TextWindow.Read() If type = "single line" then Goto singleline elseif type = "dotted" then Goto dotted Else TextWindow.WriteLine("Invalid input") Goto begin singleline: TextWindow.WriteLine("How many sides and what size? ") sides = TextWindow.ReadNumber() size = TextWindow.ReadNumber() / sides angle = 360 / sides <span style="textdecoration:underline">For i = 1 to sides</span> Turtle.Move(size) Turtle.Turn(angle) endfor EndIf Goto clear dotted: TextWindow.WriteLine("How many sides and what size and how many line segments should each line have?(type each variable on seperate lines) ") sides = TextWindow.ReadNumber() size = TextWindow.ReadNumber() / sides angle = 360 / sides segments = TextWindow.ReadNumber() <span style="textdecoration:underline">For i = 1 To sides</span> For j = 1 To segments Turtle.Move(size) Turtle.PenUp() Turtle.Move(size) Turtle.PenDown() EndFor Turtle.Turn(angle) EndFor elseif action = "clear" then GraphicsWindow.Clear() Goto begin Else Program.End() EndIf Goto clear clear: TextWindow.WriteLine("Would you like to clear the window? ") ans = TextWindow.Read() If ans = "yes" Or "y" Or "Yes" Or "Y" Then GraphicsWindow.Clear() ElseIf ans = "no" Or "n" Or "No" Or "N" Then EndIf Goto begin
This is the first program i've written and i'm new to the programming scene. i have underlined the problem code. i want the turtle to draw the shape to the left if a negative value of sides is given as input. i've tried for i = sides to sides but it doesn't give any output. Any help would be appreciated.
P.S. thanks for the comphrehensive reply
“Computers are like Old Testament gods: lots of rules and no mercy.” – Joseph CampbellFriday, November 25, 2011 11:36 AM 
The problem is that a negative value for sides results in a negative value for angle (OK) and size (not OK) and we use sides in the loop from 1 to sides (not OK).
We want sides to be positive, size to be positive and angle to be negative.
Perhaps something like this to get the angle negative while sides and size are positive after a negative for sides is entered:
TextWindow.WriteLine("How many sides and what size? ") sides = TextWindow.ReadNumber() angle = 360 / sides sides = Math.Abs(sides) size = TextWindow.ReadNumber() / sides
Friday, November 25, 2011 6:20 PM 
That makes perfect sense...I had forgotten that there were advanced maths functions in the code, and i didn't realize the size problem. Thank you so much!
“Computers are like Old Testament gods: lots of rules and no mercy.” – Joseph Campbell
GraphicsWindow.MouseDown = OnMouseDown Sub OnMouseDown Program.End() EndSub begin: TextWindow.WriteLine("Would you like the turtle to turn or move and how much or would you like it to draw a shape? ") action = TextWindow.Read() number = TextWindow.ReadNumber() If action = "move" Then Turtle.Move(number) ElseIf action = "turn" then Turtle.Turn(number) Elseif action = "shape" then TextWindow.WriteLine("dotted or single line ") type = TextWindow.Read() If type = "single line" then Goto singleline elseif type = "dotted" then Goto dotted Else TextWindow.WriteLine("Invalid input") Goto begin singleline: TextWindow.WriteLine("How many sides and what size? ") angle = 360 / sides sides = TextWindow.ReadNumber() sides = Math.Abs(sides) size = TextWindow.ReadNumber() / sides For i = 1 to sides Turtle.Move(size) Turtle.Turn(angle) endfor EndIf Goto clear dotted: TextWindow.WriteLine("How many sides and what size and how many line segments should each line have?(type each variable on seperate lines) ") angle = 360 / sides sides = TextWindow.ReadNumber() sides = Math.Abs(sides) size = TextWindow.ReadNumber() / sides segments = TextWindow.ReadNumber() For i = 1 To sides For j = 1 To segments Turtle.Move(size) Turtle.PenUp() Turtle.Move(size) Turtle.PenDown() EndFor Turtle.Turn(angle) EndFor elseif action = "clear" then GraphicsWindow.Clear() Goto begin Else Program.End() EndIf Goto clear clear: TextWindow.WriteLine("Would you like to clear the window? ") ans = TextWindow.Read() If ans = "yes" Or "y" Or "Yes" Or "Y" Then GraphicsWindow.Clear() ElseIf ans = "no" Or "n" Or "No" Or "N" Then EndIf Goto begin
I tried changing it but now it only goes forward and stops. i tried all other logical possibilities that i could think of, but i either got no output and the program skipped to the next label or it just drew a straight line. This is the final version i tried, but it just draws a straight line. Help please...! Edited by keg504 Saturday, November 26, 2011 2:15 PM
Saturday, November 26, 2011 3:40 AM