[fpc-devel] Packed array of boolean
David.Walker2 at McKesson.com
Tue Apr 8 14:08:19 CEST 2008
We're in the process of migrating an *OLD* (25+ years) application from Oregon Pascal / SCO Unix to Free Pascal (2.2.0) / SuSE Linux Enterprise. This involves at least 300,000 code lines.
The problem we've encountered is with "packed array of boolean". The compiler seems to "pack" booleans 1 per byte, whereas our old compiler packed them one per bit, into the smallest size possible. This presents a problem, because the records in our 135 disk files (per site) store bit arrays in this manner. We're trying to avoid having to do conversions on these files, as there are 600+ sites affected, and some of the files at these sites contain in excess of 1 million records.
I understand there is a TBits I could possibly use. The problem there is two-fold:
1) None of the other code is even remotely object-oriented. This is an old-fashioned procedural program, with a character interface, no mouse, no doohickeys, no popup anything. This might not be a problem but for the next point:
2) the TBits doesn't appear to have a way to write the contents of its bit array anywhere. I can test and set bits, but that appears to be about all. I can't save the bits once I've set/cleared them.
In reference to point 2 above, I attempted to write a descendant of TBits with the necessary Write method, but FBits (the actual bit array) is declared private in TBits, so I can't access it. IMO it should have been declared protected. Unfortunately, rewriting the existing TBits is not within the scope of the present project.
So, am I overlooking something in TBits, or am I reduced to writing the bit-twiddling routines myself? Or is there another approach someone can suggest?
More information about the fpc-devel