Sign in Join
Wiki copytemporary

Basic Pascal Tutorial/Chapter 5/Records/ja

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

5E - レコード型 (著者: Tao Yue, 状態: 原文のまま変更なし)

レコード型を使えば、関連したデータ項目をひとつの構造に収めておける。ある人について情報が欲しいとき、名前、年齢、都市、州、そして郵便番号が知りたいかもしれない。

レコード型を宣言するためには、以下のようにする。

pascal
TYPE
  TypeName = 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
WITH ????????????????????? DO
BEGIN
  ...
END;

たとえば、次のようになる。

pascal
with Info do
begin
  age := 18;
  zip := 90210;
end;
previous contents next

From the Free Pascal wiki, page "Basic Pascal Tutorial/Chapter 5/Records/ja", 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 4 people, 2015–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
DerakunCreated page
Derakun
FTurtletemplatename has not suffix
TrevFixed syntax highlighting (minor)
Kai BurghardtKai Burghardt moved page Records/ja to Basic Pascal Tutorial/Chapter 5/Records/ja: tidy up main name space: create subpage hierarchy for basic Pascal tutorial [cf. [[Special: PermaLink/149778#Clutteri... (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.