View previous topic :: View next topic
|
Author |
Message |
luis_pr
New User
Joined: 13 Oct 2007 Posts: 19 Location: Fort Worth, Tx USA
|
|
|
|
What is wrong with this?
The error message is:
"INPUT-INDEX (INDEX NAME)" WAS NOT NUMERIC, BUT WAS A SENDER IN AN ARITHMETIC EXPRESSION. THE STATEMENT WAS DISCARDED."
The variables are:
Code: |
01 INPUT-RECORD.
05 INPUT-CHAR OCCURS 80 TIMES
INDEXED BY INPUT-INDEX
PIC X(01).
01 FILLER REDEFINES INPUT-RECORD
PIC X(01).
88 INPUT-RECORD-IS-A-COMMENT VALUE '*'. |
The statement where the error occurs is:
Code: |
SEARCH INPUT-CHAR
AT END MOVE LIT-1 TO LIT-1
WHEN INPUT-CHAR (INPUT-INDEX) = 'A'
AND INPUT-CHAR (INPUT-INDEX + 1) = 'P'
AND INPUT-CHAR (INPUT-INDEX+2) = 'P'
AND INPUT-CHAR (INPUT-INDEX+3) = 'L'
AND INPUT-CHAR (INPUT-INDEX+4) = 'C'
AND INPUT-CHAR (INPUT-INDEX+5) = 'T'
AND INPUT-CHAR (INPUT-INDEX+6) = 'N'
AND INPUT-CHAR (INPUT-INDEX+7) = ' '
AND INPUT-INDEX + 7 < 72
PERFORM ..... etc etc etc |
The error points to here:
WHEN INPUT-CHAR (INPUT-INDEX) = 'A'
I do not see "it"??? |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
Suggest you learn how to use the "Code" tag - this will preserve alignment and improve readability. Your post has been "Code'd".
Change this:
Code: |
01 INPUT-RECORD.
05 INPUT-CHAR OCCURS 80 TIMES
INDEXED BY INPUT-INDEX
PIC X(01). |
to this:
Code: |
01 INPUT-RECORD.
05 INPUT-CHAR OCCURS 80 TIMES
INDEXED BY INPUT-INDEX.
10 MYCHAR PIC X(01). |
|
|
Back to top |
|
|
luis_pr
New User
Joined: 13 Oct 2007 Posts: 19 Location: Fort Worth, Tx USA
|
|
|
|
Thanks for the info, dick scherrer. By the way, the source code changes that you mention... from the "change this" section to the "to this" section.... were they meant to suggest that they would correct my problem? It did not look to me as if they would but I tried and still had same the error. |
|
Back to top |
|
|
Craq Giegerich
Senior Member
Joined: 19 May 2007 Posts: 1512 Location: Virginia, USA
|
|
|
|
luis_pr wrote: |
What is wrong with this?
AND INPUT-INDEX + 7 < 72
|
INPUT-INDEX is an index and you can not add to it, you could use
Code: |
and input-index < 65 |
for the same results. |
|
Back to top |
|
|
luis_pr
New User
Joined: 13 Oct 2007 Posts: 19 Location: Fort Worth, Tx USA
|
|
|
|
OMG, Craq Giegerich. Yes, that was it but for some reason the compiler generated the error message against all the lines in the WHEN Statement instead of just against that one condition. Ooooh, weeeeell. Thanks and Happy Thanksgiving everyone! |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
I knew i should have waited until i could actually test this before posting
This much compiles clean (using your original code).
Code: |
SEARCH INPUT-CHAR
AT END DISPLAY 'END'
WHEN INPUT-CHAR (INPUT-INDEX) = 'A'
AND INPUT-CHAR (INPUT-INDEX + 1) = 'P'
DISPLAY 'A'. |
This generates the error:
Code: |
SEARCH INPUT-CHAR
AT END DISPLAY 'END'
WHEN INPUT-CHAR (INPUT-INDEX) = 'A'
AND INPUT-CHAR (INPUT-INDEX + 1) = 'P'
AND INPUT-INDEX + 7 < 72
DISPLAY 'AP'. |
34 IGYPA3074-S "INPUT-INDEX (INDEX NAME)" was not numeric, etc...
Which makes sense now that i look at it closer. . . The expression can be used as the index, but not as it is used in this statement. |
|
Back to top |
|
|
Bill O'Boyle
CICS Moderator
Joined: 14 Jan 2008 Posts: 2501 Location: Atlanta, Georgia, USA
|
|
|
|
Alternative to hard-coded max test, providing that INPUT-INDEX must be less than the maximum-array occurs, minus 15 -
Code: |
03 WS-MAX-SUB PIC 9(08) COMP.
03 WS=FWORD PIC 9(08) COMP.
03 WS-MAX-INDEX INDEX.
DIVIDE LENGTH OF INPUT-RECORD BY LENGTH OF INPUT-CHAR (1) GIVING WS-MAX-SUB.
SUBTRACT 15 FROM WS-MAX-SUB GIVING WS-FWORD.
SET INPUT-INDEX TO WS-FWORD.
SET WS-MAX-INDEX TO INPUT-INDEX.
SET INPUT-INDEX TO 1.
|
Then, substitute -
Code: |
and input-index < 65
|
with -
Code: |
and input-index < ws-max-index
|
Bill |
|
Back to top |
|
|
|