home *** CD-ROM | disk | FTP | other *** search
- {$D+,L+,R+,A-}
- {$V-}
- Program DebuggingExampleOne;
- { Show the problems of using the $V- compiler directive }
- { when passing a typed string variable to a procedure that }
- { accepts a referance parameter of type STRING. }
-
- Type
- Str20 = String[20]; { Type to be passed to demo proc }
-
- Const
- ArraySize = 5;
-
- Var
- St1 : Str20; { Variable to be passed to proc }
- TrashedMemory : Array[1..ArraySize] Of Byte;
- { Memory that will be overwritten }
- I : Integer; { Loop control variable }
-
- Procedure StringAssign( Var S : String );
- { This procedure will accept any length string parameter }
- { and assign a string constant to the parameter one }
- { character at a time. }
-
- Const
- NewStr : String = '1234567890';
- { String to be assigned to param }
-
- Var
- I : Integer; { Loop control variable }
-
- Begin
- S := ''; { Initialize Parameter }
- For I := 1 to 23 Do { Copy 23 characters into param }
- S := S + NewStr[( I Mod 10 ) + 1];
- End;
-
- Begin
- FillChar( TrashedMemory, SizeOf( TrashedMemory ), #0 );
- { Init Memory to see corruption }
- FillChar( St1, SizeOf( St1 ), #0 );
- { Initialize var to be passed }
- StringAssign( St1 ); { Call the procedure }
- Writeln( St1 ); { Output the string to the screen }
- For I := 1 to ArraySize Do
- Write( TrashedMemory[I], ' ' );
- { Output the corrupted memory }
- End.