home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C!T ROM 2
/
ctrom_ii_b.zip
/
ctrom_ii_b
/
PROGRAM
/
FOXPRO
/
PRE307
/
PRE.DOC
< prev
next >
Wrap
Text File
|
1990-05-04
|
22KB
|
708 lines
PRE - Preprocessor Version 3.07, copyright (C) 1988-90 by Gary Crouse.
A preprocessor for Clipper and other dBase style source code.
This program is similar in function to preprocessors for C and other
language compilers.
Features:
Constant and simple function substitution (#DEFINE).
Include files (#INCLUDE).
Include blocks of source code (#LIBRARY, #<library identifier>).
Conditional compilation or processing (#IF, #IFDEF, #IFNDEF, #IGNORE).
Comment or skip blocks (#COMMENT/#XCOMMENT, #GOTO, #LABEL).
If the program terminates with an error (usually a file not found),
DOS errorlevel is set to 1.
Run a DOS program upon successful completion.
Syntax:
PRE [<Input Filename[.pre]>] [<Output Filename[.prg]>] [[/|-]switches]
If no filenames are specified on command line, a help screen is
displayed and the program will prompt for input and output filenames.
If only the input file is specified on the command line then the
output filename is assumed to be the same as the input filename but
with an extension of ".PRG". If no extension is given for the input
file, then ".PRE" is assumed. If no extension is given for the output
file, then ".PRG" is assumed. Input and output filenames may include
complete drive and path specification. The output and input files
must be different - i.e. the input file cannot be overwritten by the
output file (!).
Pressing the escape key at a prompt or during processing will
terminate the program.
Environment Variable:
Command line parameters may be placed in a DOS environment variable
called "PRE". Parameters in the environment variable are processed
before parameters on the command line.
Example:
set pre=/q+ /o+
Special Input filenames:
#<library identifier>
Extracts a library source code block.
See #LIBRARY.
#LIBNAMES
Extracts a list of the module names in a source code library.
See #LIBRARY.
Switches:
Command line switches are preceded by "-" or "/" and may appear
anywhere on the command line and in any order.
Switches can be upper case or lower case and used in any of these
formats:
/q /o
/qo
-q /o
Switches /1 /2 /B /C /L /O /Q /S and /T are on/off type switches. An
on/off switch is turned on by following it with a plus sign (+) or
nothing, and turned off by following it with a minus sign (-).
(NOTE: this is a significant change from some previous versions, where
on/off type switches not followed by a plus or minus simply toggled
the previous state.)
Example:
/o+ /q- /l
("O" is on, "Q" is off, "O" is on.)
With the exception of /#, /D, and /I, switches should appear only once
on the command line. The last occurrence of other switches will be
the one to take affect.
/#<directive>, /@<directive>
Command line directive.
Directive must be in quotes (").
Limited to 255 characters or maximum DOS command line length.
Processed with implicit #XLIST and #XBLANK directives to maintain
line number alignment between input and output files.
Multiple command line directives may be used.
Example:
pre test /#"define esc 27"
/', /"
Select single or double quotes for use with the "stringizing"
operator (#).
Default is double quote (").
/1 , /2
Ignore single/double quotes in function defines.
Allows processing of directives within quotes.
ON is the same as #SQUOTE/#DQUOTE, OFF the same as
#XSQUOTE/#XDQUOTE.
Default is OFF.
/B
Blank lines and comments are copied.
ON is the same as #BLANK, OFF the same as #XBLANK.
Default is ON.
See #BLANK.
/C
Case sensitivity for #DEFINE identifiers.
Turning case sensitivity off will cause slower processing.
Default is ON.
/D<identifier> [<constant or expression>]
Command line #DEFINE.
Optional constant or expression must be in quotes (").
Limited to 255 characters or maximum DOS command line length.
Processed with implicit #XLIST and #XBLANK directives to maintain
line number alignment between input and output files.
Multiple command line defines may be used.
See #DEFINE.
Examples:
pre test /ddebug
pre test /d"esc 27"
pre test /dv1 /dv3
/H, /?
Help.
Displays the following help screen and then ends the program.
/I<filename>
Command line #INCLUDE.
Limited to 64 characters.
Processed with implicit #XLIST and #XBLANK directives to maintain
line number alignment between input and output files.
Multiple command line includes may be used.
See #INCLUDE.
Example:
pre test /ikeydefs.inc
/L
List.
Directives are copied as comments.
ON is the same as #LIST, OFF the same as #XLIST.
Default is ON.
See #LIST.
/M
Math.
Constant expressions in #DEFINES are evaluated. Parameter
substitutions are made before evaluation.
ON is the same as #MATH, OFF the same as #XMATH.
Default is ON.
See #MATH.
/N<filename>
Library file name.
The default name is "LIBRARY.SRC".
See #LIBRARY.
/O
Overwrite existing output file without warning.
If /O is off and the output file already exists, a warning prompt
appears.
Default is OFF.
/P<path>
Path for includes and library.
See #PATH.
/Q
Quiet.
No Display of filenames or line numbers.
Default is OFF.
/R<DOS command>
Run a DOS command after completion of processing.
Runs only if processing completes without error.
The output file name will be applied as a parameter unless
<DOS command> is in quotes. If <DOS command> contains spaces, it
must be surrounded by quotes. If "%s" appears in <DOS command>,
the output file name will be substituted. Memory available to the
DOS command is reduced by about 100k.
Examples:
pre test /rclipper
(will run: clipper test.prg)
pre test /r"clipper %s -m"
(will run: clipper test.prg -m)
pre test /r"DIR"
(will run: DIR)
To save the memory overhead of the run command use a batch file:
pre test
if not errorlevel 1 clipper test
/S
Show Defines.
After all other processing is done, displays a list of all the
#DEFINES encountered.
Useful for debugging.
Default is OFF.
/T
Test Date.
Process only if the input file date and time is later than the
output file date and time.
Default is OFF.
/U
Update default switches.
Used in conjunction with the other switches to change the program
defaults.
If used with versions of DOS older than 3.0, "PRE.EXE" must be in
the current directory.
Updates the program file and then exits without processing any
input files.
When used with /I, /D, or /# switches, stores the first of each
switch found. With other switches stores the last occurrence of
the switch.
Warning - switches in the pre environment variable will affect
the result of the update switch.
Directives:
All directives can be upper or lower case (#define,#DEFINE), but
parameters may depend on the setting of the /C switch.
A directive must be the only thing on a line except for inline
comments (&&). Inline comments do not become part of the directive.
Any physical line beginning with a poundsign (#) will be treated as a
directive. Continuations (;) are not recognized in regular source
lines so do not use continuations to break up an expression that is to
be expanded by the preprocessor. Continuations may be used with
directive declarations, but the combined length may not exceed 255.
Directives are evaluated after and therefore override any equivalent
command line switches.
#<library identifier>
Include a source code block.
See #LIBRARY.
#* [<comment>]
Preprocessor comment line.
#BLANK (#XBLANK)
Blank lines and comments are (are not) copied to the output file.
Overrides /B.
To keep output file line numbers aligned with input file line
numbers, leave #BLANK on and #LIST on (see #LIST).
Default is #BLANK.
#COMMENT (#XCOMMENT)
Begins (ends) a comment block.
Lines following #COMMENT are commented out with an asterisk (*)
until a #XCOMMENT directive occurs.
Default is #XCOMMENT.
#DEFINE <identifier or function> [<constant or expression>]
An identifier consists of letters,numbers, or underscore up to a
maximum length of 255.
A function is an identifier with a set of parentheses containing
optional replaceable parameters. Function invocations may be
nested. Warning: be sure that complex expressions do not create
a definition loop. In some cases, invoking a function using the
same variable names that were used in the function definition can
confuse the preprocessor (see the examples).
The <constant or expression> will be used by the preprocessor to
replace any occurrences of the <identifier or function> in the
source code.
The maximum length of a <constant or expression> is 255.
The total length of the #DEFINE may not exceed 255 characters.
Replacements will not be done within comments, quotes (single or
double), text blocks, or #IGNORE blocks.
The <constant or expression> may be a previously defined
identifier or function. The <constant or expression> is optional
(see #IF, #IFDEF, #IFNDEF).
#DEFINE's may be stacked (#DEFINE the same identifier multiple
times) and then unstacked one at a time with #UNDEF (useful for
creating "local" #DEFINE's).
Examples:
#define esc 27
Any occurrence of 'esc' will be replaced with '27'.
#define zips esc
Assuming that 'esc' was previously defined as '27', any
occurrence of 'zips' will be replaced with 27.
#define zips Hotsy Totsy
'zips' has been stacked and will now produce 'Hotsy Totsy'.
#undef zips
'zips' will produce '27'.
#undef zips
'zips' will now produce 'zips'.
#define inc(x) x = x + 1
Any occurrence of the pattern 'inc(something)' will be
replaced by 'something = something + 1'.
#define keypress(c) keyboard(chr(c))
Assuming the previous definitions, 'keypress(esc)' will be
translated to 'keyboard(chr(27))'.
#define max(i,j) if(i>j,i,j)
At least one bizarre example is required - 'max(max(A,B),C)'
will produce 'if(if(A>B,A,B)>C,if(A>B,A,B),C)'.
#DQUOTE (#XDQUOTE)
Process inside double quotes.
See switch /2.
#GOTO <label>
Skips to the specified label, commenting out all lines in
between. The label must occur AFTER the #GOTO directive -
backward references are not allowed. If the label is not found
the program ends with an error.
See #LABEL.
#IF [<identifier>] [<constant>]. . . [#ELSE] . . . #ENDIF
If <identifier> is equal to <constant>, process following lines
until #ELSE or #END is found. If <identifier> and/or <constant>
is left out, the following lines are NOT processed.
May be nested up to 100 deep.
See #IFDEF.
#IFDEF [<identifier>] [constant or expression] . . [#ELSE] . . #ENDIF
If defined . . .
Blocks of code may be processed or ignored depending on whether
<identifier> has been defined. The second parameter of the
#DEFINE statement is ignored in this context.
#IFDEF without an identifier will effectively comment out a block
of code.
May be nested up to 100 deep.
Example:
#define debug
#ifdef debug
? 'Debugging'
#endif
#IFNDEF <identifier> . . . [#ELSE] . . . #ENDIF
If not defined . . .
See #IFDEF.
#IGNORE (#XIGNORE)
Copy following lines to output file but do not (do) process.
(Lines beginning with '#' are not copied).
Default is #XIGNORE.
#INCLUDE <filename>
The file specified by <filename> will be processed and
incorporated into the output file. The filename may include drive
and path.
#INCLUDE's may be nested (i.e. an included file may include
another file, etc.) but beware of the snake eating its tail.
See QINCLUDE.
#LABEL <label>
Identifies a label for the #GOTO directive. A label may be any
combination of letters, numbers, and underscores up to a length
of 255 characters.
#LIBRARY <filename>
The filename (may include path) of a source code library.
Overrides /N.
The default filename is 'LIBRARY.SRC'.
A source code library is a file with blocks of code in the
following format:
note <description of block>
*<library identifier>
.
.
source code
.
.
A block ends at the next line that starts with 'note' or *eof.
The library format is compatible with the SourceView library
format used in dBRIEF (trademark of Global Technologies Corp).
The <library identifier> has the same format as directive
identifiers.
#LIST (#XLIST)
Directives are (are not) copied to the output file as comments
(preceded by '*').
Overrides /L.
To force the line numbers of the output file to correspond with
the line numbers of the input file, turn #LIST on in the input
file and off in any #INCLUDE files (see #QINCLUDE).
The default is #LIST.
#MATH (#XMATH)
Constant expressions in #DEFINES are evaluated. Parameters are
substituted before evaluation.
Example:
#define n 4
#define arrcnt n + 1
? arrcnt
with math on becomes: ? 5
with math off : ? 4 + 1
#PATH <path>
If #INCLUDE or #LIBRARY filenames are given without a drivespec
or path, the preprocessor looks for the file first in the default
directory, then in the #PATH path. #PATH will override /P.
#QINCLUDE <filename>
#INCLUDE with implicit #XLIST and #XBLANK.
Useful for keeping line number alignment between input and output
files.
See #INCLUDE.
#SQUOTE (#XSQUOTE)
Process inside single quotes.
See switch /1
#UNDEF <identifier or function>
Undefines a previous #DEFINE.
See #DEFINE.
#XBLANK
See #BLANK.
#XIGNORE
See #IGNORE.
#XLIST
See #LIST.
#XMATH
See #MATH.
Operators:
Concatenating operator (##).
Used in the <constant or expression> part of a #DEFINE to join
two parameters. Parameters are reevaluated after joining.
Examples:
#define jam(i) X##i
jam(4)
(translated to: X4)
#define stickto(x,y) x##y
stickto(Altos,4)
(translated to: Altos4)
#define n 9
stickto(Knight,n)
(translated to: Knight9
Stringizing operator (#).
Used in the <constant or expression> part of a #DEFINE to place
quotes around the following parameter. The parameter is
evaluated before the quotes are inserted. If stringizing results
in adjacent quotes, the quotes are removed and replaced by a
single space.
Single or double quotes may be selected with the /' and /"
switches.
Examples:
#define stringer(x) #x
? stringer(Spurious)
(translated to: ? "Spurious")
#define message(msg) ? #msg"Error"
message(Unknown)
(translated to: ? "Unknown Error")
#define number 4
#define count(n) #n#times.
? count(number)
(translated to: ? "4 times."Error Messages.
Where appropriate, the following error messages will include the
filename, line number, and the contents of the line being processed.
In some cases the line will be displayed partially translated.
#ELSE without #IF.
#ELSEIF without #IF.
#ENDIF without #IF.
DEFINE definition <constant or expression> exceeds length limit: 255
DEFINE <identifier> exceeds length limit: 255
Disk Full, program terminated.
Escape pressed, program ended.
Expression too complex, or definition loop.
File: <filename> not found.
Input file: <filename> not found.
Invalid directive: <identifier>
Invalid drive: <drivespec>
Invalid output file: <filename>
Invalid Parameter: <command line parameter>
Invalid switch: <switch>
Invalid drive: <drivespec>
Label not found: <label>
Library file: <filename> not found.
Maximum command line directives exceeded: 50
Maximum Include nesting level exceeded: 10
Maximum line length exceeded: 255
Maximum nesting level exceeded: 10
Maximum number of #DEFINES exceeded: 4000
Out of Memory
Output file <filename> is "read only" !
Output file <filename> is same as input file !
Too Many files open: <number>
Unmatched Parentheses in function.
Update failed: <program name> not found.
Limits:
Number of Defines 4000 or available memory.
Size of directive identifier 255*
Size of defined constant or expression 255*
* Note: Sum of identifier size and defined constant or expression
cannot exceed maximum line length (255).
Number of command line parameters 50 or DOS limit on command
length.
Line length 255
File length Available disk space.
#INCLUDE nesting 10 or available memory or DOS
limit on number of open files.
#IF,#IFDEF,#IFNDEF nesting 10
Minimum available memory required 200k (for about 200 defines).
Run Switch (/r) memory overhead 136k
Technical support:
Available to registered users by mail or Compuserve.
Gary Crouse
4629 S. Xavier Street
Denver, CO 80236
(CompuServe: 71525,1417)
Phone: (303) 795-6719
REGISTRATION
Name ___________________________________ DATE______________
Company ________________________________ PRE VERSION # ____
Address ___________________________________________________
City, State, Zip __________________________________________
Phone ________________________ Compuserve ID ______________
Where did you get your copy of PRE ? ______________________
Registration Fee: $40.00
Registered users will receive:
The current version of the preprocessor.
Printed documentation.
Pre.ng - Pre documentation in Norton Guides format
Apply.exe - a global program execution filter.
Predoc.com - a #comment extract filter.
Technical support.
To register your copy of this software, fill out this form and send it with
payment to:
Gary Crouse
4629 S. Xavier Street
Denver, CO 80236