FUNCTION LENGTH() in PERFORM VARYING

From: Lueko Willms (l.willms_at_jpberlin.de)
Date: 12/21/04


Date: 21 Dec 2004 18:44:00 GMT

Again with Compiler Fujitsu 3.0 I have another problem:

I wanted to calculate the length of a string (subtracting the trailing
blanks) by one of the methods presented by Chuck Stevens, but the
compiler won't let me specify a FUNCTION as argument for the FROM
clause

   I have a data structure like this:

[code]
 01 OUTFILE-NAME.
     40 Laenge PIC 9(4) COMP.
     40 FIX PIC X(512).
     40 VAR REDEFINES FIX.
         41 FILLER PIC X
            OCCURS 0 TO 512 TIMES
            DEPENDING ON Laenge OF NAME
     .
[/code]

   and a piece in PROCEDURE DIVISION like this:

[code]
       PERFORM VARYING Laenge OF OUTFILE-NAME
                 FROM FUNCTION LENGTH(FIX OF OUTFILE-NAME) BY -1
*> FROM Laenge OF OUTFILE-NAME BY -1
             UNTIL Laenge OF OUTFILE-NAME = 0 OR NOT (FIX OF OUTFILE-NAME(Laenge OF OUTFILE-NAME:1) = SPACE OR LOW-VALUE)
         CONTINUE
       END-PERFORM
[/code]

The Compiler brings the following error message:

[b]JMN3385I-S[/b] FUNCTION LENGTH IN PERFORM STATEMENT
            MUST BE NUMERIC LITERAL OR NUMERIC ITEM.

The workaround is the line marked as a comment, with "Laenge" being
preassigned with FUNCTION LENGTH

Now, who is wrong, me or the compiler?

The compiler claims to be a full implementation of the 1985 standard.

MfG,
L. Willms



Relevant Pages

  • Re: If you were inventing CoBOL...
    ... > My current compiler doesn't handle multiple REPLACING clauses. ... Sounds like your compiler implemented Level 1. ... of one of the reasons the '02 standard has no modules and no levels within ... LEADING and TRAILING are new in '02. ...
    (comp.lang.cobol)
  • Re: Performance RPG Figurative Constants versus Literals
    ... I would suspect that the compiler would store *blanks as a single byte ... When doing performance tests, you have to make sure that your loop runs ...
    (comp.sys.ibm.as400.misc)
  • Defning SIZE_MAX
    ... The part I do not understand is the the meaning of subtracting 1 ... How does the compiler ... Because it fouls the order in which people normally read text. ... Why is top-posting such a bad thing? ...
    (comp.lang.c)
  • Re: Pi.
    ... can be elided for the convenience of the compiler as opposed to its ... How do you know the blanks are ... Richard ...
    (comp.lang.fortran)
  • Re: appending to a string
    ... >> hard for an optimizing compiler to do that. ... > Also, at one stage, I had to put a trim in a string comparison, ... > blanks correctly. ...
    (comp.lang.fortran)