Forum Discussion

szmajchel's avatar
13 years ago

Calling subroutine from another script doesn't work - what do I do wrong?

Hi,



I have two vb scripts in my project, both are single subroutines and I want to call one from another. I have followed instructions from article "Calling Routines and Variables Declared in Another Unit" and set unit references from one script to another, even in both directions (so called circular references) to be perfectly sure they reference to each other. And it doesn't work, when I try to call the other sub it never goes there. Maybe I'm doing something wrong, I'm not experienced in VB Script; the code is following:



Called sub:



Sub AddTestResult(sResultType, sContentStep, sContentResult, sContentTime)

...

End Sub



Calling sub:



Sub ReadStartTime

...

Call AddTestResult ("Initial", "Test description", "passed", CStr(Now))

End Sub



or:



Sub ReadStartTime

...

AddTestResult "Initial", "Test description", "passed", CStr(Now)

End Sub



Called subroutine is not executed. I placed breakpoints in the beginning of script "AddTestResult" and it never goes there.



What is wrong?



Regards

Michal
  • TanyaYatskovska's avatar
    TanyaYatskovska
    SmartBear Alumni (Retired)

    Hi Michal,


     


    Make sure that the USEUNIT command is added to the unit where you are calling the ReadStartTime function. Does the following code work for you?


    <UnitName>.AddTestResult "Initial", "Test description", "passed", CStr(Now)


    (<UnitName> is the name of the unit where AddTestResult is declared)