日本語 English
株式会社ヒューリンクス
TEL:03-5642-8384
営業時間:9:00-17:30

if…then…else

関数 if...then...else は、指定した条件に応じて、2つの一連の計算のうちどちらか一方を実行します。

構文

  • if…then…else
    文:

    if condition then
    statement
    statement...
    else
    statement
    statement...
    end if
    

if…then…else 構文は、if condition に続いて、真の場合に実行する then 以下のトランスフォーム方程式の命令文 (複数の文でも可) 、そして偽の場合に実行する else 命令文 (複数の文でも可) を記述します。if…then…else 構文があると、その命令文の中にある全ての関数は他のトランスフォームとは別に評価されます。

Note: if, then とすべての条件演算子、変数および数値はスペースで区切る必要があります。

if…then…else 構文では、以下のことが可能です:

  • 一行に複数の式を記述する
  • 方程式にインデント (字下げ) を付ける
  • 別の if 構文をネストする

Note: 上記は、if…else 文内でのみ可能です。if…then…else 文内で変数名を再定義することはできません。

  • 次の演算では:
    i = cell(1,1)
    j = cell(1,2)
    If i < 1="" and="" j=""> 1 then x = col(3)
    else x = col(4)
    end if

    もし i が 1 よりも小さく、かつ、j が 1 より大きい場合には、x に列3を代入し、そうでない場合は、列4を代入します。

if…then…else

The if…then…else function proceeds along one of two possible series of calculations based on a specified condition.

Syntax

  • if condition then
    statement
    statement...
    else
    statement
    statement...
    end if
    

To use the if…then…else construct, follow the if condition then statement by one or more transform equation statements, then specify the else statement(s). When an if…then…else statement is encountered, all functions within the statement are evaluated separately from the rest of the transform.

Note: You must separate if, then, and all condition statement operators, variables, and values with spaces.

Inside if…then…else constructs, you can:

  • Type more than one equation on a line
  • Indent equations.
  • Nest additional if constructs.

Note that these conditions are allowed only within if…else statements. You cannot redefine variable names within an if…then…else construct.

Example

  • The operations:
    i = cell(1,1)
    j = cell(1,2
    If i < 1 and j > 1 then x = col(3)
    else x = col(4)
    end if

sets x equal to column 3 if i is less than 1 and j is greater than 1; otherwise, x is equal to column 4.