Page 1 of 1

Usage of "HIGH VALUES" in COBOL.

Posted: Thu Sep 24, 2015 10:10 pm
by Pragya
Hi,

What is the use of "HIGH VALUES" in COBOL? For this I replied, "Moving High-values will move all 1's in the variable." But I think I did not reply it well. What should I have answered.

Re: Usage of "HIGH VALUES" in COBOL.

Posted: Thu Sep 24, 2015 10:27 pm
by Pragya
I also said that when we are doing the file comparison, moving high values help.

Re: Usage of "HIGH VALUES" in COBOL.

Posted: Thu Sep 24, 2015 11:42 pm
by mickeydusaor
high values hex 'FFFFFFFF' or Moving a -1 will give you high values.

Re: Usage of "HIGH VALUES" in COBOL.

Posted: Fri Sep 25, 2015 2:22 pm
by William Collins
High-values is the highest value in the "collating sequence" in your COBOL program. No value is higher.

The default value for HIGH-VALUES is X'FF'. HIGH-VALUES is a figurative-constant, When you MOVE HIGH-VALUES TO somwhere, all receiving positions of somewhere will be filled with X'FF'. Note, there is no difference between HIGH-VALUE and HIGH-VALUES.

For any type of matched-key processing, high-values can be useful, since nothing can be higher. It can also be useful for "trailer" records, as binary-ones are the highest in the collating sequence.

If you want a non-default value for high-values, take some time with the manuals and see if you can work it out.

Re: Usage of "HIGH VALUES" in COBOL.

Posted: Wed Sep 30, 2015 2:56 pm
by Pragya
Thanks William for the great explnation.

What is "collating sequence"?

Re: Usage of "HIGH VALUES" in COBOL.

Posted: Wed Sep 30, 2015 3:07 pm
by enrico-sorichetti
What is "collating sequence"?
a sequence according to some rules

for Mainframes ( EBCDIC) the numbers come after the letters
for norma PC ( ASCII ) the letters come after the numbers

Re: Usage of "HIGH VALUES" in COBOL.

Posted: Wed Sep 30, 2015 6:21 pm
by William Collins
Collating sequence starts from the lowest value, and continues, in sequence, by each subsequent higher value.

ABCDEFG

A is lowest, B is greater than A, C is greater than B (so also greater than A), D is greater than C (so also greater than B and A) etc.

Without a collating sequence, you can do no "greater than" or "less than" comparisons.

The collating sequence also determines in what order data will be sorted.

At the basic level data "collates" from X'00' thru X'FF, in sequence.

In EBCDIC, all "displayable" characters have a hexadecimal value. This is also true in ASCII, but, the hexadecimal values of, for instance, the alphabet and the numbers is different between the two character sets, so the collating sequence is different (in EBCDIC, letters collate lower than numbers, in ASCII the reverse).

At the basic level, in COBOL LOW-VALUES is the lowest hexadecimal value in the collating sequence, and HIGH-VALUES is the highest, and that is X'00' and X'FF' respectively.

However, in a COBOL program (and elsewhere outside COBOL) you can use a different collating sequence for a specific purpose. In a COBOL program running on a Mainframe you could process ASCII data using an ASCII collating sequence, or some custom collating sequence where LOW-VALUES and HIGH-VALUES still contain the lowest and highest in the sequence, but do not contain X'00' and X'FF'.

It is very rare that you would need to do this "for real", but you could do some little tests anyway. Have a look at the ALPHABET clause of the SPECIAL-NAMES paragraph (part of the CONFIGURATION SECTION in the EVIRONMENT DIVISION) and how it would be used in tests, and how you could use it to specify a COLLATING SEQUENCE for a SORT or MERGE statement in COBOL.

Re: Usage of "HIGH VALUES" in COBOL.

Posted: Wed Sep 30, 2015 6:23 pm
by Robert Sample
Moving High-values will move all 1's in the variable
This is not really an answer -- if the variable is defined as PIC X or PIC 9 USAGE DISPLAY, moving all 1's results in each byte having X'F1' whereas moving HIGH-VALUES results in each byte having X'FF' in it.