ADD 1 TO cobol
This modifies the variable cobol
. Overflow silently ignored.
ADD 1 TO cobol GIVING GnuCOBOL
This doesn't modify cobol
, the result of the ADD being stored in GnuCOBOL
. Again, overflow of the storage allocation silently ignored (the field will stay at its old value on size errors and there will be no exception raised).
ADD
a b c d f g h i j k l m n o p q r s t u v w x y z
GIVING total-of
ON SIZE ERROR
PERFORM log-problem
NOT ON SIZE ERROR
PERFORM graph-result
END-ADD
Multiple inputs are allowed, with storage size testing explicit. COBOL has an intrinsic FUNCTION E
, so it not a wise choice for a single letter identifier.
SIZE ERROR
in COBOL is dependent on type and/or PICTURE
. A PIC 9
field will only safely store values from 0 to 9, an intermediate result of 10 would trigger the ON SIZE ERROR
phrase in that case.