<< Click to Display Table of Contents >> Navigation: Advanced Features > Scripting > If-/ Else-/ ElseIf-Block, EndIf |
• If-Blocks can be nested.
• An If-Block must be closed by either EndIf, Else or ElseIf.
• See also: “[condition] ” below.
Examples:
value
a > b
a < b
a = b
a <= b
a >= b
a != b
a > b || c > d && e > f
•A condition is evaluated to either true or false.
•The result can be either a parsed value or a comparison of two parsed values, using one of these operators: >, <, =, <=, >=, !=
•Conditions can be combined using a logical AND (&&) or a logical OR (||).
•AND operators take precedent over OR operators, i.e. “a > b || c > d && e > f” is equivalent to “a > b || ( c > d && e > f)” – but the latter syntax with parentheses is not supported!
Syntax:
If [condition]
[condition true statements]
EndIf
If-Script Example1:
//Check if Vertex Global Variable Object "Variable1" Value equals 1000. If true, set Playback1 Transport state to Play
If Variable1.Value = 1000
Playback1.Play
EndIf
//End of Example1
If-Script Example2:
//This will write "trueA" to the Log
Set condition1=true
If condition1
Log trueA
EndIf
//End of Example2
Syntax:
If [condition]
[condition true statements]
Else
[condition false statements]
EndIf
If and Else Script Example1:
//Check if Systems1 LiveVolume is higher or equal than 0. If true, set Controlview1 LED1 to ON. If false, set Controlview1 LED1 to OFF
If System1.Volume >= 0
Controlview1.Controls.LED1.Value 1
Else
Controlview1.Controls.LED1.Value 0
EndIf
//End of Example1
If and Else Script Example2:
//This will write "falseB" to the Log
Set condition1=true
If condition1
Log trueB
Else
Log falseB
EndIf
//End of Example2
Syntax:
If [condition1]
[condition1 true statements]
ElseIf [condition2]
[condition2 true statements]
Else
[statements]
EndIf
If, ElseIf and Else Script Example1:
//Check if Vertex Global Variable Object "Variable1" Value equals 0.5. If true, set global Variable "Variable2" Value to TRUE.
//If Variable1 Value is lesser than 0.5, set Variable2 Value to False and set global Variable "Variable3" Value to "lesser".
//Else set Variable2 Value to False and set Variable3 Value to "greater".
If Variable1.Value = 0.5
Variable2 TRUE
ElseIf Variable1.Value < 0.5
Variable2.Value FALSE
Variable3.Value = "lesser"
Else
Variable2 0
Variable3.Value = "greater"
EndIf
//End of Example1
If, ElseIf and Else Script Example2:
//This will write "trueC" and "trueC2" to the Log
Set condition1=true
Set condition2=true
If condition1
Log trueC
ElseIf condition2
Log trueC2
Else
Log elseC
EndIf
//End of Example2
Syntax:
If [condition1]
If [condition2]
[condition2 true statements]
Else
[condition2 false statements]
EndIf
EndIf
Nested If Script Example1:
//Check if Controlview1 SliderButton1 is set to ON.
//If true, check if Playback1 current cue is Cue2.
//If True, set Playback1 to Play, wait 1 seconds and fade to Cue3.
//If false, goto Playback1 Cue2 and set Playback1 to Play
If ControlView1.Controls.SliderButton1.Value = 1
If Playback1.CurrentCueID = 2
Playback1.Play
Wait 1
Playback1.FadeToCue 3,0.5,1 // Fade to Cue 3. 0.5 Seconds PreloadTime, 1 Second fade Time
Else
Playback1.GotoCue 2
Playback1.Play
EndIf
EndIf
//End of Example1
Nested If Script Example2:
//This will write "trueD" to the Log
Set condition1=true
Set condition2=true
If condition1
If condition2
Log trueD
Else
Log falseD
EndIf
EndIf
//End of Example2
•Block-If and Single-Line-Else/ElseIf can be combined, with the latter closing the previous If-Block.
•A Single-Line-If cannot be followed by an Else/ElseIf-Block or Single-Line-Else/ElseIf.
Syntax:
If [condition] ? [true statement]
Single-Line If Script Example1:
//Check if Vertex Global Variable Object "Variable1" Value is true. If true, fade Sequence1 ClipContainer1 to an Opacity of 100% in 3 seconds
If Variable1 1 ? Sequence1.ClipContainer1.Opacity.FadeValue 1,3
//End of Example1
Single-Line If Script Example2:
//This will write "trueE" to the Log
Set condition1=true
Set condition2=trueIf condition1 ? Log trueE
//End of Example2
Syntax:
If [condition] ? [true statement] : [false statement]
Single-Line If Else Script Example1:
//Check if Vertex Global Variable Object "Variable1" Value is False. If True, Goto Playback1 Cue2. If False, Goto Playback1 Cue3
If Variable1 0 ? Playback1.GotoCue 2 : Playback1.GotoCue 3
//End of Example1
Single-Line If Else Script Example2:
//This will write "trueF" to the Log
Set condition1=true
If condition1 ? Log trueF : Log falseF
//End of Example2
Syntax:
If [conditionA]
[conditionA true statements]
ElseIf [conditionB] ? [conditionA true statement] : [condition false statement]
Single-Line If-ElseIf Script Example1:
//Check if PME1 MixLevel is set to 1 (100% visibility). If true, FadeIn PME2 MixLevel to 1 in 2 Seconds.
//If false, check if PME2 MixLevel is greater than 0.If True, set Variable1.Value to 1. If False, set Variable1.Value to 0
IF PME1.MixLevel = 1
PME2.MixLevel.FadeValue 1,2
ElseIf PME2.MixLevel > 0 ? Variable1 True : Variable1.Value = 0
//End of Example1
Single-Line If- ElseIf Script Example2:
//This will write "trueG" and "trueH" to the Log
Set condition1=true
Set condition2=true
If condition1
Log trueG
ElseIf condition2 ? Log trueH : Log falseH
//End of Example2
Syntax:
If [condition]
[condition true statements]
Else [condition false statement]
Single-Line and Multi-Line Combination If Else Script Example1:
//Check if the Opacity of Surface1 is lesser than 1. If True, set it to 1 and write "Done" to the log. Else set it to 0
If Surface1.Opacity < 1
Surface1.Opacity = 1
Log Done
Else Surface1 0
//End of Example1
Single-Line and Multi-Line Combination If Else Script Example2:
//This will write "trueI" to the Log
Set condition1=true
If condition1
Log trueI
Else Log falseI
//End of Example2
•[varname] is the name of the local variable that will be used for iterating; this can be accessed within [loop statements].
•[varname] must consist of word-characters (a-z,0-9) only (like all local variables).
•The local variable is not restricted to the loop block’s scope
•[start] and [finish] will be parsed as Integer values that determine the range for iterating. The expressions may not contain spaces; functions cannot be evaluated here.
•For each iteration [varname] will be increased/decreased by 1 (depending on [start] being larger/smaller than [finish].
•ExitLoop will exit the latest running loop, which means that in nested loops, it can be called several times to break out of several levels.
Loop [varname] From [start] To [finish]
[loop statements]
EndLoop
Loop Block Script Example1:
//This will move the Playhead of Playback1 from Cue1 to Cue5 in single steps with a wait time of 3 seconds in between each step.
Loop x From 1 To 5
Playback1.GotoCue x
Wait 3
EndLoop
//End of Example1
Loop Block Script Example2:
//This will write "1 2 3 4 5 6 7 8 9 10" (in individual lines) to the Log
Loop x From 1 To 10
Log x
EndLoop
//End of Example2
Syntax:
Loop [varname] From [start] To [finish]
If [condition] ? ExitLoop
EndLoop
Loop-Block with ExitLoop Script Example1:
//This will move the Playhead of Playback1 from Cue1 to Cue15 in single steps with a wait time of 3 seconds in between each step.
//The script will force the loop to Exit in Case the Controlview2 SliderButton3 value is TRUE.
Loop x From 1 To 15
If ControlView2.Controls.SliderButton3.Value = 1 ? ExitLoop
Playback1.GotoCue x
Wait 3
//End of Example1
Loop-Block with ExitLoop Script Example2:
//This will write "1 2 3 4" (in individual lines) to the Log. Stopping at 4, because condition is true
Set limit=4
Loop x From 1 To 10
Log x
If limit = x ? ExitLoop
EndLoop
//End of Example2
Nested Loop-Block with ExitLoop Script Example1:
//This will write "1 11 12 13 2 3 11 12 13 4 5 11 12 13 Finished" (in individual lines) to the Log.
Loop x From 1 To 5
Log x
Loop y From 11 To 13
If x=2
ExitLoop
ElseIf x=4
ExitLoop
EndIf
Log y
EndLoop
EndLoop
Log Finished
//End of Example1