PREP : Source language preprocessor Title : PREP Version : 3.1 Date : Dec 18, 2012 Author : J R Ferguson Download: http://hello.to/ferguson E-mail : j.r.ferguson@iname.com This program may be used and copied freely without charge, but only for non-commercial purposes. The author is not responsible for any damage or loss of data that may be caused by using it. Usage : PREP [outfile] [/option ...] COMMAND OPTION MEANING ------- ------ ------- * /* Comment: ignore line from here. COMMAND string /Cstring Specifies command-prefix string. Default '*'. VARBEG string /[string Specify variable start string for substitution. Default '['. VAREND string /]string Specify variable end string for substitution. Default ']'. DEFINE id /Did Define string variuable. DEFINE id=strexpr /Did=strexpr Define string variable, assign value. DEFINE id==strexpr '/Did==strexpr' Same, include leading/trailing spaces. DEFINT id Define integer variable. DEFINT id=mathexpr /Did=mathexpr Define integer variable, assign value. UNDEF id /Uid Undefine variable FULL /F Full expression parsing until end of current file. Default is legacy parsing. See PREPEXPR.TXT for the difference. LIT /L Literal. No command parsing or text replacement until end of current file. LOC [+|-] /O [+|-] Local variable support on/off [+]. Initial value is off. IF ident Process if identifier was definied. IF boolexpr Process if boolean expression yields true. ELSE Invert last IF condition. ELSEIF ident Combine ELSE and IF, needs one ENDIF only ELSEIF boolexpr Same as above ENDIF Ends IF/ELSE or IF/ELSEIF[...] block. PREFIX p1[;p2...] /Pp1[;p2...] Set file search prefix (concatenation) for INCLUDEs. Separate with with ';'. INCLUDE filespec [/option ...] Include [fileprefix]filespec Parse options as in command line. Identifiers should not contain spaces, control characters, or one of the following characters: ( ) < > = + - * / % Do not use one of these words as a variable identifier: AND ITOA NOT OR XOR Internal commands must be specified on one line and are recognized only if they start with the current command-prefix string in column one. There may be one or more tabs or spaces between the command-prefix string and the command keyword. There must be at least one tab or space between the command and its argument. Command keywords and identifiers are not case sensitive. Identifiers can be used both for conditional processing, using IF , and for text substitution. Example: *DEFINE Name=John *IF Name Dear [Name], *ELSE What's your name? *ENDIF will result in: Dear John, The standard function [ITOA]() will translate an integer expression to its alphanumeric string representation. The surrounding [ and ] are the current VARNEG and VAREND values. [ITOAB](,) will translate an unsigned integer expression to its alphanumeric string representation with number base g (1 < g < 37). [ITOABL](,,) will translate an unsigned integer expression to its alphanumeric string representation with number base g (1 < g < 37) and fixed string length , adding leading zeroes if needed. Example: Two plus two makes [ITOA](2+2). will result in: Two plus two makes 4. The same result is created with these two lines: *DEFINT result=2+2 Two plus two makes [result]. INCLUDE and IF [ELSE] commands may be nested. By default, DEFINE, DEFINT and UNDEF are global over included files. To enable local variable support, use the *LOC command or /O option, like in: *LOC + *INCLUDE filename or, shorter: *INCLUDE filename /O+ In both cases, the + sign may be omitted as it is the default. local variable support remains active over nested include files, unless it is explicitly switched off. VARBEG and VAREND are always global over included files. Options specified in an INCLUDE command remain in effect after the included file is processed. In order to maintain compatibility with older releases, the local variables state is initially off. Switching it off has the effect that future include files will use local variables, originally copied from the current ones. Changing its value has no effect on the way variables are handled in the file that is currently processed. The "full expression parsing" option (/F or *FULL) supports expressions like: *IF ([txtvar] = 'string value') AND ([intvar] > 3) When this option is activated, however, expression parsing is not fully downward compatible. For existing scripts it may therefore be better to stick with the (default) legacy expression parser, downward compatible with v3.0 and before. History: v3.1 Dec 18,2012 - Source reconstructed and expanded. - Full expression parsing option (default is v3.0 compatible) - Built with Free Pascal Compiler v2.6.0 (www.freepascal.org) - Tested with Microsoft Windows 8 (64bit) v3.0 Dec 15,2002 - Extended expression syntax. Source lost. v2.3 Dec 26,2001 - Error mesages to console (not stdout) - Prefix concatenation - Command LIT and option /L - Ignore leading/trailing spaces in DEFINE command - Symbol '==' with DEFINE command and /D option - Local variable support v2.2 Feb 19,2000 - Changed author's Internet address. v2.1 Nov 12,1999 (No earlier history available)