====== Control Structures ====== When a macro is called, all its steps are executed sequentially. However, you can define conditional steps - steps which are only executed if a condition is met. In order to do this, simply give the step a condition property, like in [[macros:example:doublechasespeed|]]: ActionScript.SetProperty.Float("Playbacks.Editor.Times.ChaseSpeed", 1.0) **At the moment (version 10.0 and 10.1) it looks like such conditions are stripped when a macro is copied in Titan. Hence, always __move__ macros with conditions (which has the backdraw that you can have a macro only on one handle.** This step is only executed if its condition is met - and the condition is a function written in double quotes: [[macros:function:math.isequal]] takes two values as arguments and returns true if both values are equal. In total, if the property ''Playbacks.Editor.Times.ChaseSpeed'' equals 0.0 then this step is performed and sets this property to 1.0. Another mechanism is also related to control structures albeit strictly it is just juggling with booleans: simple toggle logic, see [[macros:example:timecodeonoff|]]: ActionScript.SetProperty.Boolean("Timecode.Enabled", !Timecode.Enabled) This simply negates a variable, effectively turning it into its reciprocal value: if the variable 'Timecode.Enabled' is true it will be set to false, and vice versa. There are also some other syntax versions: { if(Math.IsNotEqual(Playbacks.Editor.Times.ChaseSpeed, 0.0)) { ** Do Something ** } else { ActionScript.SetProperty.Float("Playbacks.Editor.Times.ChaseSpeed", 1.0); } } and as of version 10, it is possible to write conditions in a more modern way: { if(Playbacks.Editor.Times.ChaseSpeed == 0.0) { ActionScript.SetProperty.Float("Playbacks.Editor.Times.ChaseSpeed", 1.0); } } **It appears that the else hive must not be empty. If it is empty then Titan doesn't start, and the Log Viewer complains "Compliation of action script failed:... Unexpected token '' found." ** (The typo is courtesy of the Log Viewer :-) ) If you only need the if hive, then omit the else altogether. Also see an example here: [[macros:example:dummyspeedascondition|]] ~~NOCACHE~~ {{page>macros:formats_and_syntax#further_readings}} ~~DISCUSSION~~