View previous topic :: View next topic
|
Author |
Message |
kunal jain
New User
Joined: 19 May 2011 Posts: 59 Location: India
|
|
|
|
I need to assign a initial value of 108 times '-' to a variable.
I dont want to hardcode '-' 108 times.
Do we have an alternative of doing so .Please suggest.
For eg; 01 ws-temp picx(108) value '---------108 times'
I dont want to hardcode '-' 108 times since i have many such fields of different length in my code.
Do we have any other possible way of doing so. |
|
Back to top |
|
|
Craq Giegerich
Senior Member
Joined: 19 May 2007 Posts: 1512 Location: Virginia, USA
|
|
|
|
What about reading the manual.
pic x(108) value all '-'. |
|
Back to top |
|
|
kunal jain
New User
Joined: 19 May 2011 Posts: 59 Location: India
|
|
|
|
Thank you ...Your help is really appreciated. |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
Craq has the optimal solution for the problem as defined, but goodness, how many ways are there to do this? Literally lots (sic), I'd say.
pic x occurs 108 value '-'. In the procedure, MOVE ALL '-' (I don't like) INITIALISE (not so keen), INSPECT, good-old loop, offset MOVE (my probable preference for somehting more complicated than this).
If I had to type them all, I'd make it known to be longer to start with, then compile, remove one, compile, remove one, until I didn't get a compiler message about the value being too long.... |
|
Back to top |
|
|
Bill O'Boyle
CICS Moderator
Joined: 14 Jan 2008 Posts: 2501 Location: Atlanta, Georgia, USA
|
|
|
|
On the flip-side of this, figurative constants, such as LOW-VALUE(s), SPACE(s), ZERO(s) and HIGH-VALUE(s), don't not require an ALL, but you can include the ALL optionally.
So, you could say - MOVE SPACE, MOVE SPACES, MOVE ALL SPACE or MOVE ALL SPACES TO WS-TEMP and this is one in the same.
Note; If you specified MOVE '0' (which represents one ZERO), byte one of WS-TEMP would be set to '0' and the remaining bytes would be set to SPACES.
Using the figurative constants supplied with COBOL and you won't go wrong.
HTH....
Bill |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
For some reason, I never liked the plurals for SPACE and ZERO, since they didn't do anything different. For LOW-, HIGH-, always the plural, even if only one byte. Funny old world. |
|
Back to top |
|
|
Bill O'Boyle
CICS Moderator
Joined: 14 Jan 2008 Posts: 2501 Location: Atlanta, Georgia, USA
|
|
|
|
Bill,
I think you'd be surprised as to how some folks think that a MOVE using a singular or plural figurative constant are not the same or include ALL to add to the confusion.
Regards,
Bill |
|
Back to top |
|
|
Phrzby Phil
Senior Member
Joined: 31 Oct 2006 Posts: 1042 Location: Richmond, Virginia
|
|
|
|
Thankfully I haven't seen this for a while, but I used to be surprised at people who felt the need to zeroize a variable before moving or calculating a value into it. That drove me crazy. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Quote: |
but I used to be surprised at people who felt the need to zeroize a variable before moving or calculating a value into it. That drove me crazy. |
Long ago, i worked with several people who completely believed that if they calculated a value into a variable and it was not initialized, they could/would get an 0c7. . .
And these were supposed to be some of the senior people. . . Mercy. . . Took quite a few iterations to 'splain how this could not be. . .
d |
|
Back to top |
|
|
Phrzby Phil
Senior Member
Joined: 31 Oct 2006 Posts: 1042 Location: Richmond, Virginia
|
|
|
|
Dick -
I think you have misused " 'splain. "
You might explain it to them, but they have some 'splainin' to do to say why they think that way. |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
I saw a CICS program, once upon a time, that started
Code: |
PROCEDURE DIVISION .
START-PARA.
MOVE EIBCALEN TO EIBCALEN. |
|
|
Back to top |
|
|
Bill O'Boyle
CICS Moderator
Joined: 14 Jan 2008 Posts: 2501 Location: Atlanta, Georgia, USA
|
|
|
|
Robert Sample wrote: |
I saw a CICS program, once upon a time, that started
Code: |
PROCEDURE DIVISION .
START-PARA.
MOVE EIBCALEN TO EIBCALEN. |
|
When Storage Protection (STGPROT=YES) is turned on in the SIT, it invites an ensuing S0C4 when updating any EIB field.
Bill |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
I've seen people desperate to initialise before move. Drives me nuts. Come across it in a program and it looks like there must be something missing.
Never seen it this way, before. |
|
Back to top |
|
|
|