home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / lang / pascal / 5119 < prev    next >
Encoding:
Internet Message Format  |  1992-08-30  |  1.1 KB

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