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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

HIGH-VALUES and LOW-VALUES in COBOL

Status
Not open for further replies.

adwarak

Programmer
Apr 29, 2003
11
0
0
US
Just wanted why we need to use HIGH-VALUES and LOW-VALUES in cobol programs.
All I know about these literals is NOTHING is greater than HIGH-VALUES and NOTHING is lesser than LOW-VALUES.

 
In a sense your question contains the answer. If you were sorting a table in core and wanted it to be in ascending order you could first initialize it to high values. If you did not fill the table, the remaining entries would sort to the bottom, whatever the key. Similarly if you were sorting in descending order you could initialize to low values.

If a field containing high or low values is inadvertantly packed it will not cause a problem.

Of course you can use any hex values with the notation x"nn" it is just that they do not all have special names.

Maybe others can think of some other uses.

Clive
 
Early versions of COBOL did not have hex literals, so Low-Value and High-Value were required.

As a side note, early versions of Microfocus COBOL used X'7F' for High-Value. It didn't work very well on 8-bid machines.
 
I've used LOW-VALUES when working with null-terminated strings such as those required by C (LOW-VALUES = NULL in all the COBOLs I've ever seen).

A NULL value returned from a database read (i.e. no data in the field) is also LOW-VALUES in many systems.

I often set key fields to HIGH-VALUES when I reach EOF on an input file. It simplifies the logic in dealing with EOF with match/merge algorithms. (LOW-VALUES could be used as well if the files were sorted in descending order.)

I think there are probably lots of other uses beyond those outlined so far in these responses.

Regards.

Glenn
 
Hi Ad,

Just another point that may be worth considering. When I want to "flag" a field or a record for future testing (i.e. IF HIGH-VALUES...) and special processing. I use a string of high vals on the premise that they occur rarely in nature and would only be in that field/record because I put it there. But check that premise in EVERY situation.:)

Another good/bad thing about h/l vals is that they "print" as spaces.

Regards, Jack.
 
Some caveats in using Low-Values in files other than data files: Some printers do not "print" Low-Values (nulls) as spaces, but ignore them altogether, so that X'300031' (ascii) or X'F000F1' (ebcdic) would print as "01" not "0 1". Also, some text editors cannot process nulls. One in particular, Brief, converts them to spaces.
 
I use high-values in match programs which will work with "n" input selects. I move high-values to the match-keys. You need only test the equal leg for high-values to determine when all the files are at EOF.

I likewise use low-values to force initial low conditions.

Other than that, they are dangerous to use as their display on reports and other output media varies depending on the display software. I've seen null values been ignored which will cause data to shift without clear explanation.

Null(low) values can also be used if you need to play ganes with binary counters setting enmass to zero.
 
You could set a file key to LOW-VALUES to keep some parameter(s) in one particular record.
 
Anyone remember the days?

LOW-VALUE filler for internally processed 8.3 filenames


How about "null character insertion"
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top