![]() |
The New PBASIC
OK, I've figured it out, and in case anyone wants to get started, here are the new commands and the ways you can use them. Use at your own risk as it is possible Parallax will never release the updated editor and your code will be worthless:
1. NEW IF SYNTAX! There's two, actually. The first is: Code:
if condition thenCode:
if condition then statement2. SELECT. Almost exactly like C's switch: Code:
SELECT variable/expressionEither the DO or the LOOP can be followed by the keyword WHILE or UNTIL. Putting it on the DO will cause it to be checked before executing any of the body. Putting it on the LOOP will cause it to be checked only after the body has been executed at least once. Examples: Code:
Hope that helps. --Rob P.S. RoboEmu 1.09 will support all these new commands and should be done tomorrow afternoon. |
Thanks Rob
Now all we need is First/InnovationFirst/Parallax to get their "stuff" together and get us working editor/compiler software. |
So, in other words, PBASIC is becoming more like standard BASIC. I like it. Now, if we could just add a few more variables, floating point math, and negative numbers, we'd be all set...
|
Breaking News from Parallax
We just received news from Parallax that the release of PBASIC 2.5beta will be Friday, January 10th. The files will be available on www.innovationfirst.com (not Parallax). We apologize for the delay. Please do NOT contact Parallax, as this will just delay the release.
|
Quote:
127 = Full Forward 0 = Nothing (stopped) -127 = Full Reverse This above would have to be the new way to control the speed of your robot. Note: This is how our controls specialist (I think you can call him) told me about the speed. |
So, in other words, PBASIC is becoming more like standard BASIC. I like it. Now, if we could just add a few more variables, floating point math, and negative numbers, we'd be all set...
Floating point math is not a problem with the pbasic language, but rather with the BASIC stamp itself. We would require a much more expensive microprocessor if we wanted to do floats. This is also the reason we can't have more variables, there is only so much RAM space. |
The changes seem better, it looks like the newer versions are starting to have a more uniform programming style. Most languages that I have worked with have used that kind of syntax.
|
Something rbayer didn't mention is the TCASE (Through CASE) command under SELECT. A TCASE is evaluated even if the previous CASE (or TCASE) evaluated as true. This would be like leaving out a break command in C/C++. Although no examples comes to mind at the moment, this feature may prove useful.
http://groups.yahoo.com/group/basicstamps/message/27596 |
I knew I was forgetting something! Anyway, the other new one is ON. It's almost identical to BRANCH, except you can use it to do gosubs instead of just gotos.
|
Quote:
|
No. It's like
ON counterVar GOSUB label0, label1, label2, label3, label4, label5 There may be brackets in there, but I don't remember. Anyway, if counter counterVar has the value 0, it will GOSUB to label0. If it's 1, GOSUB label1, etc. It's identical to BRANCH, except you can do a GOSUB instead of just the equivalent of GOTO. Note that you can similuate a BRANCH exactly by doing ON counterVar GOTO label0, etc. As for the code you posted, PBASIC now supports what I like to call one-line-ifs, meaning you can do if p2_y>30 then gosub exit Similarly, you can do stuff like: if (p1_y < 140 AND p1_y > 117) then p1_y=127 Mmmm... tasty. |
| All times are GMT -5. The time now is 00:10. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi