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



Hi Alan -

Yeah...I'd like to get this code. Please send it directly to me at
michaelrtr at gmail dot com.

Thanks!

On Mon, Jun 22, 2009 at 1:33 PM, Alan Campin <alan0307d@xxxxxxxxx> wrote:

Here is some procedures that I wrote that do testing and masking. The forum
is going to screw up the code so let me know if you want sent direct.

* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
* AttributeOn
* This function checks to determine if bit flag is set for requested
* attribute.
* Input - Attribute
* - Attribute flags
* Output - None
* Returns - True or False
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
p AttributeOn...
p b
d pi Like(StdLgl)
d InAttribute...
d Like(StdIntSml)
d Value
d InAttributeFlags...
d Like(StdIntSml)
d Value
/Free

// Color bits are masked out(High order).
If %BitAnd(MaskHighOrderBits(InAttributeFlags):
InAttribute ) = x'00';
Return cFalse;
Else;
Return cTrue;
EndIf;

/End-Free
p e
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
* ColorOn
* This function checks to determine if a color is on.
* attribute.
* Input - Color value
* - Attribute flags
* Output - None
* Returns - True or False
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
p ColorOn...
p b
d pi Like(StdLgl)
d InColorValue...
d Like(StdIntSml)
d Value
d InAttributeFlags...
d Like(StdIntSml)
d Value
/Free

// Attribute bits are masked out(Low order).
If %BitAnd(MaskLowOrderBits(InAttributeFlags):
InColorValue ) = x'00';
Return cFalse;
Else;
Return cTrue;
EndIf;

/End-Free
p e
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
* NoAttributes
* This function checks to determine if there are no attributes
* passed. (No low order bits).
* Input - Attribute flags
* Output - None
* Returns - True or False
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
p NoAttributes...
p b
d pi Like(StdLgl)
d InAttributeFlags...
d Like(StdIntSml)
d Value
/Free

// Color bits are masked out(High order).
If MaskHighOrderBits(InAttributeFlags) = 0;
Return cTrue;
Else;
Return cFalse;
EndIf;

/End-Free
p e
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
* MaskHighOrderBits
* This function removes high order bits from a small integer
* field.
* Input - Field to mask.
* Output - None
* Returns - Masked field.
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
p MaskHighOrderBits...
p b
d pi Like(StdIntSml)
d InFieldToMask...
d Like(StdIntSml)
d Value

d cMaskHighOrderBits...
d c 255
/Free

Return %BitAnd(InFieldToMask :
cMaskHighOrderBits);

/End-Free
p e
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
* MaskLowOrderbits
* This function removes low order bits from a small integer
* field.
* Input - Field to mask.
* Output - None
* Returns - Masked field.
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
p MaskLowOrderBits...
p b
d pi Like(StdIntSml)
d InFieldToMask...
d Like(StdIntSml)
d Value

d cMaskLowOrderBits...
d c 65280
/Free

Return %BitAnd(InFieldtoMask :
cMaskLowOrderBits);

/End-Free
p e

On Mon, Jun 22, 2009 at 10:24 AM, Adam Glauser <adamglauser@xxxxxxxxx
wrote:

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.


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

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.