Highlighted
Absent Member.
Absent Member.
1289 views

Hexadecimal value in Visual COBOL

Jump to solution

[Migrated content. Thread originally posted on 25 October 2011]

Hello,

I have found a problem checking out hexadecimal values in a string. This issue makes that my application goes crazy. Look at the program below. What do you expect to be displayed? For both cases, the program displays "wcar(x) is equal to h'03'".

*$SET CALLFH("ACUFH")
*$SET RETRYLOCK
*$SET RM"ANSI"
identification division.
program-id. Program1.

environment division.
configuration section.

data division.
working-storage section.

01 wentrada pic x(80).
01 wcontrol redefines wentrada.
03 wcar pic x occurs 80.
01 wind pic 99.
01 z pic x.

procedure division.

entry-point section.
main-entrance.
move 1 to wind.
move 3 to wcar(wind).
add 1 to wind.
move H"03" to wcar(wind).
if wcar(1) equal h"03" then
display "wcar(1) is equal to h'03'"
else
display "wcar(1) is different than h'03'"
end-if.
if wcar(2) equal h"03" then
display "wcar(2) is equal to h'03'"
else
display "wcar(2) is different than h'03'"
end-if.
accept z.

end-of-program.
goback.

end program Program1.
0 Likes
1 Solution

Accepted Solutions
Highlighted
Absent Member.
Absent Member.

RE: Hexadecimal value in Visual COBOL

Jump to solution
Later I could see that the solution is to use x"03" instead of h"03".

View solution in original post

0 Likes
1 Reply
Highlighted
Absent Member.
Absent Member.

RE: Hexadecimal value in Visual COBOL

Jump to solution
Later I could see that the solution is to use x"03" instead of h"03".

View solution in original post

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.