Forum Discussion

m1013864's avatar
m1013864
Occasional Contributor
13 years ago

Funtion within USEUNIT getting called unnecessarily

We have a situation where all the function of a JScript unit e.g. Unit1 is getting executedwhile executing a function from seperate unit(this unit does not call any functions from Unit1 OR //USEUNIT Unit1 is not present any where in the target unit)



Example;



function test()

{}



If I write this function in any new Unit say Unit3 and execute it, then automatically all the functions from the problamatic unit Unit1 gets called and they get executed.



The errant Unit has all functions which serves different calls to data base for different set of conditions or queries.

this is increasing our execution time considerably.

  • Hi,


    Could you please specify the code of your JScript unit and the code of the function you are calling?

  • m1013864's avatar
    m1013864
    Occasional Contributor
    Our suit is very huge with multiple units. where each units have multiple calls to other units. it would be difficult to paste the entire unit here but i would paste first few lines of the UNIT if that can be of any help. I dont know if this is an issue with cross/circular referencing. if yes then how can we resolve this issue because going to individual units and checking it for other units is difficult as we have more than 1100 units.



    Attaching a screen shot of the test complete project suit structure.



    Unit that is being called multiple times.


    //USEUNIT X



    function RetrieveDataForTemplate(tcID)


    RetrieveDataForTemplate(tcID)

    {


    <Calls to db through oled object>


    }



    ---------------------------

    Unit X contains no reference to any use units but this unit contains variable declarations and data structures which is being called by all the units in the suit.

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor
    If that unit is a series of declarations and utilities that is, effectively, used in ALL of your code units, perhaps it would be better if, instead of including it as a code unit, you break it out into a script extension.
  • m1013864's avatar
    m1013864
    Occasional Contributor
    Could you please let me know Martin how that can be achived?



    Many thanks !!!

  • //USEUNIT X



    function RetrieveDataForTemplate(tcID)


    RetrieveDataForTemplate(tcID)

    {


    <Calls to db through oled object>


    }




    Doesn't make sense, it looks like you are breaking a function's definition with a call to itself, which would be a syntax error.



    If you have any global variables in any unit in the project, they are going to be evaluated when the test run starts, regardless of whether they are referenced by USEUNIT or not.