• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

delphi 学习笔记

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

只是简单的c和delphi对照,这样学的很快,笔记记得很随性,只是为了看点小代码,有帮助就看看吧,delphi 已经差不多没落了。

 

1.object pascal 语法

 

一.首先是main函数

Program first;  {program name}

var a:integer;  {varent declare}

begin           {program sub}

    Writeln('this is nextline write');

    write('this will not change line');

    Readln;

    Readln(a);

    Readln;   {here can del the ';'}

end.          {must have '.'}

 

二.然后是数据类型和变量的声明

(1) 整型

int          --->      Integer

usigned int  --->      Cardinal

short        --->      Smallint

char         --->      Shortint

long         --->      Longint       {this is depend on the compiler}

int64        --->      Int64

BYTE         --->      Byte (usigned)

WORD         --->      Word (usigned)

DWORD        --->      Longword (usigned)

8位          --->      Real

 

(2) 字符

CHAR         --->      Char

char         --->      AnsiChar

wchar        --->      WideChar

 

(3) 字符串

char*        --->      PChar

int* a       --->      var a:^integer

a = &b       --->      a = @b

*a           --->      a^

 

(4) 逻辑

BOOLEAN      --->      Boolean

                       ByteBool

                       WordBool

                       LongBool

 

(5) 运算符

/   --->  div

!=  --->  <>

&&  --->  and

%   --->  mod

 

(6)结构体

fuck  ,the type can instead of struct and enum,for example

 

type color=(red,white,black);

 

type

    a:Integer;

    name:PChar;

    age:Integer;

end;

 

(7)#define

you know , delphi can use  const NUM=$1 to instead of #define NUM 0x1

#define LANG_NEUTRAL 0x00  ---> const LANG_NEUTRAL=$00

 

 

三、条件和循环

if xx

then

    xxx

 

 

if xx

then

    xxx   {这个地方不要分号}

else

    xxx;

上面这两种写法只能适合于单条语句,如果要写几行语句需要这样

if xx

then

    begin

        xxx;

        xxx           {在begin和end间,最后一句可以不加;}

    end;

else

    begin

        xxx;

        xxx

    end;

 

 

case n of

    1:xxx;

    2,3:yyy;

    4: mmm;   

    6..9: ccc     {同理 这个地方可以不加分号}

end;

 

 

while xxx do

begin

 

end;

 

reapet 

inc(a)

untill xx>10

 

for  x:= num1 to num2  do

begin

 

end;

 

四、 常用函数

int(a) 取a的整数部分

pi     π的取值

random  产生0~1的随机数

random(n) 产生0~n的随机数

round(n) 求n四舍五入后的整数

trunc(n) 取小数的整数部分

inc(a,n)/inc(a)  自增,等价于 a := a+n

dec....          自减,同上

 

 

五、输入输出

Writeln(2:3)   空3格输出2

Writeln('2=',3) 输出2=3

Readln   ---> getchar()

 


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap