Sign in Join
Wiki copytemporary

Basic Pascal Tutorial/Chapter 1/Constants/ja

한국어 · Deutsch · English · Français · Italiano · Български · Русский · 中文(中国) · 日本語

1C - 定数 (著者: Tao Yue, 状態:オリジナルのまま)

定数は識別子によって参照され、プログラムの最初にひとつの値に割り当てられる。定数に割り当てられ値は変更できない。

定数はプログラムの定数セクションで定義される。

pascal
const
  Identifier1 = value;
  Identifier2 = value;
  Identifier3 = value;

たとえば、様々なデータタイプ(文字列型、文字型、整数型、実数型、論理型)の定数を定義してみよう。これらのデータイプについては次のセクションでさらに説明する。

pascal
const
  Name = 'Tao Yue';
  FirstLetter = 'a';
  Year = 1997;
  pi = 3.1415926535897932;
  UsingNCSAMosaic = TRUE;

Pascal では文字型はシングルクォート、あるいはアポストロフィで囲む。これはダブルクォーテーションやヒアドキュメント記法(heredoc)を許すより新しい言語とは対照的である。標準的な Pascal は文字や文字列を示すのにダブルクォーテーションを用いないし、またそれは許されていない。

定数はプログラムを通して使われるが、将来変更するかもしれない値を定義するのに便利である。すべての値を変更する代わりに、ただ定数の定義を変更すればよいのである。

タイプ化された定数は、特定のデータ・タイプの定数と限定される。たとえば、以下の例では整数値12の代わりに実数値12.0を含む定数が作られる。

pascal
const
  a : real = 12;
previous contents next

From the Free Pascal wiki, page "Basic Pascal Tutorial/Chapter 1/Constants/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 3 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
Derakun
Derakun
Derakun
TrevFixed syntax highlighting (minor)
Kai BurghardtKai Burghardt moved page Constants/ja to Basic Pascal Tutorial/Chapter 1/Constants/ja: tidy up main name space: create subpage hierarchy for basic Pascal tutorial [cf. [[Special: PermaLink/149778#Clut... (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.