Passing parameter data to Form level Script

Tap Forms – Organizer Database App for Mac, iPhone, and iPad Forums Script Talk Passing parameter data to Form level Script

Viewing 3 reply threads
  • Author
    Posts
  • June 5, 2022 at 12:04 PM #47434

    Bernie McGuire
    Participant

    I want to have a Form Level Script (DoSomething) that accepts an input parm ex DoSomething(‘abc’).
    I’d like to call this script from various field level scripts using runScriptNamed(‘DoSomething’) but I do not see how to pass the value of ‘abc’ into the script on the runScriptNamed call.
    Is it possible?
    Thanks
    Bernie

    June 5, 2022 at 2:06 PM #47438

    Brendan
    Keymaster

    If you setup a variable and populate it before you call runScriptNamed() then you should have access to that variable from within the script you’re running. So no parameter required.

    June 5, 2022 at 3:58 PM #47442

    Bernie McGuire
    Participant

    you mean the Form Script will have access to a variable declared in a Field Script function ??? are all your vars global? this sounds strange to me.

    What I understand is this:
    function FieldScript() {
    var xyz = ‘123’
    form.rundScriptedNamed(‘formScript’);
    }

    Then in the Form Script:
    function formScript() {
    var abc;
    //I can set abc = xyz
    abc = xyz;
    // and now abc will have ‘123’ in it ?
    }
    This doesn’t make any sence to me thinking about rules of encapusalation. Unless there is some type of ‘Global’ tag I need to use on the variable.

    Please help
    Thanks

    June 5, 2022 at 9:45 PM #47445

    Daniel Leu
    Participant

    I use several scripts as infrastructure/include scripts. They only contain function or constant definitions. Then I use runScriptNamed() to include these functions. Later, whenever I need, I can call one of these defined functions from these include files.

    So for your example, define

    function formScript(abc) {
       console.log(abc)
    }

    Then from your calling script, you do

    runScriptNamed("myIncludeScript")
    and then later
    formScript("hello")

Viewing 3 reply threads

You must be logged in to reply to this topic.