注释三种方法:
a、{ 注释 } b、 (* 注释 *) c、//注释
变量声明:
var i:integer; var X,Y:Real;
符号常量声明
const PI=1000; HH: integer=100;
声明文件和数组
F:File of TCurveData;
Data:array of TCurveData;
运算符
算术运算符:+,-,*,/,div,mod 其中,/是浮点除,结果为实数。div是整除,只能是整数。mod取模,只能是整数。
逻辑运算符
not,and,or,xor 其中,and逻辑与,or逻辑或,xor逻辑异或,not逻辑取反。返回值为true或false。
关系运算符
=,<>,<,>,<=,>= 判断不等使用<>,C语言中使用!=.
赋值运算符
i := i+1; Edit1.Text:='Hello'; //delphi中:=为赋值符号,=为判断是否相等。
条件语句
if语句
begin
if (i mod 39)=0 then
memo1.lines.add(inttostr(i));
end.
var x,y:integer;
begin
if x>0 then
y:=2*x;
else
y:=1-2*x;
writenln('y=',y);
end.
case语句
case i of
1:writeln('one');
2:writeln('two');
3:writeln('three');
else
writeln('other number');
end;
循环语句
for循环
begin
DT:=0.01;
for I:=-500To 500 do
begin
X:=DT*I;
Y:=10*cos(4*X);
Chtcurve.series[0].AddXY(X,Y);
end;
repeat和while..do循环
repeat
循环体;
until(循环条件;)
while (循环条件) do
begin
循环体;
end;
常用语句
1:Memo2.lines.add(floattostr(K)); //将实型K值转换为字符型,再添加到memo2中。
2:x:=strtoint(edit1.text); //将edit1中的字符串转换为整形赋值给变量x。
3:delphi时间提取:label5.Caption:=datetimetostr(now); //timer组件
时间停止:timer1.enabled:=false;
时间开始:timer1.Enabled :=true;
4:power(x,n) 指x的n次方