Preprocessor inserting scripts

<< Click to Display Table of Contents >>

Navigation:  Command Language > Preprocessor >

Preprocessor inserting scripts

For large projects it often makes sense to break the CL script into a number of separate files.  Inserted files can be included at any point.

When running tables you can include additional scripts by using a *INSERT command as a Tables syntax or Manip syntax.

You may wish to use *PUSH and *POP to make sure you don't overwrite indices in an inserted CL script.

Inserted scripts should use the extension .stp, or .stpu if UTF-8 encoded.

*INSERT

The *INSERT command tells the preprocessor to stop reading the current file and start reading another.

At the end of the inserted file the preprocessor returns to the original file and continues processing from the point immediately following the *INSERT command.

The same file can be inserted more than once.

The form of the command is:

[*INSERT filename]

The filename may contain any characters that are legal for a file name. Full path names are allowed.

When looking for the file, the preprocessor will automatically add the extension ".stp" to the file name if this is not included.

If the file specified is not found, then it will look in the CL folder which is C:\ProgramData\NetMR Ltd\CL for a file with the same name and use that instead.

There is no limit on the number of files or how many times each file is inserted.

*INSERT commands may be nested; that is, an inserted file may contain other *INSERT commands. The nesting may not, however, be recursive in any way.

*INSERT commands may appear within loops.

Examples of *INSERT commands:

[*insert intro]

[*insert C:\files\p123.stp]

[*insert file[Loop]]

[*insert [1.Next]]

[*insert [Product.Loop][&Part].txt]

[*insert ..\common\formats]

*PUSH

This command saves the values of some or all of the indices so that they can be restored later with a *POP command.

The form of the command is:

[*PUSH]

[*PUSH index,index, ... ,index]

Try to use unique names for indices to avoid needing to use *PUSH and *POP.

If you write an insert file for use with many projects you should use *PUSH at the beginning and *POP at the end of the insert file to ensure you do not tamper with any indices in the calling scripts  This applies to scripts in ProgramData that contain preprocessor commands.

The *PUSH command saves the current index values. It can work selectively, saving only some of the indices, allowing the others to be overwritten.

The values of indices are not altered by the *PUSH command.

The next occurrence of a *POP command will cause the saved values to be restored.

*PUSH and *POP can be nested.

Examples of *PUSH commands:

[*push]

[*push Loop,LoopA,LoopB]

*POP

This restores all the index values saved by the last *PUSH encountered.  The form of the command is:

[*POP]

Here is an example of the use of *PUSH and *POP

in the main stp file:

[*do lpLoop=1:4] [*insert filex.stp] [*end lpLoop]  ! in the main CL script

[*push][*do lpLoop=1:8][*set Start = (lpLoop*8)-7][*end lpLoop]... [*pop] ! in filex.stp

In this example the index lpLoop in the insert file does not affect the loop in main CL script.