VDS Renaissance 的界面提供多种语言。官方文档以英语维护,以确保提供统一、一致且始终最新的参考。

IF

Windows Linux macOS

Syntax

IF <string>

... commands executed if <string> is not null (true)

{ ELSIF <string2>

... commands executed if <string> is null (false) and <string2> is not null (true) }

{ ELSE

... commands executed if both <string> and <string2> are null (false) }

END

Description

The IF command allows conditional execution of commands in a script. The <string> is evaluated and if the resulting string is non-null this is treated as true. If the result is null this is treated as false, and the next ELSIF command (if present) is evaluated. If no ELSIF commands are present, or none of them evaluate to true, the commands between ELSE and END (if ELSE is present) are executed.

The ELSIF command (else if) behaves just like an IF command and its <string2> is evaluated if (and only if) the previous IF or ELSIF was false. If <string2> is true (not null) then the commands between the ELSIF and the next ELSIF, ELSE or END are executed. An IF command may contain any number of ELSIF commands.

The ELSE marks the start of the commands that are executed if none of the previous sections of the IF command were true. This section, and the ELSIF sections, are optional. The minimum format for a valid IF command is IF followed by END.

IF commands may be nested. If this is done then it is important to ensure that the correct ELSE and END commands are not omitted. For clarity it is a good idea to indent the nested IF commands as shown in the example.

OK

Unchanged.

Example

IF @ask(Do you want to continue?)
  info You answered YES
ELSIF @ask(Are you sure?)
  info "You answered NO and then YES"
ELSE
  info Make your mind up!
END

See also