Scratch Variables

  

DEVELOPER

Scratch Variables

Scratch variables are local to the function in which they are defined.  There are three types:

Scratch variables are automatically initialized in the first occurrence within the function (alphanumerics and wides to null and numerics to zero). Scratch variables can be specified as screen and report field variables as well as modified in function logic.

Alphanumeric scratch variables may contain alphanumeric characters only, wide characters only, or both.

Alphanumeric scratch variable names start with $ or $$. If only the first character is a $, the system allocates an alphanumeric scratch variable that can contain up to 30 bytes. If the second character is also a $ the system allocates a variable that may contain up to 80 bytes.

When wide characters are included in an alphanumeric string you may need to allow space for certain shift characters. (The shift characters distinguish the wide characters from the alphanumeric characters). This is implementation-dependent.

Numeric Scratch Variables start with # or ##. If only the first character is a #, the system allocates 15 digits;  If the second character is also a #, the system allocates 20 digits.

Wide Scratch Variable names start with ! or !!. If only the first character of the variable name is a !, the system allocates a wide scratch variable that may contain up to 15 wide characters. If the second character is also a !, the system allocates a variable that may contain up to 40 wide characters.

Comment on this topic

Topic ID: 730014