× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Thank you Scott and Daniel!, 

I think I get the gist of it now.

-----Original Message-----
From: rpg400-l-bounces@xxxxxxxxxxxx
[mailto:rpg400-l-bounces@xxxxxxxxxxxx]On Behalf Of Scott Klement
Sent: Wednesday, February 16, 2005 3:03 PM
To: RPG programming on the AS400 / iSeries
Subject: Re: Free-form Equivalent to BITOFF?


Hi,

> I am trying to convert a statement that turns off the first four bits in a
> single byte field to free-form and am unsure of the best way to do that.
>
> Original statement:
> C                   BITOFF    '0123'        BYTE

Create a hex field containing the bits that you want to keep on. The 
%bitand() BIF will return a new byte where only those bits are copied from 
the original.

The old opcodes (like your example above) confuse me, so I hope I'm right, 
but this is what I suggest:

    byte = %bitand(x'0F': BYTE);

How this works is based on copying the bits that are on in BOTH bytes to 
the result. For the sake of example, let's say that BYTE contains the 
letter R, which is x'D9' in EBCDIC (I just picked this as a random value)
You'll have the following in binary:

    x'0F' = 00001111
    x'D9' = 11011001

So, it copies the bits that are in on BOTH fields, yielding:
            00001001

In other words, since I used x'0F' (which has the first 4 bits off, and 
the last 4 bits on) it copies just the last 4 bits of the field, and sets 
the rest of them off.

-- 
This is the RPG programming on the AS400 / iSeries (RPG400-L) mailing list
To post a message email: RPG400-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/rpg400-l.

As an Amazon Associate we earn from qualifying purchases.

This thread ...


Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.