|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
| Thread Tools | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
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, |
|
#2
|
||||||
|
||||||
|
That's just fine. It tokenizes perfectly for me.
|
|
#3
|
|||
|
|||
|
Hmm, well, I only tried on RoboEMU. This might be an issue. I'll try a RC soon and I'll report the results.
|
|
#4
|
||||||
|
||||||
|
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...
|
|
#5
|
|||
|
|||
|
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, |
|
#6
|
|||||
|
|||||
|
Quote:
|
|
#7
|
||||
|
||||
|
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 . 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. |
|
#8
|
||||||
|
||||||
|
Quote:
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 |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| BS2 syntax (PBASIC) on the new controllers? Maybe! | Jeremy_Mc | Programming | 0 | 25-10-2003 15:00 |
| PBASIC Syntax Question | Raven_Writer | Programming | 4 | 20-08-2003 08:07 |
| PBASIC language syntax | WizardOfAz | Programming | 14 | 30-04-2003 10:23 |
| Pbasic 2.5 syntax | Rickertsen2 | Programming | 10 | 15-02-2003 08:56 |
| Another PBASIC Question | Ian W. | Programming | 4 | 31-01-2002 21:36 |