View previous topic :: View next topic
|
Author |
Message |
Vidya Kajale
New User
Joined: 01 Jun 2010 Posts: 43 Location: India
|
|
|
|
can we have more then one value assign to a variable at level 01, 05 ,77 tct other than 88.
EX: 01 WS-report-1
05 ws-report-1A PIC X value 'A' , 'B' , 'c'
o5 WS-REPOrt-1B PIC X value 'X' , 'V'
Please suggest me suitable code. And how that variable will take diiferent values to write into the file. |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
No. Not at the same time, anyway.
What are you trying to do? Will OCCURS do what you want? |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
1. you can not have multiple value clauses for a variable.
2. use multiple level-88's and set them to true when appropriate. |
|
Back to top |
|
|
Marso
REXX Moderator
Joined: 13 Mar 2006 Posts: 1353 Location: Israel
|
|
|
|
Vidya Kajale wrote: |
can we have more then one value assign to a variable at level 01, 05 ,77 ect other than 88.
EX: 01 WS-report-1
05 ws-report-1A PIC X value 'A' , 'B' , 'c'
05 WS-REPOrt-1B PIC X value 'X' , 'V'
|
This would mean that a single byte has 2 different values simultaneously.
It is not yet possible.
Note: 88 level assigns a value when used in a SET statement, not when declared. |
|
Back to top |
|
|
Phrzby Phil
Senior Member
Joined: 31 Oct 2006 Posts: 1042 Location: Richmond, Virginia
|
|
|
|
Nice one Marso - not
possible.
A very optimistic approach. Awaiting Quantum COBOL. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Truly a variable. |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
And no, you can't use an 88 with multiple values, SET it, and get multiple values in the field associated with the 88.
We still have no idea what the TS wanted to do. You could use the "bits" to indicate the presence/absence of up to eight distinct values in one byte, but no application comes to mind which can't be dealt with in a more obvious way.
Or, maybe for ultra-performance, a cool "GO TO DEPENDING ON"? You work out the answer to the IF/EVALUATE before the data arrives in the program. Put it in a half-, or full-word, whichever the compiler is more comfortable with. Only attempt this under supervision by qualified personnel (who may, or may not, have anything to do with IT). |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
Quote: |
can we have more then one value assign to a variable at level 01, 05 ,77 |
As has been posted, this cannot be done.
If it was possible, how would you use it?
If you explain what you want to accomplish, someone may have a suggestion. |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
Quote: |
Or, maybe for ultra-performance, a cool "GO TO DEPENDING ON"? You work out the answer to the IF/EVALUATE before the data arrives in the program. Put it in a half-, or full-word, whichever the compiler is more comfortable with. Only attempt this under supervision by qualified personnel (who may, or may not, have anything to do with IT). |
Bill, this is WAY too close to the ALTER statement COBOL used to allow. Great. Now I'll have nightmares the rest of the week from when I had to support a program that used ALTER. |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
Sorry Robert, no evil intent on my part :-)
You mean
Code: |
ALTER AN-INNOCENT-PARAGRAPH-NAME TO PROCEED TO DISAPPEAR-UP-ITS-OWN...
|
That one?
I never knew how ALTER got all the bad press and GO TO DEPENDING ON escaped almost unscathed either. |
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10872 Location: italy
|
|
|
|
Quote: |
Awaiting Quantum COBOL. |
With or Without the Heinsenberg parser
|
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
ALTER was the Schrodiinger's Cat of COBOL -- you never knew for sure if the GO TO you were looking at was the one that got executed, unless you tracked through the code (opened the box?). |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
Minimum flames please . . .
ALTER did make for a very handy "fitst-time" switch. . .
The first COBOL-only shop i worked for had it in their standards that the only time ALTER could be used was as a first time thru indicator. Keep in mind that when the rule was changed that all new code would be COBOL, it was the people most experienced in assembler that saw no problem with the ALTER for handling "first time". This was basically how they handled first-time in their assembler code - have a no-op before the first time code and turn it into an unconditional branch around the first time code so there would be no checking - just a cheap branch.
d |
|
Back to top |
|
|
Phrzby Phil
Senior Member
Joined: 31 Oct 2006 Posts: 1042 Location: Richmond, Virginia
|
|
|
|
Heisenberg is out for a drive and a cop pulls him over.
"Sir, do you know how fast you were going?" "No," replies Heisenberg, "but I know where I am." |
|
Back to top |
|
|
don.leahy
Active Member
Joined: 06 Jul 2010 Posts: 765 Location: Whitby, ON, Canada
|
|
|
|
Once upon a time it was common to use the Cobol statement "ON 1" as a first time switch. Very handy because you didn't have to remember to turn it on or off. |
|
Back to top |
|
|
Kjeld
Active User
Joined: 15 Dec 2009 Posts: 365 Location: Denmark
|
|
|
|
Bill Woodger wrote: |
And no, you can't use an 88 with multiple values, SET it, and get multiple values in the field associated with the 88.
We still have no idea what the TS wanted to do. You could use the "bits" to indicate the presence/absence of up to eight distinct values in one byte, but no application comes to mind which can't be dealt with in a more obvious way.
|
I would like to point out that you can use a format
or
Code: |
VALUE 'B' THROUGH 'K' |
for conditional variables (88 level), so whenever the conditional variable is set to a value that is inside the collating sequence between the 2 end literals, the condition is evaluated true. |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
not to forget, when SETting the CONDITION-CODE TO TRUE
only the first value listed in the VALUE clause is used.
(don't want to confuse anyone...) |
|
Back to top |
|
|
Kjeld
Active User
Joined: 15 Dec 2009 Posts: 365 Location: Denmark
|
|
|
|
The construct with multiple values should in my opinion only be used for checking external values to match a specific condition. For explicitely setting conditions on and off (true/false), use a single literal as condition value. |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
I think I introduced the confusion when pre-empting the question of "what about multiple values on an 88 when I do SET, does that get me multiple values in my data-name".
The answer is still no, that doesn't happen. A fuller answer, as dbz points out, is that only the first value that has been typed for the 88 is placed in the data-name when (if) you do a SET for that data-name. Only one value is needed for the condition to be true, plus, as we head back to the start of the topic, only one value can be held in one byte at any one time.
Code: |
88 A VALUE 7.
88 B VALUE 7 THRU 9
88 C VALUE 7, 1, 3, 9.
88 D VALUE 7, 1 THRU 4, ZERO, 8. |
SET/DISPLAY for each of these would display 7, and the condition would be true. By the time you've SET them all, they'd all be true, the value of the data-name would be 7, but only because of the last SET, the others would only be true by co-incidence.
Of the about, I'm with Kjeld, I'd only really want to use A (and I'd give it a meaningful name, of course). But, if you come across an 88 with multiple values, that is SET, this is what happens. |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
well, since it is friday and we all seem to have time on our hands,
SETting a CONDITION-NAME TO TRUE
is the same as
MOVE <first value of VALUE Clause> TO <owning data description entry>
IF CONDITION-NAME IS TRUE
is the same as
IF <owning data description entry> = <one of the values of the VALUE Clause of the CONDITION-NAME>
what level-88's accomplish is to remove the need for idiots to fill the PROCEDDURE DIVISION with literals. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
And to have everyone else maintain them forever. . .
d |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
Also, out of 3 places coded with literals in procedure, only two of them with all the same literals... |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
ON 1
AND EVERY 20
UNTIL 10000
Used to be part of our test data extract from the Agency Master File. Plus the first-time for all our called modules. This might look similar to a PERFORM loop, but there is no looping involved, just a serial counting process as the CPU flies through the program.
An interesting thing, if you used ON more than once in a program it would keep a seperate count for each statement.
Like Don says, nothing to define, nothing to set, nothing to remember - except the full-stop/period. You think something is simple to use, and then someone shows you how to mess it up. |
|
Back to top |
|
|
|