Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Programming (http://www.chiefdelphi.com/forums/forumdisplay.php?f=51)
-   -   PBASIC Syntax (http://www.chiefdelphi.com/forums/showthread.php?t=16474)

Goya 14-01-2003 14:33

PBASIC Syntax
 
Quick Question - When using a DO...LOOP WHILE, is the following syntax acceptable?

Do

drive_R = 254
drive_L = 254

Loop While sForward = 1


Or do I need to use parentheses? Or possibly brackets?

Thanks in advance,

rbayer 14-01-2003 14:45

That's just fine. It tokenizes perfectly for me.

Goya 14-01-2003 14:49

Hmm, well, I only tried on RoboEMU. This might be an issue. I'll try a RC soon and I'll report the results.

rbayer 14-01-2003 14:54

One thing: syntacticly that is correct. In terms of working on an RC, it's going to give you a BASIC RUN error. To avoid this, put a SERIN and SEROUT inside the loop. Or, ditch the DO...WHILE and router everything through your normal serin and serout. I suppose a gosub could accomplish the same thing from within the DO WHILE...

Goya 14-01-2003 15:32

Actually, I had a GOSUB GoSerout within the Do .... Loop that I removed before posting. That didn't work because it wouldn't RETURN to my Loop, or it would accidentally hit that GoSerout during the MainLoop.

In this case, I placed a SERIN and a SEROUT within theh Do ... Loop itself. Question - Can I remove values of the SERIN, SEROUT commands that I don't use? For example, everything except PWM1 - 4?

Thanks a lot,

Greg Ross 14-01-2003 16:42

Quote:

Originally posted by Goya
Can I remove values of the SERIN, SEROUT commands that I don't use? For example, everything except PWM1 - 4?
I THINK you can get away with leaving off values as long as they are the last N parameters. I think the two 255s at the start of the serout will cause the RC to treat it as all good.

Ian W. 14-01-2003 16:48

the two 255's indicate the beginning of a new serout. i learned that the hard way :). don't be stupid like me, make sure no 255's come in sequence after the initial ones :p. i also think the uP may put a 127/0 to any unused outputs, but don't count me on this one, cause i'm not 100% sure.

rbayer 14-01-2003 16:58

Quote:

Originally posted by Ian W.
the two 255's indicate the beginning of a new serout. i learned that the hard way :). don't be stupid like me, make sure no 255's come in sequence after the initial ones :p. i also think the uP may put a 127/0 to any unused outputs, but don't count me on this one, cause i'm not 100% sure.
You are correct.

You CAN remove stuff from the SEROUT. You CANNOT remove stuff from the serin or you will get BASIC INIT errors.

As for the gosub, it is possible, but takes some reworking of the other parts of the code. You main loop would have to be:

Do
gosub mySerin

'normal code goes here, including your loop that you posted originally.

gosub mySerout
Loop

mySerin:
Serin ...
return

mySerout:
Serout ...
return


All times are GMT -5. The time now is 04:29.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi