Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
Variable declaration

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> PL/I & Assembler
View previous topic :: :: View next topic  
Author Message
Mind

New User


Joined: 04 Nov 2010
Posts: 9
Location: bangalore

PostPosted: Thu May 19, 2011 5:45 pm    Post subject: Variable declaration
Reply with quote

Hello Everyone,
I am a beginner in PL/I,
A variable is declared as char(80), in the program many operations are performed on that variable like substring and etc.
My question here is how can i right justify with ZEROES if at all the variable is less than 80 length. Every time any operation is performed on that variable, it should be right justified with ZEROES.

Please advice and let me know if the information is not sufficient.

Thanks in advance.
Back to top
View user's profile Send private message

Garry Carroll

Active Member


Joined: 08 May 2006
Posts: 998
Location: Dublin, Ireland / Edinburgh, Scotland

PostPosted: Thu May 19, 2011 7:44 pm    Post subject:
Reply with quote

The variable is declared with a fixed length of 80, so it can NEVER be less than or greater thasn 80 in length.

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

Active Member


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

PostPosted: Thu May 19, 2011 8:13 pm    Post subject:
Reply with quote

I think you mean the actual (non-blank) content is < 80 chars - is this correct?

Justify which way - right or left?

Sub-stringing a value from the var will not modify it at all (in any language), so that part of your query is odd.

Sub-stringing a value into the var will affect just those positions, right? So that cannot affect justification or the fill character either.

Given my comments, please reformulate your question with no extraneous information.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6968
Location: porcelain throne

PostPosted: Thu May 19, 2011 8:13 pm    Post subject:
Reply with quote

don't know anything about PL/1,
but normally,
in a char field, everything is left-justified,
numeric field, everything is right-justified.

in COBOL, if i really wanted all zeroes in the 80 char, i would stipulate that in the VALUE clause.

If I wanted only a certain number of zeroes,
i would subdivide the 80 chars into two parts,
the first populated with spaces,
the second with zeros.

I have to ask though,
why do you want zeroes (how many) in the ass-end of an 80 char field?
Back to top
View user's profile Send private message
Garry Carroll

Active Member


Joined: 08 May 2006
Posts: 998
Location: Dublin, Ireland / Edinburgh, Scotland

PostPosted: Thu May 19, 2011 8:22 pm    Post subject:
Reply with quote

Quote:
why do you want zeroes (how many) in the ass-end of an 80 char field?

Dick,

S/he wants to right-justify, so that'd put the non-zeroes in the ass-end, surely?

Garry.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6968
Location: porcelain throne

PostPosted: Thu May 19, 2011 8:45 pm    Post subject:
Reply with quote

sort of like the south-end of a north-bound cow?
Back to top
View user's profile Send private message
Akatsukami

Global Moderator


Joined: 03 Oct 2009
Posts: 1777
Location: Bloomington, IL

PostPosted: Thu May 19, 2011 8:45 pm    Post subject:
Reply with quote

As indicated by Messrs. Brenholz, Carroll, and Phrzby, this is a damned strange requirement. Assuming that you actually mean what you're saying, however, this should provide you with an example:
Code:
 foo20:  proc options (main);                             
                                                           
 dcl (var1, var2) char (80);                               
 dcl (var1_5)     char (80) var;                           
                                                           
 var1   = '123456789';                                     
 var1_5 = trim(var1);                                     
                                                           
 if (length(var1_5)=80)                                   
   then var2 = var1_5;                                     
   else var2 = repeat('0',(80-length(var1_5))-1) || var1_5;
                                                           
 put skip edit ('Var2 = [', var2, ']') (a, a, a);         
                                                           
 end foo20;                                               
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7315

PostPosted: Thu May 19, 2011 8:55 pm    Post subject: Re: Variable declaration
Reply with quote

Mind wrote:
Hello Everyone,
I am a beginner in PL/I,
A variable is declared as char(80), in the program many operations are performed on that variable like substring and etc.
My question here is how can i right justify with ZEROES if at all the variable is less than 80 length. Every time any operation is performed on that variable, it should be right justified with ZEROES.

Please advice and let me know if the information is not sufficient.

Thanks in advance.


I'm not PL/I either. But, do you want a right-justified field, left-filled with zeros, or a left-justified field, right-filled with zeros.

AAAAAA000000
or
000000AAAAAA

I guess the normal contents of the field, after a "move", would be data left-jutified and space-filled to the right. If that is the way PL/I is operating and you need zeros, translate (in whatever way there is) the spaces to zeros.

Note, if your "string" has trailing spaces, those will translate as well.

Or, as Dick said and if you are only placing data in the left of the field (with a length, so the compiler will not do the space filling) set the whole thing to zero first. This would preserve trailing spaces in your string.

However, until you are clearer about what you want, we won't get much closer to how to do it.
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 -> PL/I & Assembler All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Moving values to a variable of copybo... Vignesh Sid COBOL Programming 6 Wed Sep 06, 2017 1:04 pm
No new posts Updating the Trailer count in variabl... satheshbabur DFSORT/ICETOOL 6 Wed Aug 30, 2017 9:49 pm
No new posts Move from Comp3 variable to Edited Va... sreekusr COBOL Programming 8 Thu Aug 10, 2017 4:20 pm
No new posts Can I traverse a STEM variable? chong.zhou CLIST & REXX 5 Wed May 31, 2017 3:54 pm
No new posts Converting Variable block file to Fix... bhavana yalavarthi DFSORT/ICETOOL 10 Tue May 16, 2017 2:20 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us