Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Bintoc() & ctobin()
Message
De
14/05/2005 22:04:26
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivie
 
 
À
14/05/2005 21:58:22
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 7 SP1
Divers
Thread ID:
01014168
Message ID:
01014305
Vues:
25
>Hilmar:
>
>"Necessity" the mother of invention. I took a different approach and used ASC() to convert a string to a number that I could then manipulate with BITCLEAR(), BITSET() and so forth. I then used CHR() to convert back to a string. Before I had been using CTOBIN() and BINTOC() to do the conversions. The problem with VFP8 and below is that BINTOC() sets the sign which corrupts the bit map I was building. VFP9 has the "S" parameter to prevent this. How-some-ever, I ran into some compatibility problems with VFP9 (that's another story) and had to rule that path out. Using ASC() and CHR() are a little awkward because I have to work with 8 bits at a time and the bit maps are usually 64 or 128 bits. Not a big deal really. Once I finish coding the functions I probably won't see them again for three or four years.
>
>None the less, I needed to do this post because I was staring at a blank wall.
>
>Thanks,
>
>Scott

Indeed, your approach seems more appropriate, since VFP will do most of the work (I think), and you only need to change individual bits.

I see that the bit functions work with 32 bits at a time, so for longer bit-strings, I assume you have to piece them together.
Difference in opinions hath cost many millions of lives: for instance, whether flesh be bread, or bread be flesh; whether whistling be a vice or a virtue; whether it be better to kiss a post, or throw it into the fire... (from Gulliver's Travels)
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform