PPWIZARD is a free preprocessor for HTML, REXX, Visual Basic or any text files.
![]() | ![]() | ![]() | ![]() | ![]() |
<?Unique[:format]> |
This variable will be replaced by a unique number every time it is used.
Note that it symbol takes a parameter which can be used to format the number, please see FormatNumber()) for more details of the parameter).
This is a Standard Definition which always exists (you don't need to #define it). Note that you can create your own variations or completely new ones (see the examples).
Example of Creating Your Own Counter |
If you wanted to have a number of counters running so that each is consecutive (no gaps) then this is one possible and self documenting way:
;--- Generic Counter --- #NextId #define Counter \ <$Rexx4Counter {$?} $$RXEXEC> #DefineRexx 'Rexx4Counter' ;--- Inc the value (start with 1) --- @@CntVAR = 'Counter_{$#1}' ;;Generate Rexx var name unlikely to class with anything! @@NumDigits = '{$Digits=^3^}' ;;By default padded to 3 digits if symbol(@@CntVAR) <> 'VAR' then @@Val = 1; ;;Start with 1 else @@Val = value(@@CntVAR) + 1; ;;Incremented existing counter call value @@CntVAR, @@Val; ;;Remember value ;--- Pad the value (NEVER truncate!). Can "enable" correct sorting --- if length(@@Val) >= @@NumDigits then RxExec = @@Val; ;;Don't pad! else RxExec = right(@@Val, @@NumDigits, '0'); ;;Pad to left with zeros #DefineRexx ;--- Use the counter --- Counter X is now: <$Counter "X"> Counter Y is now: <$Counter "Y"> Counter X is now: <$Counter "X">
Note that I very carefully did not use #evaluate etc so that PPWIZARD would never complain about the counters use even if used on PPWIZARD commands (where it might overwise cause an error). Also note that you will still need to be careful about how the macro is used as it does not care about whether the number is generated into the output file, it just cares about macro expansion.