home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!usc!wupost!waikato.ac.nz!comp.vuw.ac.nz!canterbury.ac.nz!lincoln.ac.nz!cachoo
- Newsgroups: comp.lang.pascal
- Subject: reading Bit mapped fields
- Message-ID: <1992Aug31.094135.245@lincoln.ac.nz>
- From: cachoo@lincoln.ac.nz
- Date: 31 Aug 92 09:41:35 +1200
- Lines: 26
-
- According to the TurboVision guide and TP programmers manual, to check whether
- a particular bit is set in an integer, you can use the AND operator.
- lets say that we have:
-
- var
- I : Integer;
- CheckBoxResult : Word;
- BitIsSet : Array[0..15] of Boolean;
- begin
- {get CheckBoxResult from user}
- for I := 0 to 15 do
- if CheckBoxResult AND I = I then BitIsSet[I] := True
- else BitIsSet[I] := False;
- end;
-
- As I understand TP instructions, this code should return the boolean equivalent
- of the binary value of CheckBoxResult. But it does not work!
- What am I doing wrong?
-
- The other option would be to convert CheckBoxResult to a 'binary' string and
- then check each string element (for '0' or '1') to fill up the BitIsSet
- array. This seems a little cumbersome compared to the bitwise solution in the
- code above. Can anybody help?
- Thanks
- Oscar
-
-