Forum Discussion

mcguireden50's avatar
mcguireden50
New Contributor
14 years ago

Passing stores.dbtables table1 object from keyword to script routine

This has got to be really easy. But I can't figure it out. I want to change the connectionstring parameter in each dbtable object in script before I do a compare.



Thanks in advance

Dennis McGuire

3 Replies

  • Sorry - I guess I didn't do a very good job of explaining my question.



    What I want to do is pass a stores.dbtables.table1 object from a runscriptroutine in a keyword test using stores.dbtables.table1 object as a parameter to a script routine.



    Here is basic pseudo code



    Keyword test



    Item                                               Operation                                                                         Value       

    Run Script Routine              setconnectionstring                                                          stores.dbtables.table1







    Script code






    function setconnectionstring(obj:object);


    setconnectionstring(obj:);

    var DBTab;


    DBTab;

    begin



    DBTab := obj;


     


    DBTab.ConnectionString := 'Provider=Advantage.OLEDB.1;Data Source='+ProjectSuite.Variables.VariableByName['connectionpath']+';Persist Security Info=False;Advantage Server Type=ads_local_server';



    end;


    ;



    What is the proper way to pass the parameter to the script routine.



    Thanks

  • Hi,





    I was able to pass the DBTable object from a keyword test to a script test. I added the Run Script Routine operation to a keyword test and specified "dbtables.table1" in the Value column (the parameter mode is Code Expression). Here is a script function that receives the object:



    function setconnectionstring(obj);

    var DBTable;

    begin

      DBTable := obj;

      result := DBTable.ConnectionString;

    end;







    BTW, if you want just to change the connection string in your keyword test, you can use the Run Code Snippet operation instead of calling a script routine that will perform the same. Please read the "Run Code Snippet Operation" article for more information.