Alektric
- 19th January 2009, 13:36
I have always found the If Then command in PicBasic very limiting:
5.13. IF..THEN
IF Comp { AND/OR Comp } THEN Label
Performs one or more comparisons. Each Comp term can relate a variable to a constant or other variable and must be in the following form:
Var ( < | <= | = | <> | >= | > ) Value
All comparisons are unsigned since PBC only supports unsigned types. A variable must occur on the left.
The THEN in an IF..THEN is essentially a GOTO. If the condition is true, the program will GOTO the label after the THEN. If the condition evaluates to false, the program will continue at the next line after the IF..THEN. Another statement may not be placed after the THEN, it must be a label
Yet I have seen posts of code written in a similar style to C:
If B0 = 0 Then
(code to run goes here)
Else
(more code)
EndIf
If I try this, my compiler does not like it, telling me that it expected a label after the Then (as stated in the manual).
Can anyone tell me how I can use this style in PicBasic?
Sorry if it's a dumb question and thanks for reading!
5.13. IF..THEN
IF Comp { AND/OR Comp } THEN Label
Performs one or more comparisons. Each Comp term can relate a variable to a constant or other variable and must be in the following form:
Var ( < | <= | = | <> | >= | > ) Value
All comparisons are unsigned since PBC only supports unsigned types. A variable must occur on the left.
The THEN in an IF..THEN is essentially a GOTO. If the condition is true, the program will GOTO the label after the THEN. If the condition evaluates to false, the program will continue at the next line after the IF..THEN. Another statement may not be placed after the THEN, it must be a label
Yet I have seen posts of code written in a similar style to C:
If B0 = 0 Then
(code to run goes here)
Else
(more code)
EndIf
If I try this, my compiler does not like it, telling me that it expected a label after the Then (as stated in the manual).
Can anyone tell me how I can use this style in PicBasic?
Sorry if it's a dumb question and thanks for reading!