Sub-routines

<< Click to Display Table of Contents >>

Navigation:  Script Generator > Special features >

Sub-routines

Previous pageReturn to chapter overviewNext page

A sub-routine is a practical feature that makes it easier to maintain script sequences by placing parts that are used in multiple script sequences in a separate sub-routine that is called from the other script sequences. In that way, if you need to make an adjustment, you can do that in one place, instead of many.

 

Consequently, a sub-routine script sequence will act as part of another script sequence. Typically, it will act as part of the main part. Therefore, a sub-routine should have an empty header, and an empty footer.

 

To call a sub-routine, you use a dollar-sign ("$") followed by the name of the sub-routine script sequence.

 

A sub-routine script sequence can be named anything. However, since sub-routines lack header and footer, they cannot be used "stand-alone". Therefore, it is a good idea to separate them from conventional script sequences using some kind of naming convention, thereby avoiding unnecessary mistakes. When it comes to standard cadett ELSA script sequences, all sub-routines are named with underscore ("_") as first character. This will place the sub-routines at the end of the list, after standard script sequences that typically have names beginning with zero ("0"),  and user defined script sequences typically with names beginning with a letter.

 

You are encouraged to use the same convention for your own sub-routines.

 

Typical examples of sub-routine script sequences are the ones used to specify a standard layer setting (_0LAYER_0 - _0LAYER_5).

 

The content of _0LAYER_2 is shown in the figure below.

 

Figure 1481:  The "_0LAYER_2" sub-routine

Figure 1481:  The "_0LAYER_2" sub-routine

 

This sub-routine is used in many other script sequences, like for instance 0PDF_FREEGEN_Q, shown in the figure below.

 

Figure 1482:  The "0PDF_FREEGEN_Q" script sequence which uses the "_0LAYER_2" sub-routine

Figure 1482:  The "0PDF_FREEGEN_Q" script sequence which uses the "_0LAYER_2" sub-routine

 

The second line in the main part constitutes a call to the _0LAYER_2 sub-routine, which may be altered or otherwise extended in one place, which will then affect all script sequences where it is used.