OCCRA
Go to Post I owe it to the FIRST community and the awesome users of this site to keep working on this site and making it better. I will do so until someone from Chief Delphi pulls me away from it and tells me to stop. - Brandon Martus [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Events   CD-Media   CD-Spy   FRC-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Closed Thread
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 11-06-2001, 01:20 AM
Greg Ross's Avatar
Greg Ross Greg Ross is offline
Grammar Curmudgeon
AKA: gwross
FRC #0330 (Beach 'Bots)
Team Role: Mentor
 
Join Date: Jun 2001
Rookie Year: 1998
Location: Hermosa Beach, CA
Posts: 2,244
Greg Ross has a reputation beyond reputeGreg Ross has a reputation beyond reputeGreg Ross has a reputation beyond reputeGreg Ross has a reputation beyond reputeGreg Ross has a reputation beyond reputeGreg Ross has a reputation beyond reputeGreg Ross has a reputation beyond reputeGreg Ross has a reputation beyond reputeGreg Ross has a reputation beyond reputeGreg Ross has a reputation beyond reputeGreg Ross has a reputation beyond repute
Send a message via AIM to Greg Ross Send a message via Yahoo to Greg Ross
Improving PBASIC: Request for Comments

Back at the end of last month, there was a Simplifying PBasic thread going in the General Forum. I mentioned I was going to enhance my BASIC Stamp Preprocessor to add a block IF capability (IF ... ELSEIF ... ELSE ... ENDIF).

Here is my proposed syntax:
Code:
'{$IF condition 1}
  statement block 1
'{$ELSEIF condition 2}
  statement block 2

...

'{$ELSE}
  statement block n
'{$ENDIF}
Which the preprocessor would translate to:
Code:
if (condition 1) then Label1
if (condition 2) then Label2
...

  statement block n
  goto EndIfLabel

Label1:
  statement block 1
  goto EndIfLabel

Label2:
  statement block 2
  goto EndIfLabel

...

EndIfLabel:
Where Label1, Label2, EndIfLabel are labels generated by the preprocessor.


My intention is to allow nested $IF ... $ENDIFs -- although I haven't worked out just how I'm going to implement that yet. I may end up disallowing nesting if implementation becomes too hairy -- or at least not supporting it in the initial implementation(s).

What do y'all think?

FYI: I chose the '{$directive parameter} format to match the '{$Stamp } directive format since I needed to parse it anyway to get the list project files.
__________________
Greg Ross (The Grammar Curmudgeon formerly known as gwross)
S/W Engineer, Team 330, the Beach 'Bots
<--The Grammar Curmudgeon loves this cartoon.
ôLife should not be a journey to the grave with the intention of arriving safely in a pretty and well preserved body, but rather to skid in broadside in a cloud of smoke, thoroughly used up, totally worn out, and loudly proclaiming "Wow! What a Ride!" Hunter S. Thompson
"Playing a practical joke means doing something mean and calling it funny." Me
  #2   Spotlight this post!  
Unread 11-06-2001, 09:52 AM
Joe Johnson's Avatar Unsung FIRST Hero
Joe Johnson Joe Johnson is offline
Engineer at iRobot
AKA: Dr. Joe
FRC #0246 (Overclocked)
Team Role: Engineer
 
Join Date: May 2001
Rookie Year: 1996
Location: Boston, MA
Posts: 2,282
Joe Johnson has a reputation beyond reputeJoe Johnson has a reputation beyond reputeJoe Johnson has a reputation beyond reputeJoe Johnson has a reputation beyond reputeJoe Johnson has a reputation beyond reputeJoe Johnson has a reputation beyond reputeJoe Johnson has a reputation beyond reputeJoe Johnson has a reputation beyond reputeJoe Johnson has a reputation beyond reputeJoe Johnson has a reputation beyond reputeJoe Johnson has a reputation beyond repute
This sounds great.

As to nesting if-elseif-else structures, please try to make this work. There are many situations where this is needed and it would be a bother to be able to us the new structures in one place but not in another. Isn't this a sort of natural recursion application?

To me, one of the biggest issues is generating goto labels that are easy enough to follow that folks that edit the resulting code directly see something that is editible.

How about this format $IF $IFLABEL (optional) $ELSEIF $ELSE $ENDIF

My thoughts would be that if you provided a label, then the label would be used as a basename for the various goto labels in Pbasic, if not, you get what you get.

As to what I mean by a common subroutine, I don't mean jumping to a new program slot and jumping back -- the way Pbasic handles jumps would add a lot of bother and overhead to any such systems. What I do mean is something like the header file, where I could define a subroutine one time and the pre-processor would add the code to the appropriate files for the approriate programming slots.

An input subroutine is a good example. I often end up calling the input subroutine from at least 2 programming slots and sometimes from 3. If I change the variables that the master CPU sends me (perhaps I want delta_t rather that packet_num), I need to change the subrountine in all 3 places or else I get the dreaded "PBasic Error LED of Death" to light up on the Operator Interface and I am dead in the water.

Finally, what about text editing? How do you make your master file that the pre-processor processes? Has anybody made the leap to CodeWright? It is a very good program for C coding and other serious coding projects. One nice thing about CodeWrightt is that it knows the various keywords of the language you are using. It can be set up to show Constants in one color, variables in another, keywords in yet anther, etc. Has anybody taught CodeWright the Pbasic language? Do tell.


Joe J.
  #3   Spotlight this post!  
Unread 11-06-2001, 02:45 PM
Greg Ross's Avatar
Greg Ross Greg Ross is offline
Grammar Curmudgeon
AKA: gwross
FRC #0330 (Beach 'Bots)
Team Role: Mentor
 
Join Date: Jun 2001
Rookie Year: 1998
Location: Hermosa Beach, CA
Posts: 2,244
Greg Ross has a reputation beyond reputeGreg Ross has a reputation beyond reputeGreg Ross has a reputation beyond reputeGreg Ross has a reputation beyond reputeGreg Ross has a reputation beyond reputeGreg Ross has a reputation beyond reputeGreg Ross has a reputation beyond reputeGreg Ross has a reputation beyond reputeGreg Ross has a reputation beyond reputeGreg Ross has a reputation beyond reputeGreg Ross has a reputation beyond repute
Send a message via AIM to Greg Ross Send a message via Yahoo to Greg Ross
Quote:
Originally posted by Joe Johnson
As to nesting if-elseif-else structures, please try to make this work. There are many situations where this is needed and it would be a bother to be able to us the new structures in one place but not in another. Isn't this a sort of natural recursion application?
You're right. This is a natural for recursion -- and that's what I had in mind. I think I should be able to do it without too much trouble, but you never know for sure until you get in there an get your fingernails dirty.



Quote:
To me, one of the biggest issues is generating goto labels that are easy enough to follow that folks that edit the resulting code directly see something that is editible.

How about this format $IF $IFLABEL (optional) $ELSEIF $ELSE $ENDIF

My thoughts would be that if you provided a label, then the label would be used as a basename for the various goto labels in Pbasic, if not, you get what you get.
I like your idea of allowing the user to provide labels, but $IFLABEL just doesn't have "sex appeal" for me. How about if I just take a look at the next non-blank, non-comment line, and if it's a label, I will use it instead of generating a label? Something like:
Code:
'{$IF condition 1}
Label1:
  statement block 1
'{$ELSEIF condition 2}
Label2:
  statement block 2

...

'{$ELSE}
LabelN:
  statement block n
'{$ENDIF}
EndIfLabel:
Quote:
As to what I mean by a common subroutine, I don't mean jumping to a new program slot and jumping back -- the way Pbasic handles jumps would add a lot of bother and overhead to any such systems. What I do mean is something like the header file, where I could define a subroutine one time and the pre-processor would add the code to the appropriate files for the approriate programming slots.
It sounds like the include file concept satisfies this requirement. Nicht Wahr?



Quote:
An input subroutine is a good example. I often end up calling the input subroutine from at least 2 programming slots and sometimes from 3. If I change the variables that the master CPU sends me (perhaps I want delta_t rather that packet_num), I need to change the subrountine in all 3 places or else I get the dreaded "PBasic Error LED of Death" to light up on the Operator Interface and I am dead in the water.
When you say "If I change the variables that the master CPU sends me", you don't mean that you have figured out a way to read different data at different times during a match, do you? That might be a nice feature, but the only way I can envision it being done is with a robot controller restart.



Quote:
Finally, what about text editing? How do you make your master file that the pre-processor processes? Has anybody made the leap to CodeWright? It is a very good program for C coding and other serious coding projects. One nice thing about CodeWrightt is that it knows the various keywords of the language you are using. It can be set up to show Constants in one color, variables in another, keywords in yet anther, etc. Has anybody taught CodeWright the Pbasic language? Do tell.
I've never used CodeWright, but it does sound nifty. I use the StampW editor. Typically, I start out everything at the preprocessor's GUI. I launch StampW from there. After I have finished editing, I exit back to the preprocessor GUI, and have it preprocess the project. After the project has been preprocessed, it gives you the option of launching the editor so you can download the program or continue editing it.
__________________
Greg Ross (The Grammar Curmudgeon formerly known as gwross)
S/W Engineer, Team 330, the Beach 'Bots
<--The Grammar Curmudgeon loves this cartoon.
ôLife should not be a journey to the grave with the intention of arriving safely in a pretty and well preserved body, but rather to skid in broadside in a cloud of smoke, thoroughly used up, totally worn out, and loudly proclaiming "Wow! What a Ride!" Hunter S. Thompson
"Playing a practical joke means doing something mean and calling it funny." Me

Last edited by Greg Ross : 11-06-2001 at 02:50 PM.
  #4   Spotlight this post!  
Unread 11-06-2001, 03:22 PM
Brandon Martus's Avatar Unsung FIRST Hero
Brandon Martus Brandon Martus is offline
busy.
AKA: B. Slash Kamen
no team
 
Join Date: May 2001
Rookie Year: 1998
Location: Nevada, TX USA
Posts: 5,408
Brandon Martus has a reputation beyond reputeBrandon Martus has a reputation beyond reputeBrandon Martus has a reputation beyond reputeBrandon Martus has a reputation beyond reputeBrandon Martus has a reputation beyond reputeBrandon Martus has a reputation beyond reputeBrandon Martus has a reputation beyond reputeBrandon Martus has a reputation beyond reputeBrandon Martus has a reputation beyond reputeBrandon Martus has a reputation beyond reputeBrandon Martus has a reputation beyond repute
Send a message via ICQ to Brandon Martus Send a message via AIM to Brandon Martus Send a message via Yahoo to Brandon Martus Send a message via Skype™ to Brandon Martus
Quote:
Originally posted by Joe Johnson
Has anybody made the leap to CodeWright? It is a very good program for C coding and other serious coding projects. One nice thing about CodeWrightt is that it knows the various keywords of the language you are using. It can be set up to show Constants in one color, variables in another, keywords in yet anther, etc.
We use CodeWright at work so that Borland C++Builder doesn't do funky things to our code. It has a lot of handy features.
__________________
Brandon Martus
e-mail
  #5   Spotlight this post!  
Unread 11-07-2001, 08:18 AM
Lloyd Burns Lloyd Burns is offline
Registered User
FRC #1246 (Agincourt Robotics)
Team Role: Engineer
 
Join Date: Jun 2001
Rookie Year: 1997
Location: Toronto
Posts: 292
Lloyd Burns is an unknown quantity at this point
Why not a CASE x OF statement ?

The structure of the PIC code (was this what Microchip and Scenix were sqabbling over) would make it easy to construct a CASE statement.

CASE x OF
~~0 : y = 3;
~~6 : y = 7
~~1..5 : y = 4
ELSE y = 0;

~~~~~~~~MOVF X,f
~~~~~~~~BTFSC ZERO
~~~~~~~~GOTO YIS3
~~~~~~~~MOVLW .6
~~~~~~~~SUBWF X,w
~~~~~~~~BTFSC ZERO
~~~~~~~~GOTO YIS7
~~~~~~~~BTFSC CARRY 'PIC CODES NOT ~~~~~~~~~~~~~~~~~~~~~~~~' HANDY:BTFSS?
~~~~~~~~GOTO YIS0
~~~~~~~~MOVLW .4
~~~~~~~~MOVWF Y
~~~~~~~~GOTO ENDCASE
YIS3 MOVLW .3
~~~~~~~~MOVWF Y
~~~~~~~~GOTO ENDCASE
YIS7 MOVLW .7
~~~~~~~~MOVWF Y
~~~~~~~~GOTO ENDCASE
YIS0 MOVLW .0
~~~~~~~~MOVWF Y
ENDCASE

And yes, a special case could zero Y differently.
Another alternate would be the table of RETLWs, as in the PBASIC lookup/down instructions.

BTW is there an option available to NOT delete leading spaces when this BB program edits a post ?
  #6   Spotlight this post!  
Unread 11-07-2001, 08:33 AM
Unsung FIRST Hero
Nate Smith Nate Smith is offline
FRC Key Volunteer Trainer
AKA: CrazyNate
no team
 
Join Date: Jun 2001
Rookie Year: 1998
Location: Old Town, Maine
Posts: 1,029
Nate Smith is a splendid one to beholdNate Smith is a splendid one to beholdNate Smith is a splendid one to beholdNate Smith is a splendid one to beholdNate Smith is a splendid one to beholdNate Smith is a splendid one to beholdNate Smith is a splendid one to beholdNate Smith is a splendid one to behold
Send a message via AIM to Nate Smith Send a message via Yahoo to Nate Smith
Re: Why not a CASE x OF statement ?

Quote:
[BTW is there an option available to NOT delete leading spaces when this BB program edits a post ? [/b]
Use the "PHP" formatting option...it uses the PRE tag so that any spaces are kept as typed...the deleting of spaces, unfortunately, is a quirk of standard HTML and not of this board in particular...
__________________
Nate Smith
nsmith@smythsoft.com
12 seasons, 4 teams, and more time logged behind the scorekeeper's table than I care to remember...
returning for 2011? only time will tell...
  #7   Spotlight this post!  
Unread 11-07-2001, 02:55 PM
Greg Ross's Avatar
Greg Ross Greg Ross is offline
Grammar Curmudgeon
AKA: gwross
FRC #0330 (Beach 'Bots)
Team Role: Mentor
 
Join Date: Jun 2001
Rookie Year: 1998
Location: Hermosa Beach, CA
Posts: 2,244
Greg Ross has a reputation beyond reputeGreg Ross has a reputation beyond reputeGreg Ross has a reputation beyond reputeGreg Ross has a reputation beyond reputeGreg Ross has a reputation beyond reputeGreg Ross has a reputation beyond reputeGreg Ross has a reputation beyond reputeGreg Ross has a reputation beyond reputeGreg Ross has a reputation beyond reputeGreg Ross has a reputation beyond reputeGreg Ross has a reputation beyond repute
Send a message via AIM to Greg Ross Send a message via Yahoo to Greg Ross
Re: Why not a CASE x OF statement ?

Quote:
Originally posted by Lloyd Burns
The structure of the PIC code (was this what Microchip and Scenix were sqabbling over) would make it easy to construct a CASE statement.

CASE x OF
~~0 : y = 3;
~~6 : y = 7
~~1..5 : y = 4
ELSE y = 0;
Do we really need a CASE statement language element? It seems to me that it wouldn't add much value to the language beyond what we already have with the PBASIC BRANCH statement.

BTW Lloyd, I don't think we have access to PIC assembly language without breaking the seal and voiding the warranty.
__________________
Greg Ross (The Grammar Curmudgeon formerly known as gwross)
S/W Engineer, Team 330, the Beach 'Bots
<--The Grammar Curmudgeon loves this cartoon.
ôLife should not be a journey to the grave with the intention of arriving safely in a pretty and well preserved body, but rather to skid in broadside in a cloud of smoke, thoroughly used up, totally worn out, and loudly proclaiming "Wow! What a Ride!" Hunter S. Thompson
"Playing a practical joke means doing something mean and calling it funny." Me
  #8   Spotlight this post!  
Unread 11-08-2001, 10:26 PM
Lloyd Burns Lloyd Burns is offline
Registered User
FRC #1246 (Agincourt Robotics)
Team Role: Engineer
 
Join Date: Jun 2001
Rookie Year: 1997
Location: Toronto
Posts: 292
Lloyd Burns is an unknown quantity at this point
Re: Re: Why not a CASE x OF statement ?

Quote:
Originally posted by gwross



BTW Lloyd, I don't think we have access to PIC assembly language without breaking the seal and voiding the warranty.
But you don't have access to IF .. THEN ... ELSE either unless you modify the Parallax token machine. My reply supposed that Parallax was changing PBASIC, and a case statement would take care of the else easily.

Maybe a modification to the preprocessor could make euther statement available.

Personally, I think PBASIC is just one of the givens we work with, and I don't see that changing soon. In Nicholas Wirth can feel strongly about typing, PBASIC can feel strongly about unsigned integers.
  #9   Spotlight this post!  
Unread 11-09-2001, 02:02 PM
Joe Johnson's Avatar Unsung FIRST Hero
Joe Johnson Joe Johnson is offline
Engineer at iRobot
AKA: Dr. Joe
FRC #0246 (Overclocked)
Team Role: Engineer
 
Join Date: May 2001
Rookie Year: 1996
Location: Boston, MA
Posts: 2,282
Joe Johnson has a reputation beyond reputeJoe Johnson has a reputation beyond reputeJoe Johnson has a reputation beyond reputeJoe Johnson has a reputation beyond reputeJoe Johnson has a reputation beyond reputeJoe Johnson has a reputation beyond reputeJoe Johnson has a reputation beyond reputeJoe Johnson has a reputation beyond reputeJoe Johnson has a reputation beyond reputeJoe Johnson has a reputation beyond reputeJoe Johnson has a reputation beyond repute
Small Step toward signed math...

Small step toward signed math:

The main reason I want to use signed math is I want my division to work out properly. In 2's complement math, adds, subtracts, and multiplies take care of themselves (mostly). It is the divide operation that give folks the hassles.

How about if you could tag a part of an expression that may be of unknown sign and then the code could get the math right.

For example:
PWMoutput = (error term) * FeedbackGain >> FeedbackScaling + $7F MAX $FE + $8000 MIN $8000 - $8000

If would be nice if I could flag (error term) as signed for the purposes of the division ">> FeedbackScaling"

The pre-processor could then put in the right IFs, Tests, Gotos, etc. that are typically required to get the division to work right.

It would also be nice to an automatic way to make sure that the results are within the right range for an 8 bit PWM output, eliminating the need for all the MAX's & MIN's and $8000's

Just a thought.

Joe J.

Last edited by Joe Johnson : 11-09-2001 at 02:09 PM.
  #10   Spotlight this post!  
Unread 11-29-2001, 07:17 PM
kiracofe8 kiracofe8 is offline
Registered User
#1317 (Digital Fusion)
Team Role: Engineer
 
Join Date: Nov 2001
Location: Columbus, OH
Posts: 30
kiracofe8 will become famous soon enough
Coincidentally, I got frustrated with PBASIC last year, so one night when I was bored I wrote a PBASIC preprocessor. It has nested If-then-else constructs, as well as do-while loops. I meant to post it here, but I never got around to it. You can take a look at it if you want. The source code is at:

http://www.cis.ohio-state.edu/~kiracofe/epbc-src.tgz

A linux binary is available at

http://www.cis.ohio-state.edu/~kiracofe/epbc-bin.tgz

It's written in straightforward C++, so it should compile in MS Visual C++ although I've never tried it. Note that you'll need lex if you want to modify the lexer. If there is interest, I'll try to get some Windows binaries available. Just e-mail me at kiracofe.8@osu.edu.

As far as the structure of the compiler goes, it's pretty straightforward. I use lex to tokenize the input stream. I wrote the parser myself instead of using yacc (or bison or whatever) b/c the language was so simple, I figured this would be easier. Everything is implemented using C++ virtual functions. This makes the writing of nested constructs very easy. (e.g. we can call a function to output a statement without having to worry about what kind of statement it is, since each statement class knows how to "output itself"). Once you understand the BNF of the language (included in the README), the structure of the code should make sense, I hope...

If you have any comments, questions, or suggestions, let me know...
__________________
/* Daniel */
  #11   Spotlight this post!  
Unread 11-29-2001, 11:30 PM
kiracofe8 kiracofe8 is offline
Registered User
#1317 (Digital Fusion)
Team Role: Engineer
 
Join Date: Nov 2001
Location: Columbus, OH
Posts: 30
kiracofe8 will become famous soon enough
I went ahead and make some Windows binaries.
It's all command-line only stuff still. If someone
wants to whip up a GUI, be my guest.

http://www.cis.ohio-state.edu/~kirac...bc-win-bin.zip
__________________
/* Daniel */
  #12   Spotlight this post!  
Unread 12-15-2001, 05:09 AM
Greg Ross's Avatar
Greg Ross Greg Ross is offline
Grammar Curmudgeon
AKA: gwross
FRC #0330 (Beach 'Bots)
Team Role: Mentor
 
Join Date: Jun 2001
Rookie Year: 1998
Location: Hermosa Beach, CA
Posts: 2,244
Greg Ross has a reputation beyond reputeGreg Ross has a reputation beyond reputeGreg Ross has a reputation beyond reputeGreg Ross has a reputation beyond reputeGreg Ross has a reputation beyond reputeGreg Ross has a reputation beyond reputeGreg Ross has a reputation beyond reputeGreg Ross has a reputation beyond reputeGreg Ross has a reputation beyond reputeGreg Ross has a reputation beyond reputeGreg Ross has a reputation beyond repute
Send a message via AIM to Greg Ross Send a message via Yahoo to Greg Ross
Question Who wants to be a beta tester?

I'm getting pretty close with my BASIC Stamp preprocessor. I have implemented almost all the planned features. If anyone would like to help me beat it up, e-mail me, and I'll send you the program.
__________________
Greg Ross (The Grammar Curmudgeon formerly known as gwross)
S/W Engineer, Team 330, the Beach 'Bots
<--The Grammar Curmudgeon loves this cartoon.
ôLife should not be a journey to the grave with the intention of arriving safely in a pretty and well preserved body, but rather to skid in broadside in a cloud of smoke, thoroughly used up, totally worn out, and loudly proclaiming "Wow! What a Ride!" Hunter S. Thompson
"Playing a practical joke means doing something mean and calling it funny." Me
  #13   Spotlight this post!  
Unread 02-01-2002, 03:18 AM
Greg Ross's Avatar
Greg Ross Greg Ross is offline
Grammar Curmudgeon
AKA: gwross
FRC #0330 (Beach 'Bots)
Team Role: Mentor
 
Join Date: Jun 2001
Rookie Year: 1998
Location: Hermosa Beach, CA
Posts: 2,244
Greg Ross has a reputation beyond reputeGreg Ross has a reputation beyond reputeGreg Ross has a reputation beyond reputeGreg Ross has a reputation beyond reputeGreg Ross has a reputation beyond reputeGreg Ross has a reputation beyond reputeGreg Ross has a reputation beyond reputeGreg Ross has a reputation beyond reputeGreg Ross has a reputation beyond reputeGreg Ross has a reputation beyond reputeGreg Ross has a reputation beyond repute
Send a message via AIM to Greg Ross Send a message via Yahoo to Greg Ross
Thumbs up It's Here!

Finally, I have posted the preprocessor in the white papers area.

Sorry it took so long. My computer crashed just before the new year, and I had to reconstruct a lot of what I had done -- losing a lot of momentum in the process.

Here is the description I posted along with the program:

PRECIS:

A BASIC Stamp Preprocessor which simplifies coding for the BASIC Stamp 2 SX/E/P by providing an include file capability, and enabling structured programming constructs.



INTRODUCTION:
Here is the preprocessor I promised way back when. Sorry it took so long. (My computer crashed back at the end of December, and I had to reconstruct a lot of my work.)

I wrote this program to make programming our robot easier. It started when we first got the robot controller with the BASIC Stamp2 SX, and I needed to define the program data area identically in all the project programs. The original incarnation was limited to inserting an include file, and had a command line interface.

Last year, I added the graphical user interface, and this year, the structured programming capabilities.



INSTALLATION:

Copy the program to your hard disk. (That's all!)



USE:
Run the program. It brings up a Windows Explorer like interface. From there, navigate to where your robot programs are stored (or where you want them to be.)

Assuming you already have a program file, find the file you want to edit (or preprocess) in the file list, and press Ctrl-P to preprocess the file or Ctrl-E to launch the BASIC Stamp Editor to edit the file.

To create and edit a new file from the GUI, type the name of the file you want created into the file name edit box, and press Ctrl-E.

The GUI also allows you to rename (Ctrl-N) and delete (Ctrl-D) files.



DIRECTIVE SYNTAX:

All directives appear within curly braces.

All directives are case insensitive. (i.e. $Include and $INCLUDE are equivalent.)

The $Stamp directive is required by the Stamp editor to be within a comment (i.e. preceded by an apostrophe.) All other directives MAY be preceded by apostrophes, although it is not recommended because of the fact that if you forget to preprocess your program, StampW will accept it as syntactically correct, but the program will not run correctly when downloaded to your robot.

The left brace introducing a preprocessor directive must be the first non-blank character on the line (other than an optional label and the optional apostrophe), and the directive (along with its parameters, if any) must be alone inside the braces. Comments may follow the closing brace.



PREPROCESSOR DIRECTIVES:

{$Stamp processor, file2, file3, ..., file8}
Tells the BASIC Stamp editor the version of the Stamp processor the program will run on, and the program files that belong to the project. (The processor parameter is ignored by the preprocessor. Consult the StampW documentation for the $STAMP directive syntax.) The preprocessor uses the file list to determine which files to preprocess.


{$Include file_name}
Inserts file_name (after preprocessing it) into the program file being processed.


{$StampPPDate}
Causes the preprocessor to insert a DATA statement containing the date and time the file was preprocessed (StampPPDate DATA 24, "Mon Mar 19 21:16:40 2001")
When your program starts up, you can display the date the project was preprocessed with the following commands:
stringLength VAR byte
theIndex VAR byte
TheChar VAR byte
debug CLS 'Clear the debug screen
'Print out the source file timestamp:
read StampPPDate, stringLength
for theIndex=1 to stringLength
read StampPPDate+theIndex, theChar
debug theChar
next
debug CR


{$StampProjectPrefix prefix_string}
Specifies to the preprocessor the output file name prefix. By default, the preprocessor prefixes the output file names with the date in the format yyyy.mm.dd. Output files may be directed to another directory by including a directory path in the prefix string.


{$If if_condition}
if_block
{$ElseIf else_condition}
elseif_block
{$Else}
else_block
{$EndIf}
Causes the preprocessor to generate PBASIC code which, when run, will execute if_block if if_condition is true, elseif_block if else_condition is true, and else_block if none of the above are true. (Both the $ElseIf and $Else directives with their accompanying blocks are optional.)


{$While while_condition}
while_block
{$EndWhile}
Causes the preprocessor to generate PBASIC code that will repeatedly execute while_block as long as while_condition is true.


{$Repeat }
repeat_block
{$Until until_condition}
Causes the preprocessor to generate PBASIC code which will repeatedly execute repeat_block until until_condition is true.



Notes:
The preprocessor requires labels in order to generate code for many of the directives. If labels are not provided, the preprocessor will generate them. The generated labels are of the format SPPLnnnn. You may find the generated code more readable if you provide meaningful labels for these directives.
__________________
Greg Ross (The Grammar Curmudgeon formerly known as gwross)
S/W Engineer, Team 330, the Beach 'Bots
<--The Grammar Curmudgeon loves this cartoon.
ôLife should not be a journey to the grave with the intention of arriving safely in a pretty and well preserved body, but rather to skid in broadside in a cloud of smoke, thoroughly used up, totally worn out, and loudly proclaiming "Wow! What a Ride!" Hunter S. Thompson
"Playing a practical joke means doing something mean and calling it funny." Me
  #14   Spotlight this post!  
Unread 02-01-2002, 06:00 AM
Joe Johnson's Avatar Unsung FIRST Hero
Joe Johnson Joe Johnson is offline
Engineer at iRobot
AKA: Dr. Joe
FRC #0246 (Overclocked)
Team Role: Engineer
 
Join Date: May 2001
Rookie Year: 1996
Location: Boston, MA
Posts: 2,282
Joe Johnson has a reputation beyond reputeJoe Johnson has a reputation beyond reputeJoe Johnson has a reputation beyond reputeJoe Johnson has a reputation beyond reputeJoe Johnson has a reputation beyond reputeJoe Johnson has a reputation beyond reputeJoe Johnson has a reputation beyond reputeJoe Johnson has a reputation beyond reputeJoe Johnson has a reputation beyond reputeJoe Johnson has a reputation beyond reputeJoe Johnson has a reputation beyond repute
Downloading it now...

I can't wait.

Joe J.
  #15   Spotlight this post!  
Unread 02-01-2002, 09:54 AM
GreenDice GreenDice is offline
Registered User
#0891
 
Join Date: Jan 2002
Location: Syracuse, NY
Posts: 33
GreenDice is an unknown quantity at this point
Labels

Greg,

Could you give some examples on how to use labels?

Thanks.
__________________
Peter Liu
Closed Thread


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
PBASIC ARCTAN function Greg Ross Programming 14 05-11-2003 12:28 PM
Obscure PBASIC for RoboEmu rbayer Programming 1 03-28-2003 11:57 PM
PBasic 2.5 vs. 2.0 Anthony Kesich Programming 6 02-09-2003 10:06 PM
emulationFIRST (aka PBasic emulator) Matt Leese Programming 5 06-30-2002 12:06 PM
PBASIC Loop Speed? archiver 2001 3 06-23-2002 11:46 PM


All times are GMT -5. The time now is 09:32 AM.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


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