IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

To assign initial value of hyphen to a variable


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
kunal jain

New User


Joined: 19 May 2011
Posts: 59
Location: India

PostPosted: Wed Jul 06, 2011 5:18 pm
Reply with quote

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
View user's profile Send private message
Craq Giegerich

Senior Member


Joined: 19 May 2007
Posts: 1512
Location: Virginia, USA

PostPosted: Wed Jul 06, 2011 5:24 pm
Reply with quote

What about reading the manual.


pic x(108) value all '-'.
Back to top
View user's profile Send private message
kunal jain

New User


Joined: 19 May 2011
Posts: 59
Location: India

PostPosted: Wed Jul 06, 2011 5:25 pm
Reply with quote

Thank you ...Your help is really appreciated.
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Wed Jul 06, 2011 7:41 pm
Reply with quote

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
View user's profile Send private message
Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2501
Location: Atlanta, Georgia, USA

PostPosted: Wed Jul 06, 2011 8:12 pm
Reply with quote

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
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Wed Jul 06, 2011 8:28 pm
Reply with quote

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
View user's profile Send private message
Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2501
Location: Atlanta, Georgia, USA

PostPosted: Wed Jul 06, 2011 8:42 pm
Reply with quote

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. icon_wink.gif

Regards,

Bill
Back to top
View user's profile Send private message
Phrzby Phil

Senior Member


Joined: 31 Oct 2006
Posts: 1042
Location: Richmond, Virginia

PostPosted: Wed Jul 06, 2011 8:54 pm
Reply with quote

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
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Wed Jul 06, 2011 9:57 pm
Reply with quote

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. . . icon_smile.gif

d
Back to top
View user's profile Send private message
Phrzby Phil

Senior Member


Joined: 31 Oct 2006
Posts: 1042
Location: Richmond, Virginia

PostPosted: Wed Jul 06, 2011 10:32 pm
Reply with quote

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
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8696
Location: Dubuque, Iowa, USA

PostPosted: Wed Jul 06, 2011 10:36 pm
Reply with quote

I saw a CICS program, once upon a time, that started
Code:
PROCEDURE DIVISION .
START-PARA.
    MOVE EIBCALEN TO EIBCALEN.
Back to top
View user's profile Send private message
Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2501
Location: Atlanta, Georgia, USA

PostPosted: Wed Jul 06, 2011 10:56 pm
Reply with quote

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
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Thu Jul 07, 2011 4:27 am
Reply with quote

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
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts Variable Output file name DFSORT/ICETOOL 8
No new posts Moving Or setting POINTER to another ... COBOL Programming 2
No new posts parsing variable length/position data... DFSORT/ICETOOL 5
No new posts Masking variable size field - min 10 ... DFSORT/ICETOOL 4
Search our Forums:

Back to Top