Re: REXX Testing a bit?

2022-08-02 Thread Lionel B. Dyck
Thank you all for your suggestions. This is the 1st time in decades that I've 
had a need and I may not run into a need again for many years. I was thinking 
there had to be a better way and I've learned several techniques that are now 
in my tool kit for the future.


Lionel B. Dyck <><
Website: https://www.lbdsoftware.com
Github: https://github.com/lbdyck

“Worry more about your character than your reputation. Character is what you 
are, reputation merely what others think you are.”   - - - John Wooden

-Original Message-
From: IBM Mainframe Discussion List  On Behalf Of 
Billy Ashton
Sent: Tuesday, August 2, 2022 8:29 AM
To: IBM-MAIN@LISTSERV.UA.EDU
Subject: Re: REXX Testing a bit?

If you will be doing many of these kinds of tests, you can create a simple proc 
to tell you if the bit is on:

BitOn:
If Arg(2) > Length(Arg(1)) * 8 Then Return 9;

tval = Overlay('1',X2B(C2X(Copies('00'x,Length(Arg(1),Arg(2),1);
tval = X2C(B2X(tval));
Return C2X(BitAnd(Arg(1),tval)) > 0;

The first test will return a 9 if you make an error, like specify Bit 9 of a 
1-byte field. Otherwise, it will return a 1 or 0 as True or False indicating 
the bit is on or not. Note that it will work on multi-byte or single-byte 
values.

Examples:
If BitOn("AC",15) Then Say "It is on"---> RC (1): It is on
If BitOn("ABC",26) Then Say "It is on"  ---> RC (9): null
If BitOn("A",4) Then Say "It is on"---> RC (0): null


Thank you and best regards,
Billy Ashton

-- Original Message --
>From "Billy Ashton"  To "IBM Mainframe Discussion 
>List"  Date 8/2/2022 8:40:49 AM Subject Re: REXX 
>Testing a bit?

>I usually am displaying something depending on the bit setting, so I wrote a 
>small proc:
>
>/**
>  * BITSW function: to test a bit for a value and return translation   *
>  
>**/
>BitSw:
>tr$ = Trace(o);;
>
>test_str = Arg(1);
>test_bit = Arg(2);
>test_ret = Arg(3);
>
>Return Translate(Substr(x2b(test_str),test_bit,1),test_ret,"01");
>
>
>You could use it like this:
>mystring = BitSw(flag1,6,"NY")
>
>This means:
>Test the setting of bit 6 of the flag1 variable Translate to the values 
>I pass in (N, Y) from the bit value of 0, 1
>
>
>Another simple way you could do it is to build your test mask (bit 6 on), and 
>use this:
>If C2X(Bitand(flag1,'0100'b)) > 0 Then say "got it"
>
>Thank you and best regards,
>Billy Ashton
>
>-- Original Message --
>From "Lionel B. Dyck"  To IBM-MAIN@listserv.ua.edu 
>Date 8/2/2022 7:50:10 AM Subject REXX Testing a bit?
>
>>What is the best way to test if a bit is 1 or 0?
>>
>>
>>
>>I'm doing this but was thinking there may/probably is a better way:
>>
>>
>>
>>If substr(x2b(c2x(flag1)),6,1)  = 1 then say 'got  it'
>>
>>
>>
>>
>>
>>Lionel B. Dyck <><
>>
>>Website:  <https://www.lbdsoftware.com> https://www.lbdsoftware.com
>>
>>Github:  <https://github.com/lbdyck> https://github.com/lbdyck
>>
>>
>>
>>"Worry more about your character than your reputation. Character is what you
>>are, reputation merely what others think you are."   - - - John Wooden
>>
>>
>>
>>
>>--
>>For IBM-MAIN subscribe / signoff / archive access instructions, send 
>>email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN
>

--
For IBM-MAIN subscribe / signoff / archive access instructions, send email to 
lists...@listserv.ua.edu with the message: INFO IBM-MAIN

--
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN


Re: REXX Testing a bit?

2022-08-02 Thread Billy Ashton
If you will be doing many of these kinds of tests, you can create a 
simple proc to tell you if the bit is on:


BitOn:
   If Arg(2) > Length(Arg(1)) * 8 Then Return 9;

   tval = Overlay('1',X2B(C2X(Copies('00'x,Length(Arg(1),Arg(2),1);
   tval = X2C(B2X(tval));
Return C2X(BitAnd(Arg(1),tval)) > 0;

The first test will return a 9 if you make an error, like specify Bit 9 
of a 1-byte field. Otherwise, it will return a 1 or 0 as True or False 
indicating the bit is on or not. Note that it will work on multi-byte or 
single-byte values.


Examples:
If BitOn("AC",15) Then Say "It is on"---> RC (1): It is on
If BitOn("ABC",26) Then Say "It is on"  ---> RC (9): null
If BitOn("A",4) Then Say "It is on"---> RC (0): null


Thank you and best regards,
Billy Ashton

-- Original Message --

From "Billy Ashton" 

To "IBM Mainframe Discussion List" 
Date 8/2/2022 8:40:49 AM
Subject Re: REXX Testing a bit?


I usually am displaying something depending on the bit setting, so I wrote a 
small proc:

/**
 * BITSW function: to test a bit for a value and return translation   *
 **/
BitSw:
tr$ = Trace(o);;

   test_str = Arg(1);
   test_bit = Arg(2);
   test_ret = Arg(3);

   Return Translate(Substr(x2b(test_str),test_bit,1),test_ret,"01");


You could use it like this:
mystring = BitSw(flag1,6,"NY")

This means:
Test the setting of bit 6 of the flag1 variable
Translate to the values I pass in (N, Y) from the bit value of 0, 1


Another simple way you could do it is to build your test mask (bit 6 on), and 
use this:
If C2X(Bitand(flag1,'0100'b)) > 0 Then say "got it"

Thank you and best regards,
Billy Ashton

-- Original Message --
From "Lionel B. Dyck" 
To IBM-MAIN@listserv.ua.edu
Date 8/2/2022 7:50:10 AM
Subject REXX Testing a bit?


What is the best way to test if a bit is 1 or 0?



I'm doing this but was thinking there may/probably is a better way:



If substr(x2b(c2x(flag1)),6,1)  = 1 then say 'got  it'





Lionel B. Dyck <><

Website:  <https://www.lbdsoftware.com> https://www.lbdsoftware.com

Github:  <https://github.com/lbdyck> https://github.com/lbdyck



"Worry more about your character than your reputation. Character is what you
are, reputation merely what others think you are."   - - - John Wooden




--
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN




--
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN


Re: REXX Testing a bit?

2022-08-02 Thread Paul Gilmartin
On Tue, 2 Aug 2022 07:43:17 -0500, Dale R. Smith wrote:

>On Tue, 2 Aug 2022 06:50:10 -0500, Lionel B. Dyck wrote:
>>
>>If substr(x2b(c2x(flag1)),6,1)  = 1 then say 'got  it'
>> 
Some say "= 1" is superfluous, pleonasm.  However:

o Others say it adds clarity.

o Others insist on maintaining the notional distinction between boolean and 
other types.

>Assuming flag1 is a one byte field:
>If BitAnd(flag1,'40'x) == '40 × Then Say 'got it'
>
>Make sure you use exactly equal (==) especially when testing for hex 40!
> 
I'm more comfortable with "\== '00'x", especially when emulating TM.

-- 
gil

--
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN


Re: REXX Testing a bit?

2022-08-02 Thread Colin Paice
if BITAND(invalue,  '01'x)  =  '01'x


On Tue, 2 Aug 2022 at 12:50, Lionel B. Dyck  wrote:

> What is the best way to test if a bit is 1 or 0?
>
>
>
> I'm doing this but was thinking there may/probably is a better way:
>
>
>
> If substr(x2b(c2x(flag1)),6,1)  = 1 then say 'got  it'
>
>
>
>
>
> Lionel B. Dyck <><
>
> Website:   https://www.lbdsoftware.com
>
> Github:   https://github.com/lbdyck
>
>
>
> "Worry more about your character than your reputation. Character is what
> you
> are, reputation merely what others think you are."   - - - John Wooden
>
>
>
>
> --
> For IBM-MAIN subscribe / signoff / archive access instructions,
> send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN
>

--
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN


Re: REXX Testing a bit?

2022-08-02 Thread Dale R. Smith
On Tue, 2 Aug 2022 06:50:10 -0500, Lionel B. Dyck  wrote:

>What is the best way to test if a bit is 1 or 0?
>
>
>
>I'm doing this but was thinking there may/probably is a better way:
>
>
>
>If substr(x2b(c2x(flag1)),6,1)  = 1 then say 'got  it'
>
>
>
>
>
>Lionel B. Dyck <><

Assuming flag1 is a one byte field:
If BitAnd(flag1,'40'x) == '40 × Then Say 'got it'

Make sure you use exactly equal (==) especially when testing for hex 40!

-- 
Dale R. Smith

--
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN


Re: REXX Testing a bit?

2022-08-02 Thread Itschak Mugzach
i use if (bitand(xxx) = x'80') (or any other hex value that match your bit
position

ITschak

*| **Itschak Mugzach | Director | SecuriTeam Software **|** IronSphere
Platform* *|* *Information Security Continuous Monitoring for Z/OS, zLinux
and IBM I **|  *

*|* *Email**: i_mugz...@securiteam.co.il **|* *Mob**: +972 522 986404 **|*
*Skype**: ItschakMugzach **|* *Web**: www.Securiteam.co.il  **|*





On Tue, Aug 2, 2022 at 3:39 PM David Spiegel 
wrote:

> Hi Lionel,
> (assuming Rexx) you can omit "=1"
>
> Regards,
> David
>
> On 2022-08-02 07:50, Lionel B. Dyck wrote:
> > What is the best way to test if a bit is 1 or 0?
> >
> >
> >
> > I'm doing this but was thinking there may/probably is a better way:
> >
> >
> >
> > If substr(x2b(c2x(flag1)),6,1)  = 1 then say 'got  it'
> >
> >
> >
> >
> >
> > Lionel B. Dyck <><
> >
> > Website:  <
> https://nam12.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwww.lbdsoftware.com%2F&data=05%7C01%7C%7Ccc1e9338f8394f1904cb08da747d372a%7C84df9e7fe9f640afb435%7C1%7C0%7C637950378433404515%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=fLnRqUbAjMhhMGALjlZVtFw%2BWZjF91dxjPmezCDeis4%3D&reserved=0>
>
> https://nam12.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwww.lbdsoftware.com%2F&data=05%7C01%7C%7Ccc1e9338f8394f1904cb08da747d372a%7C84df9e7fe9f640afb435%7C1%7C0%7C637950378433404515%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=fLnRqUbAjMhhMGALjlZVtFw%2BWZjF91dxjPmezCDeis4%3D&reserved=0
> >
> > Github:  <
> https://nam12.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Flbdyck&data=05%7C01%7C%7Ccc1e9338f8394f1904cb08da747d372a%7C84df9e7fe9f640afb435%7C1%7C0%7C637950378433404515%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=WSxsbepwoLIuGFflWOUFpLpA3kRLZGNl0GLeDJLZsww%3D&reserved=0>
>
> https://nam12.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Flbdyck&data=05%7C01%7C%7Ccc1e9338f8394f1904cb08da747d372a%7C84df9e7fe9f640afb435%7C1%7C0%7C637950378433404515%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=WSxsbepwoLIuGFflWOUFpLpA3kRLZGNl0GLeDJLZsww%3D&reserved=0
> >
> >
> >
> > "Worry more about your character than your reputation. Character is what
> you
> > are, reputation merely what others think you are."   - - - John Wooden
> >
> >
> >
> >
> > --
> > For IBM-MAIN subscribe / signoff / archive access instructions,
> > send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN
>
> --
> For IBM-MAIN subscribe / signoff / archive access instructions,
> send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN
>

--
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN


Re: REXX Testing a bit?

2022-08-02 Thread Billy Ashton
I usually am displaying something depending on the bit setting, so I 
wrote a small proc:


/**
 * BITSW function: to test a bit for a value and return translation   *
 **/
BitSw:
tr$ = Trace(o);;

   test_str = Arg(1);
   test_bit = Arg(2);
   test_ret = Arg(3);

   Return Translate(Substr(x2b(test_str),test_bit,1),test_ret,"01");


You could use it like this:
mystring = BitSw(flag1,6,"NY")

This means:
Test the setting of bit 6 of the flag1 variable
Translate to the values I pass in (N, Y) from the bit value of 0, 1


Another simple way you could do it is to build your test mask (bit 6 
on), and use this:

If C2X(Bitand(flag1,'0100'b)) > 0 Then say "got it"

Thank you and best regards,
Billy Ashton

-- Original Message --

From "Lionel B. Dyck" 

To IBM-MAIN@listserv.ua.edu
Date 8/2/2022 7:50:10 AM
Subject REXX Testing a bit?


What is the best way to test if a bit is 1 or 0?



I'm doing this but was thinking there may/probably is a better way:



If substr(x2b(c2x(flag1)),6,1)  = 1 then say 'got  it'





Lionel B. Dyck <><

Website:  <https://www.lbdsoftware.com> https://www.lbdsoftware.com

Github:  <https://github.com/lbdyck> https://github.com/lbdyck



"Worry more about your character than your reputation. Character is what you
are, reputation merely what others think you are."   - - - John Wooden




--
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN


--
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN


Re: REXX Testing a bit?

2022-08-02 Thread David Spiegel

Hi Lionel,
(assuming Rexx) you can omit "=1"

Regards,
David

On 2022-08-02 07:50, Lionel B. Dyck wrote:

What is the best way to test if a bit is 1 or 0?

  


I'm doing this but was thinking there may/probably is a better way:

  


If substr(x2b(c2x(flag1)),6,1)  = 1 then say 'got  it'

  

  


Lionel B. Dyck <><

Website:  

 
https://nam12.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwww.lbdsoftware.com%2F&data=05%7C01%7C%7Ccc1e9338f8394f1904cb08da747d372a%7C84df9e7fe9f640afb435%7C1%7C0%7C637950378433404515%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=fLnRqUbAjMhhMGALjlZVtFw%2BWZjF91dxjPmezCDeis4%3D&reserved=0

Github:  

 
https://nam12.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Flbdyck&data=05%7C01%7C%7Ccc1e9338f8394f1904cb08da747d372a%7C84df9e7fe9f640afb435%7C1%7C0%7C637950378433404515%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=WSxsbepwoLIuGFflWOUFpLpA3kRLZGNl0GLeDJLZsww%3D&reserved=0

  


"Worry more about your character than your reputation. Character is what you
are, reputation merely what others think you are."   - - - John Wooden

  



--
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN


--
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN


REXX Testing a bit?

2022-08-02 Thread Lionel B. Dyck
What is the best way to test if a bit is 1 or 0?

 

I'm doing this but was thinking there may/probably is a better way:

 

If substr(x2b(c2x(flag1)),6,1)  = 1 then say 'got  it'

 

 

Lionel B. Dyck <><

Website:   https://www.lbdsoftware.com

Github:   https://github.com/lbdyck

 

"Worry more about your character than your reputation. Character is what you
are, reputation merely what others think you are."   - - - John Wooden

 


--
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN