All right, I'm forcing myself along here, but am having a problem with labels in my code. I've posted the code below. Basically my problem is that when I attempt to compile this I receive this error:
"Compile Error: Label 'start' not found"
' BASICalc
' Last edit on 6.17.2005
' Time to start input
#start
Print ""
Print "Simple calculator"
Print ""
whattodo$ = Input("Add, subtract, multiply or divide? (a,s,m,d) ")
If whattodo = "a"
Goto add
Else If whattodo = "s"
Goto subtract
Else If whattodo = "m"
Goto multiply
Else If whattodo = "d"
Goto divide
Else
Print "Error! Choose either a, s, m, or d!"
Goto start
End If
End
' Enter our labels for the different types of calculations
' Addition
#add
grabx# = Float(Input("x value > "))
graby# = Float(Input("y value > "))
Print "Result is: "+add(grabx,graby)
again()
' Subtraction
#subtract
grabx# = Float(Input("x value > "))
graby# = Float(Input("y value > "))
Print "Result is: "+subtract(grabx,graby)
again()
' Multiplication
#multiply
grabx# = Float(Input("x value > "))
graby# = Float(Input("y value > "))
Print "Result is: "+multiply(grabx,graby)
again()
' Dividing
#divide
grabx# = Float(Input("x value > "))
graby# = Float(Input("y value > "))
Print "Result is: "+divide(grabx,graby)
again()
' Exit
#done
Print "Bye!"
End
' ====================================================
' Let's declare some functions
Function add#(x#,y#)
Return x+y
End Function
Function subtract#(x#,y#)
Return x-y
End Function
Function multiply#(x#,y#)
Return x*y
End Function
Function divide#(x#,y#)
Return x/y
End Function
Function again()
Global again$=Input("Calculate another problem? (y,n) ")
If again = "y"
Goto start
Else
Goto done
End If
End Function
I'm wondering if BMax just doesn't like hopping back and forth through the code, or I'm not completely understanding labels and gotos. If someone could shine some light my way I would appreciate it!
"Compile Error: Label 'start' not found"
' BASICalc
' Last edit on 6.17.2005
' Time to start input
#start
Print ""
Print "Simple calculator"
Print ""
whattodo$ = Input("Add, subtract, multiply or divide? (a,s,m,d) ")
If whattodo = "a"
Goto add
Else If whattodo = "s"
Goto subtract
Else If whattodo = "m"
Goto multiply
Else If whattodo = "d"
Goto divide
Else
Print "Error! Choose either a, s, m, or d!"
Goto start
End If
End
' Enter our labels for the different types of calculations
' Addition
#add
grabx# = Float(Input("x value > "))
graby# = Float(Input("y value > "))
Print "Result is: "+add(grabx,graby)
again()
' Subtraction
#subtract
grabx# = Float(Input("x value > "))
graby# = Float(Input("y value > "))
Print "Result is: "+subtract(grabx,graby)
again()
' Multiplication
#multiply
grabx# = Float(Input("x value > "))
graby# = Float(Input("y value > "))
Print "Result is: "+multiply(grabx,graby)
again()
' Dividing
#divide
grabx# = Float(Input("x value > "))
graby# = Float(Input("y value > "))
Print "Result is: "+divide(grabx,graby)
again()
' Exit
#done
Print "Bye!"
End
' ====================================================
' Let's declare some functions
Function add#(x#,y#)
Return x+y
End Function
Function subtract#(x#,y#)
Return x-y
End Function
Function multiply#(x#,y#)
Return x*y
End Function
Function divide#(x#,y#)
Return x/y
End Function
Function again()
Global again$=Input("Calculate another problem? (y,n) ")
If again = "y"
Goto start
Else
Goto done
End If
End Function
I'm wondering if BMax just doesn't like hopping back and forth through the code, or I'm not completely understanding labels and gotos. If someone could shine some light my way I would appreciate it!