FORUMS: list search recent posts

Scripting Newb Question: Why isn't this wrapped in a function?

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Jim Huffaker
Scripting Newb Question: Why isn't this wrapped in a function?
on May 27, 2016 at 3:40:43 pm

I'm pretty new to scripting. I've only actually written one simple script so far. As I've studied other scripts, I find that the code below is repeated at the head of numerous different functions. Why don't people wrap this in it's own function? Is it slower that way? Does it make it harder to terminate the script? Or is it just easier to just copy and paste this kind of code? I'm just curious because it seems people who do this kind of thing for a living would make more sophisticated scripting choices. Maybe?

if ((activeItem == null) || !(activeItem instanceof CompItem))
{
alert("Please select or open a composition first." , scriptName);
}else{
//actual function code
{


Return to posts index

Xavier Gomez
Re: Scripting Newb Question: Why isn't this wrapped in a function?
on May 27, 2016 at 5:09:25 pm

Writing a function for that won't make it slower.
Most scripts samples you find on the net are in user-to-user forums, hence written in a way everybody can understand. If on your side you want to write it differently, feel free. In the end, you'll still need to handle the case where the active item (or whatever input the script requires) is what it is expected to be, and the other case(s).

Xavier


Return to posts index

Jim Huffaker
Re: Scripting Newb Question: Why isn't this wrapped in a function?
on May 27, 2016 at 7:47:49 pm

Okay. Thanks!


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2018 CreativeCOW.net All Rights Reserved
[TOP]