![]() | ![]() | ![]() | ![]() | ![]() |
The #NextId command is designed to make it easy for you to generate code (for example rexx) with global variable names (rexx or ppwizard variables) that will not clash with others of the same name. It does this by creating a unique namespace.
For example you may have a global variable called "string", it may be used in a number of locations (including called subroutines), if no care is taken you may "corrupt" the value. Now in rexx you could use the "procedure" command however there are reasons why you would not want to use it. This command allows you to call the variable by the name "@@string" and have the '@@' (or whatever characters you choose) replaced with a unique identifier.
Note that there is only ever one ID in use at any time. Apart from the obvious use of having short unique variable names without risk of clashing with those defined elsewhere in your code you can also protect yourself from clashing with variables that ppwizard uses.
[WhiteSpace]#NextId ["]ON["] | ["]OFF["]
This format of the command is to turn OFF (the default state) or ON the Next ID processing state. When turned on, processing resumes with the same counter and other information as specified when processing was turned off.
[WhiteSpace]#NextId [["]ToReplace["] [["]IdMask["] [["]Counter["]]]]
This form of the command turns on Next ID processing.
The "ToReplace" parameter can be any string (the default being "@@"). This string will be replaced in any line read from a file. A value of "" can be used to indicate that the last used or default value should be used. You must carefully pick this value so that you will never use it in your source code for any other reason (such as in a literal). The use of <?xXX> codes is one way of handling the odd occurance of the string when it is not a Next ID marker.
The "IdMask" parameter is used to define how the replacement value should look. The mask would normally contain one "*" character to indicate where the unique number should be placed. A value of "" can be used to indicate that the last used or default should be used. PPWIZARD always adds an underscore to the end of a mask, this is to reduce the chance that they may clash with your normal variables! For example you could specify "GV*" which would generate "GV1_", "GV2_" etc.
The "Counter" parameter can be used to supply an initial value for the counter (an integer). It is up to you to ensure that you either change the mask or don't reuse a number.
The following shows some rexx fragments where I am using Next ID processing to ensure that each routine has it's own variables (which other routines don't also use).
;================= Function1: ;================= #NextId #define @@FRED ... parse arg @@Parm1, @@Parm2 ... @@Result = Function1(1, 2) return(@@Result || @@Parm1 || <$@@FRED>) ;================= Function2: ;================= #NextId #define @@FRED ... parse arg @@Parm1, @@Parm2 ... @@Result = ... return(@@Result)
Note that the ppwizard variable "FRED" and the rexx variables "Parm1" and "Parm2" actually have different names betwwen "function1" and "function2" and therefore do not overwrite each overs values.
![]() | ![]() | ![]() | ![]() | ![]() |