Difference between revisions of "Basic Pascal Tutorial/Chapter 1/Constants/ja"

From Free Pascal wiki
Jump to navigationJump to search
(Created page with "{{Constants}} 1C - Constants (author: Tao Yue, state: unchanged) Constants are referenced by identifiers, and can be assigned one value at the beginning of the program. The ...")
 
Line 1: Line 1:
{{Constants}}
+
{{定数}}
  
1C - Constants (author: Tao Yue, state: unchanged)
+
1C - 定数 (著者: Tao Yue, 状態:オリジナルのまま)
  
Constants are referenced by identifiers, and can be assigned one value at the beginning of the program. The value stored in a constant cannot be changed.
+
定数は識別子によって参照され、プログラムの最初にひとつの値に割り当てられる。定数に割り当てられ値は変更できない。
  
Constants are defined in the constant section of the program:
+
定数はプログラムの定数セクションで定義される。
 
<syntaxhighlight>
 
<syntaxhighlight>
 
const
 
const
Line 12: Line 12:
 
   Identifier3 = value;
 
   Identifier3 = value;
 
</syntaxhighlight>
 
</syntaxhighlight>
For example, let's define some constants of various data types: strings, characters, integers, reals, and Booleans. These data types will be further explained in the next section.
+
たとえば、様々なデータタイプ(文字列型、文字型、整数型、実数型、論理型)の定数を定義してみよう。これらのデータイプについては次のセクションでさらに説明する。
 
<syntaxhighlight>
 
<syntaxhighlight>
 
const
 
const
Line 21: Line 21:
 
   UsingNCSAMosaic = TRUE;
 
   UsingNCSAMosaic = TRUE;
 
</syntaxhighlight>
 
</syntaxhighlight>
Note that in Pascal, characters are enclosed in single quotes, or apostrophes (')! This contrasts with newer languages which often use or allow double quotes or Heredoc notation. Standard Pascal does not use or allow double quotes to mark characters or strings.
+
Pascal では文字型はシングルクォート、あるいはアポストロフィで囲む。This contrasts with newer languages which often use or allow double quotes or Heredoc notation. Standard Pascal does not use or allow double quotes to mark characters or strings.
  
 
Constants are useful for defining a value which is used throughout your program but may change in the future. Instead of changing every instance of the value, you can change just the constant definition.
 
Constants are useful for defining a value which is used throughout your program but may change in the future. Instead of changing every instance of the value, you can change just the constant definition.

Revision as of 09:28, 8 July 2015

Template:定数

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

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

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

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

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

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

Pascal では文字型はシングルクォート、あるいはアポストロフィで囲む。This contrasts with newer languages which often use or allow double quotes or Heredoc notation. Standard Pascal does not use or allow double quotes to mark characters or strings.

Constants are useful for defining a value which is used throughout your program but may change in the future. Instead of changing every instance of the value, you can change just the constant definition.

Typed constants force a constant to be of a particular data type. For example,

const
  a : real = 12;

would yield an identifier a which contains a real value 12.0 instead of the integer value 12.

previous contents next