home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / PASCAL / TP_ADV.ZIP / LIST0201.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1989-07-31  |  1.6 KB  |  49 lines

  1. {$D+,L+,R+,A-}
  2. {$V-}
  3. Program DebuggingExampleOne;
  4. { Show the problems of using the $V- compiler directive     }
  5. { when passing a typed string variable to a procedure that  }
  6. { accepts a referance parameter of type STRING.             }
  7.  
  8. Type
  9.   Str20 = String[20];     { Type to be passed to demo proc  }
  10.  
  11. Const
  12.   ArraySize = 5;
  13.  
  14. Var
  15.   St1 : Str20;            { Variable to be passed to proc   }
  16.   TrashedMemory : Array[1..ArraySize] Of Byte;
  17.                           { Memory that will be overwritten }
  18.   I : Integer;            { Loop control variable           }
  19.  
  20. Procedure StringAssign( Var S : String );
  21. { This procedure will accept any length string parameter    }
  22. { and assign a string constant to the parameter one         }
  23. { character at a time.                                      }
  24.  
  25. Const
  26.   NewStr : String = '1234567890';
  27.                           { String to be assigned to param  }
  28.  
  29. Var
  30.   I : Integer;            { Loop control variable           }
  31.  
  32. Begin
  33.   S := '';                { Initialize Parameter            }
  34.   For I := 1 to 23 Do     { Copy 23 characters into param   }
  35.     S := S + NewStr[( I Mod 10 ) + 1];
  36. End;
  37.  
  38. Begin
  39.   FillChar( TrashedMemory, SizeOf( TrashedMemory ), #0 );
  40.                           { Init Memory to see corruption   }
  41.   FillChar( St1, SizeOf( St1 ), #0 );
  42.                           { Initialize var to be passed     }
  43.   StringAssign( St1 );    { Call the procedure              }
  44.   Writeln( St1 );         { Output the string to the screen }
  45.   For I := 1 to ArraySize Do
  46.     Write( TrashedMemory[I], '  ' );
  47.                           { Output the corrupted memory     }
  48. End.
  49.