Forum Discussion

william_roe's avatar
william_roe
Super Contributor
10 years ago

Calling Function in Specific Script File

I have a function with the same name in multiple script files. How do I specifically designate the intended script file? Intellisense doesn't show all script files. Must the function names be unique across all script files? I assumed each file would have it's own scope.

  • HKosova's avatar
    HKosova
    10 years ago

    william_roe wrote:

    Intellisense doesn't show all script files.


    You need //UNEUNIT UnitName to call functions from other units, and for those units to appear in the Code Completion.

     

    [JScript]

    //USEUNIT Unit2 //USEUNIT Unit3 function Main() { Test(); // Runs the Test() function from the current unit Unit2.Test(); Unit3.Test(); }

    william_roe wrote:

    Must the function names be unique across all script files?


    No. But it's a good idea to keep them unique.

  • I think you can do something like this:

     

    MyExtUnit.MyRoutine(Param1, Param2)

    • william_roe's avatar
      william_roe
      Super Contributor

      This does not work for all script files (units). I can do this with some of the script files but not all. Specifically, I have a script file 'Purchasing' which contains a function called 'ShowAllSites'. This function exists in other script files... none of which can be called with the MyExtUnit.MyRoutine syntax (Purchasing.ShowAllSite). My guess is the script file are global in scope and the identical function names are causing the problem.

       

      Can anyone confirm this?

      • HKosova's avatar
        HKosova
        SmartBear Alumni (Retired)

        william_roe wrote:

        Intellisense doesn't show all script files.


        You need //UNEUNIT UnitName to call functions from other units, and for those units to appear in the Code Completion.

         

        [JScript]

        //USEUNIT Unit2 //USEUNIT Unit3 function Main() { Test(); // Runs the Test() function from the current unit Unit2.Test(); Unit3.Test(); }

        william_roe wrote:

        Must the function names be unique across all script files?


        No. But it's a good idea to keep them unique.