Global function

Viewing 1 reply thread
  • Author
    Posts
  • April 4, 2026 at 11:36 PM #53898

    Steve-Kai Vyska
    Participant

    Hi, everyone and happy easter,

    Using piclists, you can set them to to Document, so that you can access them from every form. is there somehow a possibility to make the same with functions?

    i have several function, which I need to use in several forms. actually I copy them to each script I need it in. Is there some way to declare it onetime and use from every script?

    Greetings 🐣

    Steve

    April 5, 2026 at 8:11 AM #53905

    Daniel Leu
    Participant

    Yes, there’s the runScriptNamed('common functions') command. This will execute the named script. If such a script only contains functions and definitions, then they will be directly accessible from you script. But if the script contains a function call, it would be executed too.

    To prevent that, I use following structure at the end of the file:

    if (!scriptName == "common functions"){
       // function call to entry point of script
       main();
    } else {
       console.log("Script " + scriptName + " loaded");
    }
    

    For a document script use document.runScriptNamed('common functions') and for a form script use document.getFormNames('script form').runScriptNamed('common functions').

    As you see, you can put scripts in a common form where you can pull them from. I do this with my scriptHandler helpers.

    Cheers, Daniel

    ---
    See https://lab.danielleu.com/tapformspro/ for scripts and tips&tricks

Viewing 1 reply thread

You must be logged in to reply to this topic.