Sign in Join
Wiki copytemporary

Basic Pascal Tutorial/Chapter 5/Records/zh CN

Sent here from Records/zh CN.

English · Français · Български · 中文(中国) · 日本語

5E - 记录类型 (原作者: Tao Yue, 状态: 未更改)

记录类型允许你将多个数据类型组成一个数据类型。假设你想存储一个人的信息,它会包含姓名、年龄、城市、区域、国家、邮编等信息。

你可以这样来声明记录类型:

pascal
TYPE
  ??????????????? = record
    ?????????1 : ??????1;
    ...
    ?????????n : ??????n;
  end;

如:

pascal
type
  InfoType = record
    Name : string;
    Age : integer;
    City, State : String;
    Zip : integer;
  end;

Name、Age、City、State和Zip这些标识符,被称为字段。通过变量名来使用这些字段:

pascal
 ???????????????.???????????????

使用点(.)来分隔变量名和字段名。

定义记录类型变量:

pascal
 VAR
 ???????????????:???????????????;

在处理记录数据类型时,如果一个记录字段很多,你得一个一个的输入变量名,这样很繁琐。

你可以只使用字段标识符。像这样:

pascal
WITH ??????????????? DO
BEGIN
  ...
END;

如:

pascal
with Info do
begin
  Age := 18;
  ZIP := 90210;
end;
上一页 目录 下一页

From the Free Pascal wiki, page "Basic Pascal Tutorial/Chapter 5/Records/zh CN", as it stood on 2022-08-20 after a change by Kai Burghardt, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's Licensing page. If you have concerns about this material, message the admin.

Revision 1, last changed by WikiArchive .

Edited on wiki.freepascal.org by 5 people, 2013–2022

From the official wiki's backup of 26 May 2024: who edited this page there, and when. Edits made there after that date were not recorded, and the earlier versions are not shown here; the main page says why.

WhenWhoWhat changed
WangyouworldCreated page
Swen (minor)
Wangyouworld
FTurtle
TrevFixed syntax highlighting; removed categories included in template (minor)
Kai BurghardtKai Burghardt moved page Records/zh CN to Basic Pascal Tutorial/Chapter 5/Records/zh CN: tidy up main name space: create subpage hierarchy for basic Pascal tutorial [cf. [[Special: PermaLink/149778... (minor)
Kai Burghardtbypass redirects [cf. discussion]
Kai Burghardtbypass [previously missed] redirect [cf. discussion]
Kai Burghardtbypass language bar/categorization template redirect [cf. discussion] (minor)

Talk about this page

Nobody has opened a bench for this page yet. Sign in to open one.