home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Delphi Programming Unleashed
/
Delphi_Programming_Unleashed_SAMS_Publishing_1995.iso
/
chap15
/
pcharfun
/
main.pas
< prev
next >
Wrap
Pascal/Delphi Source File
|
1995-03-20
|
999b
|
57 lines
unit Main;
{ Program copyright (c) 1995 by Charles Calvert }
{ Project Name: }
{ This program demonstrates how to retrieve a
PChar from a function. The key point is that
you should never allocate memory for the PChar
from inside the called function, but should
first allocate memory, pass the string to a
function, and then change the string that
has been passed in. }
interface
uses
WinTypes, WinProcs, Classes,
Graphics, Forms, Controls,
StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Edit1: TEdit;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
uses
SysUtils;
{$R *.DFM}
procedure GetDate(Date: PChar);
begin
StrCopy(Date, '11/01/94');
end;
procedure TForm1.Button1Click(Sender: TObject);
var
S: array[0..100] of char;
begin
GetDate(S);
Edit1.Text := S;
end;
end.