易截截图软件、单文件、免安装、纯绿色、仅160KB

Delphi 关键字详解

 absolute
//它使得你能够创建一个新变量, 并且该变量的起始地址与另一个变量相同.
var
Str: string[32];
StrLen: Byte absolute Str;
//这个声明指定了变量StrLen起始地址与Str相同.
//由于字符串的第0个位置保存了字符串的长度, 所以StrLen的值即字符串长度.
begin
Str := 'abc';
Edit1.Text := IntToStr(StrLen);
end;
abstract
//它允许你创建抽象的方法, 包括有抽象方法的类称为抽象类.
//Abstract关键字必须与Virtual或Dynamic关键字同时使用, 因为抽象方法必须被覆盖式实现.
//抽象类不能实例化, 抽象方法不能包含方法体.
type
TDemo = class
private
protected
procedure X; virtual; abstract;
public
constructor Create;
destructor Destroy; override;
published
end;
and
//一、表示逻辑与
if (a>0) and (b>0) then
//二、表示位运算
var
a,b,c: Integer;
begin
c := (a and b);
end;
//使用And表示逻辑时, And左右的表达式必须用小括号括起, 以避免以生条件的冲突.
//例如:
if a>0 and b>0 then
//编译器可能会理解为:
if a>(0 and b)>0 then
//或:
if (a>0) and (b>0) then
//但是实际编译时, 编译器会产生一个冲突, 报告错误.
//并且第一种可能包含了a>b>c的形式, 这在Delphi中不被支持.
//所以使用And运算符时必须使用括号, 以区分左右的条件.
//表示位运算时也必须加上括号, 将And以及左右参数括起.
array
//Array用于表示数组, 任何的对象都能被声明成数组.数组分为静态和动态的2种.
//静态数组
var
Arr1: array [1..10] of Integer;
//动态数组, 由于声明时不知其元素个数, 所以必须在后期用SetLength方法设置数组的大小
var
Arr2: array of Integer;
//数组作为参数时, 不能传入数组的大小, 只能传入数组名, 然后用Length方法获取数组的元素个数
function X(A: array of Integer): Integer;
var
i: Integer;
begin
Result := 0;
for i := 0 to Length(A)-1 do
Result := Result + A[i];
end;
as
//As用于将一个对象转换为另一个对象
procedure BtnClick(Sender:TObject);
begin
(Sender as TButton).Caption := 'Clicked';
end;
//对于对象填充接口的转换, 必须用As进行
(HTTPRIO as IExp).GetConnection;
//As不能用于数据类型的转换, 下面的代码


相关文档:

如何让Delphi调用外部程序并等待其运行信息(如结束)

函数一:
view plaincopy to clipboardprint?
uses 
    Windows,  
    SysUtils,  
    Classes,  
    ShellAPI;  
function RunAndWait(FileName: string; Visibility: Integer): THandle;&nbs ......

Delphi 函数大全

名称 类型 说明  
abort 函数 引起放弃的意外处理  
abs 函数 绝对值函数  
addexitproc 函数 将一过程添加到运行时库的结束过程表中  
addr 函数 返回指定对象的地址  
adjustlinebreaks 函数 将给定字符串的行分隔符调整为cr/lf序列  
align 属 ......

一个delphi程序员的开发习惯

                                                   ......

delphi string类型转integer时出错的检测

procedure TForm1.Button1Click(Sender: TObject);
Var
  Num: Integer;
Begin
  Try
    Num:=StrToInt(Edit1.Text);
    Edit2.Text:=IntToStr(Num*Num);
  Except
    On EConvertError Do   ShowMessage(Edit1.Text+'无法转成整数!'); ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号