View Full Version : PBASIC Syntax Documentation
01-15-2003, 04:07 PM
I am a programmer from team 623. I was wondering if there is any website/document with DEFINITIVE information on the syntax of the PBASIC programming language. I've been to Innovation First and I got the programming reference guide, but the syntax isn't explained too well. I can do some guess work by looking at the sample programs but I still need more info.
Aside from that, a have a more specific question about the MIN and MAX keywords in the sample program. What do they do exactly? Right now that is the keyword that I really need info on.
Note: Im posting under a fellow team member's name. Later, when I get my new computer, I will be posting as "EbonySeraphim."
01-15-2003, 04:33 PM
MIN and MAX set a min and max value for a variable...
you could use it to limit how fast your motors go (like maybe you wanted them to stop for 3 seconds you could set the max and min to 127...)
i might be wrong (i'm pretty new to PBASIC) but from the samples i've looked at that's what it looks like
01-15-2003, 05:21 PM
These two statememts ask PBASIC to check if the result of the calculation they follow is a minimum of, ar a maximum of the stated value.
x = 30 * datav MIN 60 MAX 120
will do the operation 30 times datav, then if datav was only 1 or zero, MIN would return a value of 60. If datav is 2, 3 or 4, the result is passed through. If datav > 4 then MAX will replace the product with 120
Since the Stamp only uses integer arithmetic, there are no other values of datav to worry about. Heh heh heh, not so fast !
Some people mess it up with MIN 0. if a=4 and b=5 in your program and x = a - b MIN 0 is used, the result a-b is more than zero, because -1 is 255 in the 8-bit world. 255 passes MIN 0 with flying colours. Similarly, with byte variables, (253 + 3) MAX 256 appears to do nothing giving 1 as a result.
To work around this eight-bit under/overflow, we add 2000, so the arithmetic has to be done 16 bits wide.
x = (((a + 2000) - b) MIN 2000) - 2000
will return 0, because the result of the original subtraction was 1999, a positive integer, but it will be replaced by MIN with 2000, the MINimum allowable value.
01-15-2003, 06:53 PM
The PBASIC manual is availible from Parallax (http://www.parallax.com/html_pages/downloads/basicstamps/documentation_basic_stamp.asp). Note that this does not cover the pbasic 2.5 syntax. If you want to use that, you will need to search other posts. However, it is not necessary to use the new syntax (and things like min and max didn't change) so the manual is all your really need.
01-15-2003, 08:21 PM
The 2.5 syntax is covered in the PBASIC 2 Enhanced Syntax Notes.pdf which is in the .zip file you downloaded to get the 2.5 editor.
vBulletin® v3.6.4, Copyright ©2000-2013, Jelsoft Enterprises Ltd.