1

I have this piece of code.

IF         COND(%TRIM(&BLANK_VAR) *EQ '') THEN(DO)
            CALL       PGM(MY_PROGRAM) PARM(&BLANK_VAR)
ENDDO

I would like to check if &BLANK_VAR is an empty string. However my program won't compile because of error message:

* CPD0126 30  Operand not valid or operator missing in COND.

Is this an issue with %TRIM? I tried using %LEN but it gives me lenght of the variable declared, not the actual data inside.

&BLANK_VAR is 10 characters in length. Do I have to do:

IF COND(&BLANK_VAR *EQ '          ')
Ruslan
  • 1,919
  • 21
  • 42

1 Answers1

5

The solution is to simply add an actual space in your two single quotes:

IF         COND(%TRIM(&BLANK_VAR) *EQ ' ') THEN(DO)
            CALL       PGM(MY_PROGRAM) PARM(&BLANK_VAR)
ENDDO

The reason you are getting the error is that two ' right next to each other is acting as an escaped single quote. This typically allows you to embed single quotes into a literal string but in this case it looks to the compiler like you have an invalid single character string.

Player1st
  • 1,575
  • 10
  • 14
  • 1
    There is no BUILT-IN in CLLE for *BLANKS. Using that code will compare the character fields against the string containing the text '*BLANKS'. The first comparison using single quote blank single quote is correct. – ChrisHiebert Apr 16 '21 at 18:19
  • 1
    I didn't realize that. Thanks. I don't use CL all that often. I have removed that suggestion from my answer. – Player1st Apr 16 '21 at 21:08