Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Diff between HIGH-VALUES and SPACES

Status
Not open for further replies.

sriganti

Programmer
Dec 17, 2002
2
0
0
CA
Hi,
What exactly the diff between HIGH-VALUES and SPACES?
When should I use HIGH-VALUES and When I should use SPACES?
Please ...

Thanks
 
Hi sriganti,

The ASCII ( decimal value of SPACE is 32.
The decimal value of HIGH-VALUES is usually 255 (the highest value that can fit in one byte).

SPACE is handy when you want to initialize a string (PIC X) to 'nothing'. Of course, value 'space' could be a valid value in given cases. By the way, LOW-VALUES (ASCII decimal value 0) is commonly used to initialize numeric fields to 'nothing'.

If you use the COBOL verb INITIALIZE on a group level, spaces will be moved to alphanumeric fields and LOW-VALUES (binary zeroes) will be moved to numeric fields.

HIGH-VALUES is handy when you want to initialize a field to the highest possible value - for comparisons with other fields, for example.

Dimandja
 
Hi sriganti,

If you happen to be on a mainframe, the hex value of spaces is 40 and HIGH-VALUES is FF

Marc
 
A bit of trivia for the newbei COBOL mainframers out there:

There's another way to set a field to X'FF', in this case a COMP field. You'll see this done in CICS to tell BMS where to position the cursor on the screen.

You move -1 to the length field associated with the data field you desire to have the cursor positioned to. The length field is defined as PIC S9(04) COMP in the symbolic map.

DB2 uses the same approach to mark a DB2 column as null by moving -1 to the column's null indicator field.

If reference modification was available then, I think they might have opted for it instead of the move -1 technique.

In both cases the move of the -1 to the field changes the field to all X'FF' as a result of the 2s-comlement arithmetic used to populate the field.

For completeness I guess I should also mention the "move all X'FF'" approach.

Jack
 
I'm trying to find out the last day in any given month using cobol. Does anyone know how to do this?
Thanks
 
Hi Hugh,

One way is to create a table of days, e.g.:
Code:
01 days-tbl value
   312831303130313130313031. *==> I think you can do this if not use redefines.
   05  day-entry  pic  9(002)
       occurs 12.
01 month-nbr      pic  9(002).  *==> this is the subscript
In your procedure division, isolate the month of the date you're using and verify that it is numeric and between 1 and 12 inclusive.

Then determine if the year is a leap year. If it is add 1 to the Feb value in the table. (Hint- use the month# of Feb as a subscript).

Now, use the month# of your date as a subscript in the MOVE stmt that will move the # of days from the table to your receiving field.

 
hugheskbh & slade,

Aren't you posting to the wrong thread?
 
So you found us. Sometimes you can run, but you can't hide. :)

Regards, Jack.
 
Not only are they posting in the wrong thread, but Hugh has already asked this question and received pretty comprehensive answers in thread209-421402.

How odd.

Marc
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top