Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Bit manipulation on the string data

Status
Not open for further replies.

AMakovoz

MIS
Jun 20, 2000
19
US
Is there any easy way to manipulate bits on the string data similar to BITxxx functions used for numeric data? [sig][/sig]
 
Hi AMakovoz,

You may want to elaborate on what you mean by bits on the string data. Maybe give an example of what you are trying to achieve.

The BITxxx functions are used to perform bitwise operations on binary data, IOW, 0's and 1's. [sig]<p>Jon Hawkins<br><a href=mailto: jonscott8@yahoo.com> jonscott8@yahoo.com</a><br><a href= > </a><br>Focus on the solution....Not the problem.[/sig]
 
Hello AMakovoz!
Try to use the ASC() function to retrieve the ANSI value of char. Then you can use BITxxx functions with this value.

Marat
tolgambaev@hotmail.com [sig][/sig]
 
To Jon Hawkins: Thanks for responding.
Here what I'm trying to do: Let suppose I have a text field 100 char long (its 800 bits). I want to be able to analyze and modify each bit (i.e. set its value to 0 or 1). A can do it using ASC, CHR, BITxxx functions but it takes forever on the big table. Is there more effective way to do it? [sig][/sig]
 
If you want it to be really fast, then write the routine in C and compile it as a DLL or FLL, and include it in your project. [sig][/sig]
 
Let suggest you need to get value of bit 200 from your string MyField:
BitN = 200
? BITTEST(asc(substr(MyField, BitN/8 + 1, 1)), BitN % 8)

Let suggest you need change bit 200 in your string:

BitN = 200
BytePos = BitN/8 + 1
ResultString = ;
STUFF(MyField, BytePos, 1, CHR( ;
BITSET(asc(substr(MyField, BytePos, 1)), BitN % 8) ;
))
[sig]<p>Vlad Grynchyshyn<br><a href=mailto:vgryn@softserve.lviv.ua>vgryn@softserve.lviv.ua</a><br>[/sig]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top