Alaska Software Inc. - 9 years old isbit() bug and chr(0) in dbf-field
Username: Password:
AuthorTopic: 9 years old isbit() bug and chr(0) in dbf-field
Klemens Lichter9 years old isbit() bug and chr(0) in dbf-field
on Fri, 11 Feb 2011 00:35:37 +0100
Hi,

I need to store some bytes in a dbf field and those bytes may contain 
sometimes chr(0) values. The field legth ist 40 byte and sometimes the 
whole string is replicate(chr(0),40).
First bug: If I check this field in debugger it shows me "" instead of a 
40 byte string if all bytes are chr(0). The same if I store the field 
value into a memory variable.
I think this has something to do with string termination. Is there any 
possibility to surround this?

Second bug: If I want to check if a certain bit is set in a certain byte 
of this string, this runs fine in clipper 5.3 but fails in xBase++ 
1.9.355. I found here that there has been a bg with isbit() about 9 
years ago. Gernot Trautmann offered a workaround n[bitpos]. OK this 
workaround works fine, but is it really a fact that a bug is not fixed 
after 9 years?

Klemens
James Loughner Re: 9 years old isbit() bug and chr(0) in dbf-field
on Thu, 10 Feb 2011 18:52:40 -0500
Convert to hex maybe? It will cost twice the storage

On 02/10/2011 06:35 PM, Klemens Lichter wrote:
> Hi,
> 
> I need to store some bytes in a dbf field and those bytes may contain
> sometimes chr(0) values. The field legth ist 40 byte and sometimes the
> whole string is replicate(chr(0),40).
> First bug: If I check this field in debugger it shows me "" instead of a
> 40 byte string if all bytes are chr(0). The same if I store the field
> value into a memory variable.
> I think this has something to do with string termination. Is there any
> possibility to surround this?
> 
> Second bug: If I want to check if a certain bit is set in a certain byte
> of this string, this runs fine in clipper 5.3 but fails in xBase++
> 1.9.355. I found here that there has been a bg with isbit() about 9
> years ago. Gernot Trautmann offered a workaround n[bitpos]. OK this
> workaround works fine, but is it really a fact that a bug is not fixed
> after 9 years?
> 
> Klemens
Peter AlderliestenRe: 9 years old isbit() bug and chr(0) in dbf-field
on Fri, 11 Feb 2011 09:15:20 +0100
Klemens,

In the debugger the string indeed shows upto the first chr(0), but I found
that I can find the length of the string normally with len().
Perhaps you could save the string in a memo-field type "V".

Peter

 Lichter:

> Hi,
> 
> I need to store some bytes in a dbf field and those bytes may contain 
> sometimes chr(0) values. The field legth ist 40 byte and sometimes the 
> whole string is replicate(chr(0),40).
> First bug: If I check this field in debugger it shows me "" instead of a 
> 40 byte string if all bytes are chr(0). The same if I store the field 
> value into a memory variable.
> I think this has something to do with string termination. Is there any 
> possibility to surround this?
> 
> Second bug: If I want to check if a certain bit is set in a certain byte 
> of this string, this runs fine in clipper 5.3 but fails in xBase++ 
> 1.9.355. I found here that there has been a bg with isbit() about 9 
> years ago. Gernot Trautmann offered a workaround n[bitpos]. OK this 
> workaround works fine, but is it really a fact that a bug is not fixed 
> after 9 years?
> 
> Klemens
Andreas HerdtRe: 9 years old isbit() bug and chr(0) in dbf-field
on Fri, 11 Feb 2011 09:36:12 +0100
Hi Klemens,

For the time being it is indeed a problem to check a string that contains zero
characters. The character string is truncated at the first occurrance of a zero
character when it is visualized.

Regarding the IsBit() function - To what problem are you referring to? I would
assume that you refer to PDR 5642 (previously tools PDR 209-214), however that
one was closed back in 2002.....

