PDA

View Full Version : Can a function take an undetermined amount of clips with properties?


StifflerStealth
18th December 2007, 19:58
Hi,

I would like to write a function that can take any number of clips, but each clip has it's own set of properties that need to be associated with it. They are the same type of properties for each clip, but they can be different values. I need to name each variable because they can all be optional, so I need to set defaults for them.

I was thinking that an array would be needed for this, right? I was also thinking it would need to be an array of arrays. So that the format would be something like.
My_Function([clip1,prop1,prop2],[clip2,prop3]....)

Something like that. I would need to go through and store the values in the correct order, though. Or the person could enter a value for each of the variables.

However, I do not know how I would set this up. How can I have an array with a length determined by the user, get the size of that array and then process it? Is this even possible in scripting? I did a search for this, but I only found references to DLLs having this ability.

Thanks.

IanB
18th December 2007, 21:53
Functions may have optional arguments by putting quotes around the argument name.

Function arguments can be of type "Val" to accept any type in the call.

Use the Defined() and Default() to test if the Arg was provided and give it a default value.

Arrays are not exposed in the scripting language, so you will need to provide enough arguments to cater for the maximum call case.

Also the argument list as well as the Name defines the function name entry so you can overload a given function name with versions with different argument lists. i.e. a 1 clip version and a 2 clip version, ... and a 10 clip version.