Page 2 of 2

Re: Cobol TRIM

PostPosted: Thu Dec 15, 2022 7:46 pm
by Robert Sample
Is it possible to do that in some way?
Yes:
move 'leading' to option
IF OPTION = 'LEADING'
THEN move function trim(checkfield, 'LEADING') to field
ELSE move function trim(checkfield, 'TRAILING') to field

Re: Cobol TRIM

PostPosted: Thu Dec 15, 2022 8:11 pm
by LasseH
Yes but it would have worked if they had put the option in quotes like 'leading' 'trailing' instead of using "reserved" word(s)

Re: Cobol TRIM

PostPosted: Thu Dec 15, 2022 9:28 pm
by Robert Sample
Check the syntax diagram in the Enterprise COBOL Language Reference manual. You can use nothing, or you can use the literal 'LEADING' or you can use the literal 'TRAILING'. What you CANNOT do is to make up your own syntax and expect COBOL to recognize it. This is why your
move function trim(checkfield, option) to field
failed -- you made up your own syntax.

Topic locked as the original question has been answered and we're veering into irrelevant areas.