tparray18.pp 964 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. { %fail }
  2. { currently fails under FPC, because parameters to read(ln) have to be }
  3. { var parameters, and you cannot pass bitpacked record fields and array }
  4. { elements as var parameters }
  5. { from gpc tests, original name: bitfields.pas }
  6. {$ifdef fpc}
  7. {$bitpacking on}
  8. {$endif}
  9. Program BitFields;
  10. Var
  11. Foo: packed record
  12. b: 0..63;
  13. a: 0..1;
  14. end { Foo };
  15. r: packed array [ 40..47 ] of 0..1;
  16. F: Text;
  17. begin
  18. assign(f,'bitfields.txt');
  19. rewrite ( F );
  20. writeln ( F, '42' );
  21. writeln ( F, '0' );
  22. writeln ( F, '1' );
  23. with Foo do
  24. begin
  25. reset ( F );
  26. readln ( F, b );
  27. readln ( F, a );
  28. readln ( F, r [ 42 ] );
  29. close ( F );
  30. erase ( F );
  31. if ( b = 42 ) and ( a = 0 ) and ( r [ 42 ] = 1 ) then
  32. writeln ( 'OK' )
  33. else
  34. begin
  35. writeln ( 'failed: ', b, ' ', a, ' ', r [ 42 ] );
  36. halt(1);
  37. end;
  38. end { with };
  39. end.