Am 11.2.2011 00:35, schrieb Klemens Lichter:
> Hi,
>
> I need to store some bytes in a dbf field and those bytes may contain sometimes
> chr(0) values. The field legth ist 40 byte and sometimes the whole string is
> replicate(chr(0),40).
> First bug: If I check this field in debugger it shows me "" instead of a 40 byte
> string if all bytes are chr(0). The same if I store the field value into a
> memory variable.
> I think this has something to do with string termination. Is there any
> possibility to surround this?
>
> Second bug: If I want to check if a certain bit is set in a certain byte of this
> string, this runs fine in clipper 5.3 but fails in xBase++ 1.9.355. I found here
> that there has been a bg with isbit() about 9 years ago. Gernot Trautmann
> offered a workaround n[bitpos]. OK this workaround works fine, but is it really
> a fact that a bug is not fixed after 9 years?
>
> Klemens

With my best regards

   Andreas Herdt
   Alaska Software

--------------------------------------------------------------------

Technical Support:      support@alaska-software.com

News Server:            news.alaska-software.com
Homepage:               http://www.alaska-software.com
WebKnowledgeBase:       http://www.alaska-software.com/kbase.shtm

Fax European Office:    +49 (0) 61 96 - 77 99 99 23
Fax US Office:          +1 (646) 218 1281
--------------------------------------------------------------------
Klemens LichterRe: 9 years old isbit() bug and chr(0) in dbf-field
on Fri, 11 Feb 2011 18:17:06 +0100
Am 11.02.2011 09:36, schrieb Andreas Herdt:
> Hi Klemens,
>
> For the time being it is indeed a problem to check a string that
> contains zero
> characters. The character string is truncated at the first occurrance of
> a zero
> character when it is visualized.
>
> Regarding the IsBit() function - To what problem are you referring to? I
> would
> assume that you refer to PDR 5642 (previously tools PDR 209-214),
> however that
> one was closed back in 2002.....
>
> Am 11.2.2011 00:35, schrieb Klemens Lichter:
>> Hi,
>>
>> I need to store some bytes in a dbf field and those bytes may contain
>> sometimes
>> chr(0) values. The field legth ist 40 byte and sometimes the whole
>> string is
>> replicate(chr(0),40).
>> First bug: If I check this field in debugger it shows me "" instead of
>> a 40 byte
>> string if all bytes are chr(0). The same if I store the field value
>> into a
>> memory variable.
>> I think this has something to do with string termination. Is there any
>> possibility to surround this?
>>
>> Second bug: If I want to check if a certain bit is set in a certain
>> byte of this
>> string, this runs fine in clipper 5.3 but fails in xBase++ 1.9.355. I
>> found here
>> that there has been a bg with isbit() about 9 years ago. Gernot Trautmann
>> offered a workaround n[bitpos]. OK this workaround works fine, but is
>> it really
>> a fact that a bug is not fixed after 9 years?
>>
>> Klemens
>
> With my best regards
>

Hi Andreas,

yes, I speak of this PDR. I found yesterday that isbit returns alway .F. 
so I searched in the NG and found this PDR. Now after some more research 
I think this was also some effect coming from several chr(0) inside the 
string. Because I just now don´t need every bit within the bytes of the 
string, I changed my code an set every byte to chr(1) as default and set 
my information that has to be stored in bits 3 to 8 of every byte. Now 
it´s running perfect, even with isbit(). The workaround with n[nBit] was 
working even if there had been chr(0) in the string.

Klemens
----

Alaska newsgroup bugreport from 10.09.2002, answer from Gernot Trautmann

Valery,
Thanks for the report. XbToolsIII-PDR 0214.
Workaround:


Function Main()
Local n := 0xff,i

? n := 0xffffffff
? "isbit(n, 31)", isbit(n, 31)

? "n:", n := 0x7fffffff
? "isbit(n, 32)", isbit(n, 32)
? "setbit(@n, 32)", n:=setbit(@n, 32)
? "isbit(n, 32)", isbit(n, 32)
? "isbit(n, 31)", isbit(n, 31)
? "clearbit(@n, 32)", n:=clearbit(@n, 32)
? "isbit(n, 32)", isbit(n, 32)

     ? '32 '
n := 0xffffffff
For i := 1 to 32
     ?? if(IsBit(n,i),'T','F')+','
