Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
VarBinary
Message
From
18/08/2010 17:02:49
 
 
To
18/08/2010 13:27:20
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Windows 7
Miscellaneous
Thread ID:
01476933
Message ID:
01477167
Views:
37
>>>>Hi All:
>>>>
>>>>I have a VARBINARY field in my table called varb with a value of, say, 0h0000011111. I want to set up ten fields in my table (R1 to R10) that represents each bit, so that the user can easily change each bit.
>>>>
>>>>What syntax would I use to transfer each bit to the proper field such as:
>>>>
>>>>
>>>>Replace R8 with substr(varb,8,1) - which doesn't work.
>>>>
>>>>
>>>>THEN, once the user has completed his task, I would need the equivalent of
>>>>
>>>>
>>>>Replace varb with CharToVarbinary(R1 + R2 ... + R10)
>>>>
>>>>
>>>>Thanks,
>>>>
>>>>Yossi
>>>
>>>
>>>
>>>Replace R8 with substr(varb,8,1)#0h0
>>>
>>>Replace varb with IIF(R1,0h1,0h0)+...
>>>
>>>
>>>
>>>you can shrink data using varb=0h0F and
>>>
>>>Replace R8 with BITTEST(varb,8)
>>>
>>>...
>>>
>>
>>Fabio:
>>
>>1. What do you mean by 'you can shrink data using varb=0h0F'
>>2. I say:
>>
>>
>>? rf_rptlvl                         0h0000000111
>varbinary is a byte base datatype
>then 0h0000000111 = 0b0000000000000000000000000000000100010001
>
>>? VARTYPE(rf_rptlvl)       Q
>>? BITTEST(rf_rptlvl,1)      .F.
>
>* BITTEST check the bit within the varbynary string 
>* - start with left first byte
>* - for each byte lower bit is map to 0 index
>* then
>FOR k=0 TO 15
> ? m.k,BITTEST(0h1480,m.k)
>next
>
>* print
>* 4
>         0 .F.
>         1 .F.
>         2 .T.
>         3 .F.
>* 1
>         4 .T.
>         5 .F.
>         6 .F.
>         7 .F.
>* 0
>         8 .F.
>         9 .F.
>        10 .F.
>        11 .F.
>* 8
>        12 .F.
>        13 .F.
>        14 .F.
>        15 .T.
>>
>>
>>Shouldn't I be getting .T. on the BITTEST(rf_rptlvl,1)? What am I doing wrong?
>>
>>3. How can I accomplish:
>>
>>
>>? rf_rptlvl                         0h0000000011
>>? ConvertToRegularNumeric(rf_rpflvl) = 3    .T.
>>
>>
>>Thanks,
>>
>>Yossi

Fabio:

Thanks! You gave me the info I need.

Yossi
Previous
Reply
Map
View

Click here to load this message in the networking platform