Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Scripting Newb Question: Why isn’t this wrapped in a function?

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

    Posted by Jim Huffaker on May 27, 2016 at 3:40 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
    {

    Jim Huffaker replied 9 years, 11 months ago 2 Members · 2 Replies
  • 2 Replies
  • Xavier Gomez

    May 27, 2016 at 5:09 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

  • Jim Huffaker

    May 27, 2016 at 7:47 pm

    Okay. Thanks!

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy