Subroutines
on (value...)
Additional Notes
the subroutine has to be defined in the code before it is called, or you'll get a look of blank incomprehension from the parser.
This one will not result in type errors:
on doSomething(string a_string, value a_value)
...
end;
...
doSomething("the text", 1.2);
Although I can't find a way to be able to pass other types as a constant. (It did not mind the string argument, actually)
Subroutines are limited to 15 parameters. If a subroutine declaration has more than 15 parameters, FCP crashes immediately upon running the script. I haven't found this documented anywhere.
This works [declarations are one line]:
on ftest(value a1,value a2,value a3,value a4,value a5,value a6,value a7,value a8,value a9,value a10,value a11,value a12,value a13,value a14,value a15)
//
end
This doesn't:
on ftest(value a1,value a2,value a3,value a4,value a5,value a6,value a7,value a8,value a9,value a10,value a11,value a12,value a13,value a14,value a15, value a16)
//
end


if you have a subroutine such as
on doSomething(string subString, float subFloat, color theColour)
[do something]
end
you can't call it as follows
doSomething("hello", 1.234, {255,255,0,0}}
calling the string like this will result in a type-mismatch error. instead you have to pass it pre-declared variables that have had their values assigned eg:
string theString;
float, theFloat;
color theColour;
theString="hello"
theFloat = 1.234
theColour = {255,255,0,0}
doSomething(theString, theFloat, theColour);