home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / ipo-101.zip / Samples.zip / NOTSTRIC.PAS < prev    next >
Pascal/Delphi Source File  |  1997-12-07  |  798b  |  28 lines

  1. (*
  2. ** PURPOSE: Illustrates the dangers of turning off strict checking
  3. ** COMPILE: ipw -s- notstric
  4. ** RUN:     ivm notstric
  5. ** NOTE:    The value of 'i' is changed by the assignment to 's'.
  6. **          Because an assignment to 's' is actually an assignment
  7. **          to 'x' but the 'Hello world!' is too long to fit in 'x'
  8. **          so it overflows into 'i'.
  9. **          (see the discussion on the strict checking in "user.txt"
  10. **          for more information). 
  11. *)
  12. program NotStrict(output);
  13. var
  14.    x : string[7];
  15.    i : integer;
  16.  
  17.    procedure f(var s : string);
  18.    begin
  19.       writeln('Before assignment i =', i);
  20.       s := 'Hello world!'; (* assignment to global 'x' through 's' *)
  21.       writeln('After assignment i =', i)
  22.    end;
  23.  
  24. begin
  25.    i := 0;
  26.    f(x)
  27. end.
  28.