Variables
Variable is essentially a name for a location in memory. Variable in the program used to store a particular value where that value can vary. Each variable has a type and only the data of the same type with the type of variables that can be stored in variables. Each variable has a name and the separation between the variables is done by giving a comma.
Example:
namabarang: string;
Before a variable can be used, the variable must be declared in advance with the variable name and data type. Variables declared in the section that begins with var as the example above.
Var keyword is used in several places in the code, such as at the beginning of the unit to define global variables as well as at the beginning of a function or procedure to determine the local variables.
Variable naming rules in Delphi:
- Variable names of up to 63 characters.
- The variable name must contain only letters, numbers, underscores (_) and should not be preceded by the numbers
- May not use the keyword belongs to Delphi, for example, the variable with the name of if, else, for not allowed.
Constants
In contrast to the variable whose contents can be changed during program execution takes place, the value of a constant can not be changed. Constants can be declared without any data type should be included. The compiler will look at the data and will automatically use traditional data types accordingly. Such as variables, constants in the code can serve as a global and local constants. To declare constants as follows:
Const
Max: 100;
discount: 0.2;
pi: 3.14;
0 komentar:
Post a Comment
"Thank you for visiting and reading this article. May be useful. Do not forget to leave a message buddies as a sign of friendship between human beings visit + inter-blog. . ."
Terima kasih telah berkunjung dan membaca artikel ini. Semoga bermanfaat. Jangan lupa tinggalkan pesan sobat sebagai tanda kunjungan silaturahmi antar umat manusia + antar blog . . .