IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Binary to Numeric in EZtrieve


IBM Mainframe Forums -> CA Products
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
S0C7

New User


Joined: 19 May 2006
Posts: 26

PostPosted: Mon May 12, 2008 3:42 pm
Reply with quote

Hi,

How do I convert a Binary field into a numeric field in Eztrieve. I want the values in all the individual bits of 1 byte.

Thanks.
Back to top
View user's profile Send private message
CICS Guy

Senior Member


Joined: 18 Jul 2007
Posts: 2146
Location: At my coffee table

PostPosted: Mon May 12, 2008 6:15 pm
Reply with quote

S0C7 wrote:
How do I convert a Binary field into a numeric field in Eztrieve.
By defination. binary is numeric....
Quote:
I want the values in all the individual bits of 1 byte.
I'm not sure of what you want, but I think a simple move to a numeric display field should provide what you need.....
Back to top
View user's profile Send private message
Craq Giegerich

Senior Member


Joined: 19 May 2007
Posts: 1512
Location: Virginia, USA

PostPosted: Mon May 12, 2008 6:26 pm
Reply with quote

Are you saying that you want to see eight ones or zeros for each byte of data. c'1' = x'f1' = b'11110001'. Eztrieve doesn't have a build in function for doing that.
Back to top
View user's profile Send private message
S0C7

New User


Joined: 19 May 2006
Posts: 26

PostPosted: Mon May 12, 2008 11:43 pm
Reply with quote

Craq Giegerich wrote:
Are you saying that you want to see eight ones or zeros for each byte of data. c'1' = x'f1' = b'11110001'. Eztrieve doesn't have a build in function for doing that.


Yah Craq, I need to identify individual bits and find out if its a 0 or a 1. Is there any way I can do that? I have a code in my shop that uses individual bits to store flags. So a byte actually stores 8 flags. I need to find these individual bit values and modify my existing Eztrieve code.

Looking forwad to ur reply.
Back to top
View user's profile Send private message
CICS Guy

Senior Member


Joined: 18 Jul 2007
Posts: 2146
Location: At my coffee table

PostPosted: Tue May 13, 2008 12:05 am
Reply with quote

How about Format 2 of the Assignment Statement?

Quote:
DEFINE F1 W 2 P MASK HEX
DEFINE F2 W 2 P VALUE X'123D'
JOB INPUT NULL NAME MYPROG
F1 = F2 AND X'FFFE'
DISPLAY SKIP 2 +
'F1 = F2 AND X''FFFE'' = ' F1
F1 = F2 OR X'000F'
DISPLAY SKIP 2 +
'F1 = F2 OR X''000F'' = ' F1
F1 = F2 XOR X'FFFF'
DISPLAY SKIP 2 +
'F1 = F2 XOR X''FFFF'' = ' F1
F1 = F2 XOR F2
DISPLAY SKIP 2 +
'F1 = F2 XOR F2 = ' F1
STOP

Produce:
Resulting
Value
F1 = F2 AND X'FFFE' = 123C
F1 = F2 OR X'000F' = 123F
F1 = F2 XOR X'FFFF' = EDC2
F1 = F2 XOR F2 = 0000

Where:
Quote:
Format 2 (Logical Expression)
Format 2 of the Assignment statement sets the value of field-name-1 equal to the result of evaluating a logical expression. The value of field-name-2 is logically acted upon by the value of field-name-3 or literal-2. The lengths of all values must be the same and literal-2 must be hexadecimal. The logic operators are processed as follows:
AND zero bits in field-name-3 or literal-2 are carried forward to field-name-2 and the result is placed in field-name-1.
OR one bit in field-name-3 or literal-2 is carried forward to field-name-2 and the result is placed in field-name-1.
XOR corresponding bits of field-name-3 or literal-2, and field-name-2 must be opposite (zero and one) to result in a one bit in field-name-1.
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Tue May 13, 2008 1:57 am
Reply with quote

Hello,

Another way to get the 1's and 0's for a byte is:

Code:

FILE FILEB   
BYTE1 1 1 A 

*my actual file has 80 bytes. . . could be anything. . .

FBYTE W 1 B     
FBIT7 W 1 A     
FBIT6 W 1 A     
FBIT5 W 1 A     
FBIT4 W 1 A     
FBIT3 W 1 A     
FBIT2 W 1 A     
FBIT1 W 1 A     
FBIT0 W 1 A     


JOB INPUT FILEB


DISPLAY BYTE1             
MOVE BYTE1 TO FBYTE       
DISPLAY FBYTE             
IF FBYTE > 127             
   MOVE '1' TO FBIT7       
   FBYTE = FBYTE - 128     
  ELSE                     
   MOVE '0' TO FBIT7       
END-IF                     
IF FBYTE > 63             
   MOVE '1' TO FBIT6       
   FBYTE = FBYTE - 64     
  ELSE                     
   MOVE '0' TO FBIT6       
END-IF                     
IF FBYTE > 31             
   MOVE '1' TO FBIT5       
   FBYTE = FBYTE - 32     
  ELSE                     
   MOVE '0' TO FBIT5       
END-IF                     
IF FBYTE > 15             
   MOVE '1' TO FBIT4       
   FBYTE = FBYTE - 16     
  ELSE                     
   MOVE '0' TO FBIT4       
END-IF                     
IF FBYTE > 7               
   MOVE '1' TO FBIT3       
   FBYTE = FBYTE - 8       
  ELSE                     
   MOVE '0' TO FBIT3       
END-IF                     
IF FBYTE > 3               
   MOVE '1' TO FBIT2       
   FBYTE = FBYTE - 4       
  ELSE                     
   MOVE '0' TO FBIT2       
END-IF                     
IF FBYTE > 1               
   MOVE '1' TO FBIT1       
   FBYTE = FBYTE - 2       
  ELSE                     
   MOVE '0' TO FBIT1       
END-IF                     
IF FBYTE = 1               
   MOVE '1' TO FBIT0       
  ELSE                     
   MOVE '0' TO FBIT0       
END-IF                     
DISPLAY FBIT7             
DISPLAY FBIT6             
DISPLAY FBIT5             
DISPLAY FBIT4   
DISPLAY FBIT3   
DISPLAY FBIT2   
DISPLAY FBIT1   
DISPLAY FBIT0   



Code:
//FILEB  DD *
)   


gives:
)
93
0
1
0
1
1
1
0
1

I ran several characters thru and the 1&0's looked right.

My test input was 80-byte data, not just 1 byte. I only used one byte for demonstration.
Back to top
View user's profile Send private message
S0C7

New User


Joined: 19 May 2006
Posts: 26

PostPosted: Tue May 13, 2008 11:27 am
Reply with quote

Thanks a lot guys.... this really helped a lot.
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Tue May 13, 2008 11:30 am
Reply with quote

You're welcome - good luck icon_smile.gif

d
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> CA Products

 


Similar Topics
Topic Forum Replies
No new posts Convert HEX to Numeric DB2 3
No new posts Find a record count/numeric is multip... COBOL Programming 1
No new posts Handling the numeric data in unstring... COBOL Programming 18
No new posts Numeric check on packed signed and un... COBOL Programming 4
No new posts Numeric check w/SyncSort. SYNCSORT 1
Search our Forums:

Back to Top