05 Aug 95 10:16, Frank Cox escrib¡a a Whoever cares:
Hi Frank!
FC> Hypothetical situation: We have a database containing names and
FC> yes/no answers, like this:
FC> I see two characteristics of this database that "waste space". First,
FC> all of the ASCII characters in the names are CHR$(127) or less.
FC> Second, a yes/no answer only requires one bit to be on or off.
FC> Question: Has anyone written a routine or does anyone know how to
FC> build and maintain a datafile in PowerBASIC where a field can be
FC> defined using 7-bit ASCII and a field can be only one bit long if
FC> required?
Ummm! A system that uses a 7 bit storage strategy has a big speed penalty
more that the memory that remains free. The speed reduction may be around
30-1 and the memory reduction may be around 7-1, this situation made this
algoritm not interesting.
In the other hand a 1 bit storage is easy and has a direct support by PB,
you can do this:
Dim MyVar (1000) as BYTE
And you can access to an 8.000 bit field array using:
Answer=Bit(MyVar(0),5000)
And set it with:
Bit Set MyVar(0),5000
Note: I think that the PB 'bounds check' don't test this situation, be
carefull.
Saludotes,
,,, JOS (2:348/102)
`0-0' jmejuto@encomix.com
/-(_)-\ mejuto@sfdzuma.usc.es
--- FD2.12+ & GoldED 2.50+ & FE145+
---------------
* Origin: -=EDI=BBS=-// Santiago de Compostela //+34-81-502110 (2:348/102)
|