How do I get the current remaining length of a string?

78 Views Asked by At

I've got an array

DO WHILE (NOTEND = '1'B);
    IF (LENGTH(VALUELIST) > 8) THEN DO;
        VALUELIST = SUBSTR(VALUELIST,8);
    END;
    ELSE DO;
        NOTEND='0'B;
    END;
END;

Now my problem is: Length(valuelist) always returns the original definition of the characterfield: CHAR(500) thus 500. I didn't find any other command there though.

Thus my question is: How can I get the remaining length of that string (aka of its content not the char array itself)?

1

There are 1 best solutions below

0
zarchasmpgmr On

The solution provided by Lasse V. Karlsen is one method. A different, possibly more straight-forward solution would be to use CHAR VARYING (a.k.a. VARCHAR), which maintains the length of the string. After the assignment, LENGTH(VALUELIST) will be correct (8 less than the previous length).