program Project1;
{$APPTYPE CONSOLE}
uses
SysUtils;
Const //定义常量
author='who';
perpertys='what';
PI=3.1415926;
var
area:Real; //定义变量
i:Integer;
begin
Writeln(author+''+perpertys); //调用常量
area:= PI*3*3 ; //调用变量
Writeln(area);
i:=10;
while(i>0) do //while循环
begin
Writeln(i);
i:=i-1;
end;
for i:=0 to 10 do //for循环
begin
Writeln(i);
end;
if(i>0) and (i<>10) then //if then else
begin
Writeln(i);
end;
else
begin
Writeln(i+'i小于0') ;
end;
//exit语句的功能:退出当前代码块
//halt语句的功能:终止程序的执行
Readln;
end.
// 程序结构、
// unit unit1{单元名}
// interface {接口部分}
// uses{引用部分}
// type {类型区段}
// private
// {私有成员}
// public
// {公共成员}
// end;
// var{变量定义区}
// {定义成员变量}
// implementation{实现部分}
// {$R *.dfm}
// ....
// end.
//字符串处理函数
{
LowerCase(const S:string):string;
UpperCase(const s:string):string;
CompareStr(const s1,s2:string):Integer; 大于返回大于0的数,小于返回小于0,等于返回等于0 区分大小写
CompareText(const s1,s2:string):Integer; 不区分大小写
AppendStr(var Dest:string;const s:string)//合并字符串
concat(s1,s2...sn:string) :string 合并多个字符串
Pos(substr:stirng;s:string):Integer; 字符串查找,返回位置 ,如果不存在返回0
length(s:string):Integer 求字符串长度
Copy(S;Index,count):string 字符串截取
Delete(s;index,count) 删除字符串中索引位置
Inset(source;String;var s:string;index:Integer) 字符串source插入到字符串的s中index后面
}
{数字和字符串的转换
inttostr
floattostr
val用于将字符串转换为数值数据
strtoint
strtofloat
inttoHex(value:Integer;Digits:Integer):string; 10进制装换为16进制
}
{
Ascii转换字符
chr(x:Byte):Char;
}
{
格式化函数
Format(Const Format:string;Const Args:Array of Const)
}