next
      f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,T, 
- ????????

Return NIL

function isbit(n, nBit)
return n[nBit]

function setbit(n, nBit)
	n[nBit] := .T.
return n
function clearbit(n, nBit)
	n[nBit] := .F.
return n
-- Regards, Gernot Trautmann Alaska Software Technology AG
Andreas HerdtRe: 9 years old isbit() bug and chr(0) in dbf-field
on Mon, 14 Feb 2011 09:39:07 +0100
Hi Klemens,

Am 11.2.2011 18:17, schrieb Klemens Lichter:

> Hi Andreas,
>
> yes, I speak of this PDR. I found yesterday that isbit returns alway .F. so I
> searched in the NG and found this PDR. Now after some more research I think this
> was also some effect coming from several chr(0) inside the string. Because I
> just now don´t need every bit within the bytes of the string, I changed my code
> an set every byte to chr(1) as default and set my information that has to be
> stored in bits 3 to 8 of every byte. Now it´s running perfect, even with
> isbit(). The workaround with n[nBit] was working even if there had been chr(0)
> in the string.

In case you can show some sample code that demonstrates wrong behaviour of the
function IsBit() - please send it to support.


Many thanks in advance.

   Andreas Herdt
   Alaska Software

--------------------------------------------------------------------

Technical Support:      support@alaska-software.com

News Server:            news.alaska-software.com
Homepage:               http://www.alaska-software.com
WebKnowledgeBase:       http://www.alaska-software.com/kbase.shtm

Fax European Office:    +49 (0) 61 96 - 77 99 99 23
Fax US Office:          +1 (646) 218 1281
--------------------------------------------------------------------
Jack DuijfRe: 9 years old isbit() bug and chr(0) in dbf-field
on Sun, 13 Feb 2011 11:32:05 +0100
Hello.

Would this help ?

Function My_IsBit(cData,nBit)

 cData = 1 Character
 nBit = 1..8

LOCAL nVal        := Val(cData)         Number 1..255
Return nVal[nBit]

Regards,
Jack Duijf



LOC


"Andreas Herdt" schreef in bericht 
news:407e1736$230895c7$783dd@news.alaska-software.com...
> Hi Klemens,
>
> For the time being it is indeed a problem to check a string that contains 
> zero
> characters. The character string is truncated at the first occurrance of a 
> zero
> character when it is visualized.
>
> Regarding the IsBit() function - To what problem are you referring to? I 
> would
> assume that you refer to PDR 5642 (previously tools PDR 209-214), however 
> that
> one was closed back in 2002.....
>
> Am 11.2.2011 00:35, schrieb Klemens Lichter:
>> Hi,
>>
>> I need to store some bytes in a dbf field and those bytes may contain 
>> sometimes
>> chr(0) values. The field legth ist 40 byte and sometimes the whole string 
>> is
>> replicate(chr(0),40).
>> First bug: If I check this field in debugger it shows me "" instead of a 
>> 40 byte
>> string if all bytes are chr(0). The same if I store the field value into 
>> a
>> memory variable.
>> I think this has something to do with string termination. Is there any
>> possibility to surround this?
>>
>> Second bug: If I want to check if a certain bit is set in a certain byte 
>> of this
>> string, this runs fine in clipper 5.3 but fails in xBase++ 1.9.355. I 
>> found here
>> that there has been a bg with isbit() about 9 years ago. Gernot Trautmann
>> offered a workaround n[bitpos]. OK this workaround works fine, but is it 
>> really
>> a fact that a bug is not fixed after 9 years?
>>
>> Klemens
>
> With my best regards
>
> -- 
>   Andreas Herdt
>   Alaska Software
>
> --------------------------------------------------------------------
>
> Technical Support:      support@alaska-software.com
>
> News Server:            news.alaska-software.com
> Homepage:               http://www.alaska-software.com
> WebKnowledgeBase:       http://www.alaska-software.com/kbase.shtm
>
> Fax European Office:    +49 (0) 61 96 - 77 99 99 23
> Fax US Office:          +1 (646) 218 1281
> --------------------------------------------------------------------