No internet connection
  1. Home
  2. How to

send variables thru command id packages

By samuel henriques @samuel_henriques
    2021-02-05 17:26:34.353Z

    hello,
    I'm chaining 4 scripts together using the sf.soundflow.runCommand with the next script commandId.
    I would like to send a variable from the 1st in line to the 3rd. I'm storing it in globalState and works, but was wondering if theres a different way.

    Thank you

    • 5 replies
    1. From what I understand, using globalState is the best, easy method for doing this as it requires the least amount or script rewriting.

      1. Having said that, I'm sure Christian or Kitch may offer a better solution :).

      2. You can set the "result" (output) of a script like this:

        event.setResult('test result');
        

        So, in the script that calls it, you get the result out like this:

        var res = sf.soundflow.runCommand({
            commandId: 'package:ckimmgdb20000yh10z0t280w7',    
        }).result;
        
        log(res);
        

        You can also give a script input (arguments) like this:

        sf.soundflow.runCommand({
            commandId: 'package:ckimmgdb20000yh10z0t280w7',
            args: {
                arg1: 'test123',
            },
        });
        

        You fetch that argument "arg1" like this:

        log(event.arguments.arg1);
        
        1. Instead of this though, you may want to use modules and require syntax instead.

          Please see here for an example of how to use that:

          1. samuel henriques @samuel_henriques
              2021-02-05 19:09:51.137Z

              Awesome guys, and thank you so much!!