Maintain an External Counter

Subroutine Name Executable Example Viewable Example

W3CNTR

E3CNTR

E3CNTR

Description

Maintain a counter which is stored on a text resource file. The counter can be read, set to a specific value or increased. If the resource does not yet exist, it is allocated automatically.

Parameters
1 W3CNTNAM   (A) DYNAMIC BY VALUE          /* i /m : Resource name, '.txt' is added automatically.
1 W3CNTVAL   (A) DYNAMIC                   /* io/m : Counter
1 W3OPTION   (A) DYNAMIC BY VALUE OPTIONAL /* i /o : Option; possible values are:
*                                          /*        'INC'   Increment the counter by 1 (default)
*                                          /*        'READ'  Read the counter
*                                          /*        'RESET' Set the counter to 0
*                                          /*        'SET'   Set the counter to W3CNTVAL
1 W3RESPONSE (I4)                          /* o /m : Response code; possible values are:
*                                          /*        1  Resource name not specified
*                                          /*        2  W3CNTVAL not numeric for W3OPTION='SET'
*                                          /*        3  Invalid option W3OPTION specified
How To Invoke
CALLNAT 'W3CNTR' W3CNTNAM W3CNTVAL W3OPTION W3RESPONSE

CALLNAT 'W3CNTR' 'MY-COUNTER' W3CNTVAL 'INC' W3RESPONSE