pascal 使用
学delphi这前要先一些pascal基础.但是对pascal的基本用法如何在delphi环境下应用.如验证两整数交换.可如下:uses
type point=^integer;
var
p:point;
a,b,c:integer;
begin
a:=100;
b:=50;
p:=@a;
c:=p^;
p^:=b;
b:=c;
end.
请问如何在delphi运行..
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
point=^integer;
TForm1 = class(TForm)
Edit1: TEdit;
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
p:point;
a,b,c:integer;
begin
a:=100;
b:=50;
p:=@a;
c:=p^;
p^:=b;
b:=c;
edit1.text:=inttostr(b);
end;
end.
上面我在form中增加了一個edit1為你顯示數據,變量就看你是要它為全局變量還是局部變量,在這裡我是將它做局部變量用的