Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref

Author Message
S0C7

New User

Joined: 19 May 2006
Posts: 26

 Posted: Mon May 12, 2008 3:42 pm    Post subject: Binary to Numeric in EZtrieve 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.

CICS Guy

Senior Member

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

Posted: Mon May 12, 2008 6:15 pm    Post subject: Re: Binary to Numeric in EZtrieve

 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.....
Craq Giegerich

Senior Member

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

 Posted: Mon May 12, 2008 6:26 pm    Post subject: 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.
S0C7

New User

Joined: 19 May 2006
Posts: 26

Posted: Mon May 12, 2008 11:43 pm    Post subject:

 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.

CICS Guy

Senior Member

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

Posted: Tue May 13, 2008 12:05 am    Post subject:

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.
dick scherrer

Site Director

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

Posted: Tue May 13, 2008 1:57 am    Post subject:

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.
S0C7

New User

Joined: 19 May 2006
Posts: 26

 Posted: Tue May 13, 2008 11:27 am    Post subject: Thanks a lot guys.... this really helped a lot.
dick scherrer

Site Director

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

 Posted: Tue May 13, 2008 11:30 am    Post subject: Reply to: Binary to Numeric in EZtrieve You're welcome - good luck d
 All times are GMT + 6 Hours
 Page 1 of 1

Search our Forum:

 Topic Author Forum Replies Posted Similar Topics Moving a COMP-3 Variable to a Numeric... ajayachander COBOL Programming 2 Thu Dec 14, 2017 5:46 pm File Aid tool to compare numeric data balaji81_k Compuware & Other Tools 2 Tue Sep 26, 2017 3:35 am Binary to display characters Roy Ware SYNCSORT 3 Tue Sep 19, 2017 8:46 pm Remove leading spaces from numeric field rexx77 SYNCSORT 6 Wed Sep 06, 2017 2:15 am Return a Non Numeric value from REXX Learncoholic CLIST & REXX 3 Fri Sep 01, 2017 8:33 pm

 © 2003-2017 IBM MAINFRAME Software Support Division
 Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us