Forum Discussion

aradecki's avatar
aradecki
New Contributor
13 years ago

Variable as a part of alias

Hi,



Is it possible to replace part of alias with a variable ?



Expample:



Aliases.iforce1.MainForm.MDIClient.frmTransEd_FX.ScrollBox.pnlCenter.gbBuy.dedAmountBought.Keys('1000'); 



Instead "frmTransEd_FX" I want to put variable in which I put string "frmTransEd_FX" or other. I have no idea how to do it in delphi script (or in keyword test if possible).



Please help :)



aradecki

4 Replies

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor
    Another possible option is to use the Evaluate function.  You could do:



    var MyObj;

    MyObj := Evaluate('Aliases.iforce1.MainForm.MDIClient.' + Var1 + '.ScrollBox.pnlCenter.gbBuy.dedAmountBought');

    MyObj.Keys('1000');


  • Hi aradecki,



    You can use the WaitAliasChild method:





      var var1:OleVariant;

    begin

    ...

      var1 := 'frmTransEd_FX';

      Aliases.iforce1.MainForm.MDIClient.WaitAliasChild(var1).ScrollBox.pnlCenter.gbBuy.dedAmountBought.Keys('1000');

    ...









  • aradecki's avatar
    aradecki
    New Contributor
    In my case it's easier to use WaitAliasChild method. In my script (which is converted from keyword test) i have about 20-30 fields on form, so it looks like :



    (...)

      Aliases.iforce1.MainForm.MDIClient.WaitAliasChild(test).ScrollBox.pnlCenter.dedTransactionRate.Keys('4,1234');

      //Enters '1000' in the 'dedAmountBought' object.

      Aliases.iforce1.MainForm.MDIClient.WaitAliasChild(test).ScrollBox.pnlCenter.gbBuy.dedAmountBought.Keys('1000');

      //Enters 'USD[Enter]' in the 'dedCcyBought' object.

      Aliases.iforce1.MainForm.MDIClient.WaitAliasChild(test).ScrollBox.pnlCenter.gbBuy.dedCcyBought.Keys('USD[Enter]');

      //Enters '~[Down]' in the 'dcbNostBought' object.

      Aliases.iforce1.MainForm.MDIClient.WaitAliasChild(test).ScrollBox.pnlCenter.gbBuy.dcbNostBought.Keys('~[Down]');

      (...)



    Replace part of alias with WaitAliasChild(variable) is faster than changing every line into new object.

    Although thank you for new idea :)