L’interface de VDS Renaissance est disponible en plusieurs langues. La documentation officielle est maintenue en anglais afin de garantir une référence unique, cohérente et toujours à jour.

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