No internet connection
  1. Home
  2. How to

Reference script of arguments that can be linked in other scripts

By Alex Oldroyd @Alex_Oldroyd8
    2022-06-16 12:10:21.986Z

    Hi all

    I have multiple scripts that perform a function depending on the track name. eg colour the track depending on the track name. They all use the same Switch function set.

    ie

    
        switch (true) {
            // lead vocal
            case (trackName.includes('lv')) || (trackName.includes('lead')) && (trackName.includes('vocal')) || (trackName.includes('vox')):
                functionToPerform(8, "Section 2", 2);
                break
            // backing vocal
            case ((trackName.includes('harm') || trackName.includes('group') || trackName.includes('chant') || trackName.includes('gang') || trackName.includes('bv')) || (trackName.includes('back') && (trackName.includes('vocal') || trackName.includes('vox')))):
                functionToPerform(8, "Section 2", 3);
                pickColour(22, 2);
                break
    

    Problem is, if i want to add or amend one of the arguments, I have to do it to every single script.

    Would it be possible for the Switch set to sit somewhere, and have each script refer to that single Switch set that i can update as I go?

    Template is not ideal as I'd have to change my whole folder structure... but if that's the only way, I'd appreciate some help with how to accomplish this.

    Thanks all

    Best

    Alex

    Solved in post #2, click to view
    • 5 replies
    1. Hi Alex,

      See here for how to reuse functions across scripts without templates:

      ReplySolution
      1. AAlex Oldroyd @Alex_Oldroyd8
          2022-06-16 17:30:37.119Z

          Whoop! This looks like exactly what I was after!! :)

          Thanks Christian!

          1. In reply tochrscheuer:
            AAlex Oldroyd @Alex_Oldroyd8
              2022-06-17 13:46:44.197Z

              So do you do this often to stop scripts getting too convoluted?

              1. Yes, this is standard practice when building packages for publishing where several scripts will depend on the same code or configuration.

                1. AAlex Oldroyd @Alex_Oldroyd8
                    2022-06-17 21:54:18.066Z

                    Thanks Christian