APREPRO Additional Functionality

Additional APREPRO Functionality includes the following:

1. File Inclusion

APREPRO can read input from multiple files using the include() and cinclude() functions. If a line of the form:

{include(" filename")}


is read, APREPRO will open and begin reading from the file filename. A string variable can be used as the argument instead of a literal string value. When the end of the file is reached, it will be closed and APREPRO will continue reading from the previous file. The difference between include and cinclude is that if filename does not exist, include will terminate APREPRO with a fatal error, but cinclude will just write a warning message and continue with the current file. The cinclude function can be thought of as a conditional include, that is, include the file if it exists. Multiple include files are allowed and an included file can also include additional files. Approximately 16 levels of file inclusion can be used. This option can be used to set variables globally in several files. For example, if two or more input files share common points or dimensions, those dimensions can be set in one file that is included in the other files.

2. Conditionals

Portions of an input file can be conditionally processed through the use of the {Ifdef(variable)} or Ifndef(variable)} constructs. The syntax is:


...Lines processed if 'variable' is not equal to 0


...Lines processed if 'variable' is equal to 0 or undefined



...Lines processed if 'variable' is equal to 0 or undefined


...Lines processed if 'variable' is not equal to 0


The {Else} is optional. Note that if variable is undefined, its value is equal to zero. Ifdef constructs can be nested up to approximately 16 levels. A warning message will be printed if improper nesting is detected. Ifdef(variable)}, {Ifndef(variable)}, {Else}, and {Endif} are the only text parsed on a line. Text following these on the same line is ignored.

3. Loops

Repeated processing of a group of lines can be controlled with the {loop( control)}, {endloop} commands. The syntax is:


...Process these lines 'variable' times


Loops can be nested. A numerical variable or constant must be specified as the loop control specifier. You currently cannot use an algebraic expression such as {loop(3+5)}.

A loop may also be exited before running the specified number of times using a #{Break} statement. As soon as a #{Break} statement is encountered, the loop is exited and the rest of the statements in the loop will not execute. Additional iterations of the loop will not be executed either. For example, the following commands will create 3 bricks:

    brick x 1
    brick x 1

When a #{Break} statement executes, anything in the loop following the  #{Break} statement will be skipped, including the #{EndIf}. For this reason, a #{Break} statement not only exits the loop, but also terminates the most recent #{If} statement exactly as #{EndIf} would do. #{Break} statements should not be used outside of #{If} statements.