4D v16変数の概要 |
|||||||||||||||||||||||||||||||||||||||||||||
|
4D v16
変数の概要
|
ステージ | 通常の変数 | 配列 | コメント |
初期化 | C_LONGINT(NumDays) | ARRAY TEXT(ArrayDates;0) | Unicodeモードでは文字型とテキスト型に違いはありません |
INSERT IN ARRAY(ArrayDates;1) | |||
ArrayDates{1}:=!06/05/2012! | |||
値の代入 | NumDays:=25 | または | |
APPEND TO ARRAY(ArrayDates;!06/05/2012!) | |||
使用 | For($i;1;NumDays) | $StartDate:=ArrayDates{1}+18 | 変数を読み書き |
End for | |||
メモリから消去 | CLEAR VARIABLE(NumDays) | CLEAR VARIABLE(ArrayDates) | 変数は存在していますが、内容は初期化されています |
例題でこのことを確認してみましょう:
変数の名前を決定する際には、一貫性を持たせた命名規則を先に決定し、プロジェクト全体でその規則に従うべきです。
読みやすく、役割を理解しやすい名前を付けるべきです。後で名称を変更したくなった時は、グローバルな名称変更機能を使用できます (デザインリファレンスの "デザインモードの検索と置換" を参照ください)。
他の言語と同様、変数は4Dにとって不可欠です。必要な時には遠慮なく使用してください。
以下の変数は言語上存在しても、フォームには表示できない点に留意してください:
In the previous video, we used a variable to display the number of records found according to the table where the search was performed.
In fact, a variable is a space in memory that we can represent by an object in a form.
So we're going to create a test project form called "test variables" in order to show how variables work.
Let's create a first variable named v1 and that we'll make non-enterable. This variable does not actually exist in memory; there is just an area on screen that represents the contents of the variable if and when it exists.
We're going to:
We're going to display an alert that expects an argument of the text type so we're going to convert variable v1 after multiplying it by 12.
Now let's test the form:
Here is the first use of a simple variable.
The principle is the same with:
If we test the form:
4D includes many functions for processing strings.
Let's take the case of an array.
To assign values to the array, we're going to indicate that:
As concerns the use of the array, we can do it as shown here for example:
1st array value + a space + 2nd array value + 3rd array value.
Now let's test the result:
So there we have it, a simple and quick overview of how to use variables.
プロダクト: 4D
テーマ: 変数の概要
セルフトレーニング ( 4D v16)