pbasic help
Robert25
Posts: 53
Hi... hope this is the correct forum to post this.
I am having a problem with a pbasic (2.5)·code that keeps giving me an error message during syntax check.· I attached that portion of the code below that is a do loop.· When I run the syntax check, I receive the following error message:· error 141 - expected a constant, variable, unary operator, or "("
Naturally, all the variables and such were defined earlier.
Since I a still a bit new to programming, can someone give me a clue what to look for to solve the issue????
Code:
·DO
··· GOSUB Get_Sonar···························· ' get sensor value
··· inches = rawDist ** RawToIn················ ' convert to inches
··· cm = rawDist ** RawToCm···················· ' convert to centimeters
··· DEBUG CRSRXY, 15, 3,······················· ' update report screen
········· DEC rawDist, CLREOL,
········· CRSRXY, 15, 4,
········· DEC inches, CLREOL,
········· CRSRXY, 15, 5,
········· DEC cm, CLREOL,
········· CRSRXY, 15, 6,
········· DEC cmd, CLREOL
··· PAUSE 50
··· IF inches < 6 THEN GOSUB Play_msg
'··· BRANCH cmd, [noparse][[/noparse]Play_Msg, Play_Msg]
· LOOP
· GOTO Main
· END
·
I am having a problem with a pbasic (2.5)·code that keeps giving me an error message during syntax check.· I attached that portion of the code below that is a do loop.· When I run the syntax check, I receive the following error message:· error 141 - expected a constant, variable, unary operator, or "("
Naturally, all the variables and such were defined earlier.
Since I a still a bit new to programming, can someone give me a clue what to look for to solve the issue????
Code:
·DO
··· GOSUB Get_Sonar···························· ' get sensor value
··· inches = rawDist ** RawToIn················ ' convert to inches
··· cm = rawDist ** RawToCm···················· ' convert to centimeters
··· DEBUG CRSRXY, 15, 3,······················· ' update report screen
········· DEC rawDist, CLREOL,
········· CRSRXY, 15, 4,
········· DEC inches, CLREOL,
········· CRSRXY, 15, 5,
········· DEC cm, CLREOL,
········· CRSRXY, 15, 6,
········· DEC cmd, CLREOL
··· PAUSE 50
··· IF inches < 6 THEN GOSUB Play_msg
'··· BRANCH cmd, [noparse][[/noparse]Play_Msg, Play_Msg]
· LOOP
· GOTO Main
· END
·
Comments
Are you using the following directive at the beginning of your program, if not, you need to add it in:
' {PBASIC 2.5}
Regards,
Bruce Bates
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
<!--StartFragment -->
Could the problem be a missing constant, variable, unary operator, or "(" further up in your code?
It is possible that something else is missing, eg constant, variable etc.
Why would it give me the syntax error from the "do" in the do loop???
if the "constant, variable etc." is outside the loop???
If I understand correctly, I should be looking for a missing constant or variable declaration???
·· There is too much missing and generating all kinds of errors.· Why not post the exact code you are using as an attachedment (Not pasted) so we can compile it and see what is happening?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
csavage@parallax.com
Chances are better than even that you're not using curley brackets, as you should be.
This is correct:
' {PBASIC 2.5}
This is INCORRECT:
' [noparse][[/noparse]PBASIC 2.5]
Regards,
Bruce Bates
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
<!--StartFragment -->
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Think outside the BOX!
Just for a previous post, I use the buttons in the editor to insert the Pbasic and stamp I am using...· they automatically insert the braces...· {}.
·· The reason this is happening to your DO statement is that the previous line of code has a comma at the end.· This tells the compiler that the next line is part of it.· Remove the comma and you should be okay.· Oh, and the 'j' artifact in your DEBUG section right below it.· Oh, you also have a Check_Busy call and that label doesn't exist.· After that it works.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
csavage@parallax.com
ah... for the wnat of an extra comma....