×

Good News Everybody!

The new search engine is LIVE!

Please report any problems to david (at) midrange.com.




In C, logically shifting bits left or right is easy. In MI, it can be done with 
CPYBTLLS or CPYBTRLS. Even in REXX, character/hex/binary conversions can make 
it easy.

Other than by multiplying/dividing binary values by powers of two or using an 
ugly series of bit-level builtins (setbts, clrbts, tstbts, and others), is 
there any good way in other languages?

As a bonus for reading this, I thought I'd include a bit of V5R3 ILE CL that 
shows a way to check the "length" of a *CHAR variable. Pretty cool stuff now 
available in CL:

pgm

   dcl        &str          *char       10     value( 'abc' )
   dcl        &stri         *char       11

   dcl        &len          *int               value( 0 )

   dcl        &x00          *char        1     value( x'00' )

   chgvar   &stri    ( &str *cat &x00 )

   callprc  'triml'  ( +
                       &stri  +
                       ( ' '   *byval ) +
                     ) +
               rtnval( &len )

dmpclpgm

   return

endpgm

Create that as a module. Then use CRTPGM with BNDDIR(QC2LE) to find the 'triml' 
procedure. Procedure 'triml' takes a null-terminated string and returns the 
length after checking for the trailing character that is specified in the 
second parm. In this case, trailing blanks are counted off; but it could be any 
character.

Tom Liotta

-- 
Tom Liotta
The PowerTech Group, Inc.
19426 68th Avenue South
Kent, WA 98032
Phone  253-872-7788 x313
Fax    253-872-7904
http://www.powertech.com


__________________________________________________________________
Switch to Netscape Internet Service.
As low as $9.95 a month -- Sign up today at http://isp.netscape.com/register

Netscape. Just the Net You Need.

New! Netscape Toolbar for Internet Explorer
Search from anywhere on the Web and block those annoying pop-ups.
Download now at http://channels.netscape.com/ns/search/install.jsp

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