Basic Pascal Tutorial/Chapter 1/Constants/ja: what changed
Revision 0 to 1. Removed lines have a minus sign; added lines have a plus sign.
Title: Basic Pascal Tutorial/Chapter 1/Constants/ja
| Old | New | Line | |
|---|---|---|---|
| 1 | + | 1C - 定数 (著者: Tao Yue, 状態:オリジナルのまま) | |
| 2 | + | ||
| 3 | + | 定数は識別子によって参照され、プログラムの最初にひとつの値に割り当てられる。定数に割り当てられ値は変更できない。 | |
| 4 | + | ||
| 5 | + | 定数はプログラムの定数セクションで定義される。 | |
| 6 | + | ||
| 7 | + | ``` pascal | |
| 8 | + | const | |
| 9 | + | Identifier1 = value; | |
| 10 | + | Identifier2 = value; | |
| 11 | + | Identifier3 = value; | |
| 12 | + | ``` | |
| 13 | + | ||
| 14 | + | たとえば、様々なデータタイプ(文字列型、文字型、整数型、実数型、論理型)の定数を定義してみよう。これらのデータイプについては次のセクションでさらに説明する。 | |
| 15 | + | ||
| 16 | + | ``` pascal | |
| 17 | + | const | |
| 18 | + | Name = 'Tao Yue'; | |
| 19 | + | FirstLetter = 'a'; | |
| 20 | + | Year = 1997; | |
| 21 | + | pi = 3.1415926535897932; | |
| 22 | + | UsingNCSAMosaic = TRUE; | |
| 23 | + | ``` | |
| 24 | + | ||
| 25 | + | Pascal では文字型はシングルクォート、あるいはアポストロフィで囲む。これはダブルクォーテーションやヒアドキュメント記法(heredoc)を許すより新しい言語とは対照的である。標準的な Pascal は文字や文字列を示すのにダブルクォーテーションを用いないし、またそれは許されていない。 | |
| 26 | + | ||
| 27 | + | 定数はプログラムを通して使われるが、将来変更するかもしれない値を定義するのに便利である。すべての値を変更する代わりに、ただ定数の定義を変更すればよいのである。 | |
| 28 | + | ||
| 29 | + | タイプ化された定数は、特定のデータ・タイプの定数と限定される。たとえば、以下の例では整数値12の代わりに実数値12.0を含む定数が作られる。 | |
| 30 | + | ||
| 31 | + | ``` pascal | |
| 32 | + | const | |
| 33 | + | a : real = 12; | |
| 34 | + | ``` | |
| 35 | + | ||
| 36 | + | | | | | | |
| 37 | + | |----|----|----| | |
| 38 | + | | [[Basic Pascal Tutorial/Chapter 1/Identifiers/ja|previous]] | [[Basic Pascal Tutorial/Contents/ja|contents]] | [[Basic Pascal Tutorial/Chapter 1/Variables and Data Types/ja|next]] | | |
| 39 | + | ||
| 40 | + | --- | |
| 41 | + | *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](/wiki-contact).* |
