Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   General Forum (http://www.chiefdelphi.com/forums/forumdisplay.php?f=16)
-   -   Simplifying PBasic (http://www.chiefdelphi.com/forums/showthread.php?t=887)

Greg Ross 01-11-2001 21:26

Re: BASIC Stamp Preprocessor
 
Quote:

Originally posted by Joe Johnson

...There are a few "macros" that if someone wrote, I would be very grateful for:
1) the ability to have a single "header" file for all modules with all variable, alias & constantant definitions. As it stands, when I use several programing slots, I have to have the same declaration in many files. This can lead to subtle errors if I fix something in one file and forget to fix it in another.
2) an IF-THEN-ELSEIF-ELSE structure
3) something like the "macro" function in C (or C++)
4) way of having common subroutine definitions that would allow a singe definition of a subrountine that is shared by multiple programming slots (subroutines with names like "GetData" & "PutData" come to mind).

<snip>

Joe J.



I wrote a program last year (in Delphi, appropriately enough) which is quite similar to what Joe J. suggested. It preprocesses each program of a BASIC Stamp project and inserts a header file into it.

In its current form, it recognizes the standard '{$STAMP ...} directive as well as two new directives: '{$INCLUDE ...} and '{$StampPPDate}.

The '{$STAMP ...} directive is used to determine which program files belong to the project so that it can preprocess all of them in one swell foop.

'{$INCLUDE ...} causes the specified include file to be inserted into a program file.

'{$StampPPDate} causes the date and time the project was preprocessed to be inserted into the source. I added this directive so that I could print it out at startup and get warm fuzzies about the version of the program currently loaded into the robot.

Currently, the preprocessor renames the input files (appending .bak to the files names) and creates new files. I am planning on reopening the code and coming up with a safer scheme -- like maybe generating a set of files with a common prefix so that all the files in a project appear together in a sorted directory listing. The prefix might be the date and time or a version string. I'm open to suggestions.

I will probably try implementing $IF, $ELSEIF, $ELSE, $ENDIF directives ($THEN is kind of superfluous isn't it?) and I will think about a $DEFINE macro capability.

As for the "common subroutines", Joe, are you thinking about generating code which will make a call to a subroutine in another program slot and then return when it's finished? I tried something like that before, and decided it wasn't worth the effort. Or were you thinking of a "common" routine which actually exists in each of the program slots, and would be called locally? That certainly seems doable. As a matter of fact, it could probably be done with the program as it currently stands: Just $INCLUDE a file which contains the desired subroutine in each of your programs.

If anyone is interested in getting a copy of what I currently have and/or whatever I come up with, just e-mail me. I offered it last year, and only had one or two takers.

Greg Ross

Greg Ross 06-11-2001 01:36

This thread has been moved to the Technical Help Forum
 
This thread has been adjourned to the Technical Help Forum. Please go to Improving PBASIC: Request for Comments


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

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