Data AcQuisition And Real-Time AnalysisScope - Spectrum - Spectrogram - Signal Generator
Software for Windows
Science with your Sound Card!
Contact us about
MIDI Changes Script IF Statements
Changes: [condition ... | ... ]
IF statements allow MIDI Changes scripts to execute commands or groups of commands conditionally, as in conventional programming languages.
A simple IF statement begins with [ followed immediately by the conditional statement such as UA=1. Any number of commands may follow, on any number of lines, that will be executed if the conditional statement is true. The IF statement can then end with ].
An IF...ELSE statement is just like the above, except that after all the commands that are to be executed if the condition is true, you use | (SHIFT+Backslash) to indicate ELSE, followed by all the commands to be executed if the condition is false. Note that the | should be preceded by a space to prevent confusion with the bitwise or logical OR operators in an expression. As above, the IF...ELSE statement ends with ].
The conditional statement can have any valid expressions (including current MIDI control values, random values, current computer keyboard states or mouse position, input or buffered notes, oscillators, and User Variables) on the left and right sides of the condition operator. The condition operator may be =, != (not equal), > (greater than), < (less than), >= (greater or equal), or <= (less or equal).
Note that this is unlike the Daqarta macro IF, which always requires an initial =:
Macro MIDI = = Equal =! != Not equal => > Greater than =< < Less than =>= >= Greater than or equal to =<= <= Less than or equal to
Complex statements can be made more legible by assigning the left and right sides to User Variables ahead of time, so that the statement itself has the form [UX>=UY I2=43]
IF statements normally test only numeric values. You can't test multi-character strings directly, but you can test if a variable is equal to a single character as in [UK="?". This approach is used in GlossyFish (and related) Percussion scripts to test for user keyboard entry.
IF and IF...ELSE statements can be nested up to 8 levels deep, though you can have as many as you want at each level. If you attempt to go beyond 8 levels, the Changes debugger will report "Too many nested IF levels" for that script and will prevent it from running.
Questions? Comments? Contact us!We respond to ALL inquiries, typically within 24 hrs.
Over 35 Years of Innovative Instrumentation
© Copyright 2007 - 2021 by Interstellar Research
All rights reserved