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



TESTBIT()

is available at www.rpglanguage.com/boolean

Regards,
John McKay mba

----- Original Message ----- From: "Adam Glauser" <adamglauser@xxxxxxxxx>
Newsgroups: midrange.rpg400-l
To: <rpg400-l@xxxxxxxxxxxx>
Sent: Monday, June 22, 2009 5:24 PM
Subject: Re: Bit Operation - BITAND


Michael Ryan wrote:
Hi Adam -

Actually, I have to test each bit in PrimaryBitMap to see if that bit is on
or off.

It's too bad that there isn't a %testbit() function. As far as I know,
the most straightforward way of doing this would be to define a "mask"
for each bit you want to test.

For example, say your bit map is a set of customer information flags.
http://code.midrange.com/71a457c8f6.html

Another possibility would be to define eight masks, one mask for each
bit in a byte, then loop through each byte in the bitmap field, setting
elements of a 64-element array of indicators to *ON or *OFF as
appropriate. Then you could set up constants to name each of the bits

D ACTIVE_CUST...
D C 1
// binary 01000000....0000, test second bit
D PAYMENT_DUE_MASK...
D C 2

and say things like

if (flag(ACTIVE_CUST) = *ON);
// do active cust processing

Yet another possibility is to build a service program with one procedure
per flag, where each procedure would use one of the masks from the first
example. This might be the best way to go if you need to test these
flags in more than one place.

HTH,
Adam
--
This is the RPG programming on the IBM i / System i (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-Ups:
Replies:

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.