4.15. counter
4.15.1. Summary
Parameters: file
Positional parameters in same order.
Invalidates cache: YES
Called Routine:
ASP-like Perl call:
$Tag->counter( { file => VALUE, } ) OR $Tag->counter($file, $ATTRHASH);
Attribute aliases
name ==> file [counter file]
Parameters | Description | Default |
file | DEFAULT_VALUE | |
name | Alias for file | DEFAULT_VALUE |
Attributes | Default |
interpolate (reparse) | No |
Other_Charactreristics | |
Invalidates cache | YES |
Container tag | No |
Has Subtags | No |
Nests | Yes |
Tag expansion example:
[counter file] --- TAGRESULT
ASP-like Perl call:
$Tag->counter( { file => VALUE_file }, $body );
or similarly with positional parameters,
$Tag->counter(file, $attribute_hash_reference, $body);
4.15.2. Description
Manipulates a persistent counter, by default incrementing it and returning the new value.
The counter value is stored in the specified file. If the file name begins with a "/" then it is an absolute path. Otherwise, it is relative to VendRoot. The default file is etc/counter. If the file does not exist, it is created and initialized to the value of the start parameter.
The counter is implemented using Perl's File::Counter module, which protects the file against simultaneous access by multiple processes.
WARNING: This tag will not work under Safe, i.e. in embedded Perl.
Additional parameters:
4.15.2.1. decrement=1
Causes the counter to count down instead of up.
4.15.2.2. start=50
Causes a new counter to be created and to start from 50 (for example) if it did not exist before.
4.15.2.3. value=1
Shows the value of the counter without incrementing or decrementing it.