The enumerating SUBs are used in a similar way as the structure type SUBs. A common use for those enumerated variables are the definition of object types, return values, error numbers etc.
Example: (defining some return values) -------------------------------------- SetENUM 0& IncEVAR RETURN_OK& IncEVAR RETURN_WARN& IncEVAR RETURN_ERROR& IncEVAR RETURN_FAIL& and again with explaination: ---------------------------- SetENUM 0& 'this SUB does init the enumerating base number IncEVAR RETURN_OK& 'set the variable RETURN_OK& = offset counter (is zero from the init above) 'increment the offset counter by 1 for the next variable IncEVAR RETURN_WARN& 'set the variable RETURN_WARN& = offset counter (now 1 from last increment) 'increment the offset counter by 1 for the next variable IncEVAR RETURN_ERROR& 'set the variable RETURN_ERROR& = offset counter (now 2 from last increment) 'increment the offset counter by 1 for the next variable IncEVAR RETURN_FAIL& 'set the variable RETURN_FAIL& = offset counter (now 3 from last increment) 'increment the offset counter by 1 for the next variable
Another Example: (separating the OK value from error levels by setting a new base in between, you may set a new base at any time) ---------------------------------------------------------------------- SetENUM 0& IncEVAR RETURN_OK& SetENUM 10& IncEVAR RETURN_WARN& IncEVAR RETURN_ERROR& IncEVAR RETURN_FAIL& and once again with explaination: --------------------------------- SetENUM 0& 'this SUB does init the enumerating base number IncEVAR RETURN_OK& 'set the variable RETURN_OK& = offset counter (is zero from the init above) 'increment the offset counter by 1 for the next variable SetENUM 10& 'init a new enumerating base number IncEVAR RETURN_WARN& 'set the variable RETURN_WARN& = offset counter (is 10 from the new base init) 'increment the offset counter by 1 for the next variable IncEVAR RETURN_ERROR& 'set the variable RETURN_ERROR& = offset counter (now 11 from last increment) 'increment the offset counter by 1 for the next variable IncEVAR RETURN_FAIL& 'set the variable RETURN_FAIL& = offset counter (now 12 from last increment) 'increment the offset counter by 1 for the next variable Likewise you could use DecEVAR to generate decrementing variable numbers. Mixing IncEVAR and DecEVAR in the same sequence seems useless. Back to Types Overview