Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

To assign initial value of hyphen to a variable

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
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    Post subject: To assign initial value of hyphen to a variable
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    Post subject:
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    Post subject:
Reply with quote

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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7228

PostPosted: Wed Jul 06, 2011 7:41 pm    Post subject:
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: 2502
Location: Atlanta, Georgia, USA

PostPosted: Wed Jul 06, 2011 8:12 pm    Post subject: Reply to: To assign initial value of hiphen to a variable of
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7228

PostPosted: Wed Jul 06, 2011 8:28 pm    Post subject:
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: 2502
Location: Atlanta, Georgia, USA

PostPosted: Wed Jul 06, 2011 8:42 pm    Post subject: Reply to: To assign initial value of hiphen to a variable of
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

Active Member


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

PostPosted: Wed Jul 06, 2011 8:54 pm    Post subject:
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

Site Director


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

PostPosted: Wed Jul 06, 2011 9:57 pm    Post subject: Reply to: To assign initial value of hiphen to a variable of
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

Active Member


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

PostPosted: Wed Jul 06, 2011 10:32 pm    Post subject:
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: 7912
Location: Bellevue, IA

PostPosted: Wed Jul 06, 2011 10:36 pm    Post subject:
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: 2502
Location: Atlanta, Georgia, USA

PostPosted: Wed Jul 06, 2011 10:56 pm    Post subject:
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7228

PostPosted: Thu Jul 07, 2011 4:27 am    Post subject: Reply to: To assign initial value of hiphen to a variable of
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    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Format to pipe delimited with variabl... pshongal SYNCSORT 6 Wed Sep 14, 2016 2:48 pm
No new posts Variable for cursor names ravikumar15 DB2 5 Sun Jul 17, 2016 7:08 am
No new posts OPC JCL Variable passion_sujesh IBM Tools 5 Fri Jul 01, 2016 4:21 am
No new posts JOINKEYs and Variable files migusd SYNCSORT 8 Fri Jun 17, 2016 3:16 am
No new posts File Manager with Variable Length File ahabib IBM Tools 10 Thu Mar 31, 2016 11:00 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us