Forum Discussion

regamba's avatar
regamba
New Contributor
13 years ago

Execute script by "Call" instruction, when the name of the script is in a variable.

I have a technical question, I hope you o somebody help me, because I was searching any answer in internet and I could not any answer.

I am in a script and I must call other script, to call the script I use “Call Login” senetence.



I want to have the script name in a variable, so when I execute the following senetence the TestComplete give an exception.

 

Dim vScript

vScript = “Login”

Call vScript



Do you now to execute the script when the name of it is in a variable?



Thanks,

7 Replies

  • AlexKaras's avatar
    AlexKaras
    Icon for Champion Level 2 rankChampion Level 2
    Also, in VBScript, it is Eval() but not Evaluate() (like it is in JScript and DelphiScript).
  • paul_scroce's avatar
    paul_scroce
    Frequent Contributor


    You could use the script name as a parameter something like this



    vScript = "Login"

    Call RunScript (vScript)



    Sub RunScript (strName)

      Select Case strName

        Case "Login"

          Call Login



      End Select

    End Sub



     



     



     



     



     



     



     


  • AlexKaras's avatar
    AlexKaras
    Icon for Champion Level 2 rankChampion Level 2
    Hi Rubén,



    Evaluate() function should do what you need.

    Something like this:

    Dim vScript

    vScript = “Login”

    Evaluate("Call " & vScript)



  • regamba's avatar
    regamba
    New Contributor
    Hi Alk,

    I executed the code that you can see blelow:




       Sub Test1


            Dim vScript


            vScript = "Borrar1" 


            Evaluate("Call " & vScript)


       End Sub




    But Test Complete showed the following message:



    "Error en Microsoft VBScripot en tiempo de ejecución

    No coiciden los tipos "Evaluate"



    Error de localicación ...."



     

  • As mentioned above, Eval() is what you need if you're using VBScript.



    All my stuff runs in a framework and the function calls and their parameters are read in and executed as per the user defined input data using Eval(). Works fine.
  • regamba's avatar
    regamba
    New Contributor
    Hi everybody,

    I resolved the problem with the following sentrence:



    project.Variables.gNombreScript = ScriptName .TestProcedure



    Execute project.Variables.gNombreScript



    Now, I a going to test with Eval().

    Thanks for all.