View previous topic :: View next topic
|
Author |
Message |
maxsubrat
Active User
Joined: 27 Feb 2008 Posts: 110 Location: india
|
|
|
|
I have a a requirement of a lenghth check..
FIELDA = X(800)
FIELDA has data varying 3 to 10.
IF FIELDA is less and equal to X(10)
perform para-100
else
perform para-200
end-if.
How to meet the above requirement.Thanks for any suggestion.
Thanks |
|
Back to top |
|
|
Nic Clouston
Global Moderator
Joined: 10 May 2007 Posts: 2455 Location: Hampshire, UK
|
|
|
|
jeesh! And with your daily reading of the forum nothing came to mind as to previous topis on this subject? |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
I suspect that different people will have different understandings of what you have asked.
Personally, i do not understand at all. How can FIELDA be compared to X(10)?
Maybe if you show some samples of the "input" and the result of the IF statement for each of the input samples it will help clarify. |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
I'm not sure what you actually want either.
Code: |
01 a-nice-name-which-describes-the-field pic x(10).
MOVE FIELDA TO a-nice-name-which-describes-the-field
IF FIELDA EQUAL TO a-nice-name-which-describes-the-field
perform para-100
ELSE
perform para-200
END-IF |
This assumes trailing spaces in your FIELDA. |
|
Back to top |
|
|
Pandora-Box
Global Moderator
Joined: 07 Sep 2006 Posts: 1592 Location: Andromeda Galaxy
|
|
|
|
Assuming that I understood your requirement
maxsubrat wrote: |
FIELDA has data varying 3 to 10.
|
Do you mean the actual data of 3 to 10 bytes apart from spaces ,low-values ??
Code: |
If FIELDA(11:790) NOT = SPACES OR LOW-VALUES
perform para-100
Else
perform para-200
End-if |
|
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
COBOL does not have strings in the same way other languages have strings (variables whose length changes at run time). FIELDA, if you defined it as PIC X(800) in WORKING-STORAGE, has a length of 800. It will have a length of 800 no matter what the data is in the variable. A variable in WORKING-STORAGE is fixed length -- even variables with OCCURS DEPENDING ON have the maximum possible amount of storage reserved for them, no matter how many occurrences exist at any given time.
If a variable is defined in LINKAGE SECTION, with OCCURS DEPENDING ON, then the length can vary at run time -- but the memory for the variables is not local to the executing program.
Variables in an 01 in the FILE SECTION can also use OCCURS DEPENDING ON to have varying length, but in this case the length is based upon what the file record contains.
As others have said, perhaps if you explain what you need to accomplish, rather than how you're trying to do it, we can provide more assistance. |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
Pandora-Box wrote: |
Assuming that I understood your requirement
maxsubrat wrote: |
FIELDA has data varying 3 to 10.
|
Do you mean the actual data of 3 to 10 bytes apart from spaces ,low-values ??
Code: |
If FIELDA(11:790) NOT = SPACES OR LOW-VALUES
perform para-100
Else
perform para-200
End-if |
|
Code: |
01 FIELDA.
05 FILLER PIC X(10).
05 FILLER PIC X(790).
88 FIELDA-TRAILING-VALUE-ONLY VALUE SPACE.
If FIELDA-TRAILING-VALUE-ONLY
perform para-100
Else
perform para-200
End-if |
Your solution, Pandora-box, just not encouraging the reference-modification. |
|
Back to top |
|
|
Pandora-Box
Global Moderator
Joined: 07 Sep 2006 Posts: 1592 Location: Andromeda Galaxy
|
|
|
|
Thanks Bill :-)
I get that :-) |
|
Back to top |
|
|
|