t82_setin.pas 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. program t82_setin;
  2. { t82 -- `in' with a RUN-TIME element.
  3. CALC.INC's Clear loop is `until Upcase(Ch) in ['Y','N']': the element is a
  4. value in AX, not a compile-time constant, so the bit test has to run. The
  5. set may be an inline literal (code-resident), a typed constant (also
  6. code-resident) or a data set (a record field): the address is chosen
  7. accordingly, then byte = (e - base) DIV 8 and bit = (e - base) MOD 8.
  8. Also covers `Ch in ['a'..'z']' (a range in a literal) and an enumerated data
  9. set with both a present and an absent element. }
  10. const
  11. Digits : set of Char = ['0'..'9'];
  12. type
  13. Attr = (Constant, Formula, Txt, OverWritten, Locked, Calculated);
  14. Cell = record
  15. S : set of Attr;
  16. N : integer;
  17. end;
  18. var
  19. c : char;
  20. i : integer;
  21. sh : array [1..2, 1..3] of Cell;
  22. begin
  23. c := 'Y';
  24. if Upcase (c) in ['Y', 'N'] then writeln ('yes') else writeln ('no');
  25. c := 'x';
  26. if Upcase (c) in ['Y', 'N'] then writeln ('yes') else writeln ('no');
  27. c := 'a';
  28. if c in ['a'..'z'] then writeln ('lower') else writeln ('not');
  29. c := 'A';
  30. if c in ['a'..'z'] then writeln ('lower') else writeln ('not');
  31. sh[1,1].S := [Locked];
  32. i := 1;
  33. if i in sh[1,1].S then writeln ('locked') else writeln ('not-locked');
  34. i := 4;
  35. if i in sh[1,1].S then writeln ('locked') else writeln ('not-locked');
  36. c := '7';
  37. if c in Digits then writeln ('digit') else writeln ('not');
  38. c := 'x';
  39. if c in Digits then writeln ('digit') else writeln ('not')
  40. end.