Chief Delphi

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

rbayer 06-01-2003 00:20

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 then
code to execute if condition is true
else
code to execute otherwise
endif

The second is:
Code:

if condition then statement
These should make people happy as if statements now work like you're used to from C/Java/etc.

2. SELECT. Almost exactly like C's switch:
Code:

SELECT variable/expression
CASE value1
commands
CASE value2
commands
ENDSELECT

3. DO...LOOP. Like do/while.
Either 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:


DO
commands to execute
LOOP

-or-

DO WHILE condition
commands to execute
LOOP

-or-

DO
commands to execute
LOOP WHILE condition

There's one other new one, but I can't remember what it is at this time. Something similar to BRANCH, if I remember correctly.

Hope that helps.

--Rob

P.S. RoboEmu 1.09 will support all these new commands and should be done tomorrow afternoon.

ttedrow 06-01-2003 08:29

Thanks Rob

Now all we need is First/InnovationFirst/Parallax to get their "stuff" together and get us working editor/compiler software.

Jeff Waegelin 06-01-2003 09:27

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...

InnovationFirst 06-01-2003 13:13

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.

Raven_Writer 06-01-2003 15:01

Quote:

Originally posted by Jeff Waegelin
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...
The problem with negitive numbers is that unless they make it so that -127 is the new full-reverse number, then it will totally screw up your robot. Think of it this way:

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.

Skabana159 06-01-2003 16:06

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.

AJ Quick 07-01-2003 16:33

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.

Morgan Jones 07-01-2003 20:17

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

rbayer 07-01-2003 20:44

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.

Raven_Writer 07-01-2003 20:57

Quote:

Originally posted by rbayer
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.
I'm just trying to see if I understand you right, you mean something like "if p2_y > 30 on 40 then gosub Exit"?

rbayer 07-01-2003 21:02

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