Micro Focus QTP (UFT) Forums
Actions - Printable Version

+- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums)
+-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP)
+--- Forum: UFT / QTP Interview Questions (https://www.learnqtp.com/forums/Forum-UFT-QTP-Interview-Questions)
+--- Thread: Actions (/Thread-Actions)

Pages: 1 2


Actions - bfakruddin - 08-04-2010

Hi,

Can anybody give the sample code for returning multiple values for an Action.

Code:
Dim retval
retval=RunAction("Action1",OneIteration)
msgbox "Returned value of the Action is : " & Chr(32) & retval
' it will return xxxxxxx value

ExitAction(xxxxxx)

here, it is returning a single value... But, Action returns multiple values how it will return multiple values. please give me the sample code.


RE: Actions - rajeshwar - 08-04-2010

'Sample code
-------------------
Code:
'Driver Action
RunAction "Mats",oneiteration,5,2,iAdd,iMul,iSub
' Here A=5,B=2 are "Mats" action's input parameters and iAdd,iMul,iSub are "Mats" action's output parameters.
msgbox iAdd
msgbox iMul
msgbox iSub

' Mats Action
Parameter("iAdd") = Parameter("A") +Parameter("B")
Parameter("iSub") = Parameter("A") -Parameter("B")
Parameter("iMul") = Parameter("A")*Parameter("B")



RE: Actions - bfakruddin - 08-04-2010

Thank you Rajasekhar,

you have used the output parameters here to get the values from Action, Even we can do that by using Functions...

I'm asking that the Action returned value as I showed in my script by using

Code:
retval = ExitAction(retval)

Actually, Action can returns multiple values... how it will do that.

I hope you got my question. If you need any further information please revert me.


RE: Actions - rajeshwar - 08-04-2010

Hi,

I tried this using dictionary object.

Action 1
‘==========================

Code:
Dim ODictAction1
Set ODictAction1 = CreateObject("Scripting.Dictionary")

                Set ODictAction1 = Runaction("Action2", Oneiteration)

    a = ODictAction1.Items   ' Get the items.
   For i = 0 To ODictAction1.Count -1 ' Iterate the array.
      msgbox  s & a(i)
   Next


Action 2
‘===================

Code:
Dim ODictAction2

Set ODictAction2 = CreateObject("Scripting.Dictionary")

ODictAction2.Add "a", "Athens"   ' Add some keys and items.
ODictAction2.Add "b", "Belgrade"
ODictAction2.Add "c", "Cairo"

ExitAction (ODictAction2)



RE: Actions - venkatbatchu - 08-05-2010

Hi Rajesh,

It is not always suggestable to go with Dictionary Objects why because these are system specific and it is not script specific. I mean to say whatever the object you have created that might be in ur system(regedit) if u execute the same script in another system then it may not run as you expected probably the created object may not be available in another system for that you need to create that object in regedit so instead of that it would be better to go with RunAction "Action Name","Iteration","Input Parameters","Output Parameters"

Please let me know if you need any clarification on this.


Venkat.Batchu


RE: Actions - rajeshwar - 08-06-2010

Hi Venkat,


I need more information on what are you trying to say. Yes we need to have entry on the regedit and which is by default present in the registry for all windows system. Why do you think it will not run unless some person intentionally done the changes to the registry.


Thanks
Rajeshwar


RE: Actions - venkatbatchu - 08-06-2010

Hi,

Dictionary object is not the default one for all windows systems, u need to add the object(object name is any) to regedit

Note: try by using dictionary objects in different system and then u come to know what is the thing u need to configure before executing.

For ur reference:
https://www.learnqtp.com/dictionary-object-qtp-use/


Venkat.Batchu.


RE: Actions - rajeshwar - 08-06-2010

Hi,

The reference you have given is for using the Reserved objects. I am not using the reserved object I just making use of environment object which always available. Reserved Objects in regedit are used to create Singleton objects which not the case here. We using the object referecne for other object which is not restrictive and can be used on any windows operating system without restriction. Please let me know in case you need more information.


RE: Actions - venkatbatchu - 08-06-2010

Hi Rajeshwar,

As i discussed above is regarding dictionary objects and i agree with you that environment variables object is by default in all windows systems which is not system specific but dictionary objects are system specific.


Venkat.Batchu


RE: Actions - rajeshwar - 08-06-2010

Hi Venkat,

I disagree with your comments. Dictionary object are not system specfic they can be used by any languge C#, VB, C++, F# and you can refer to MSDN for more details. These objects are extensively used in C#. I havn't made any changes to my regedit to make use of it. Secondly I even checked my reserved objects there is no entry of Scripting.Dictionary.

For ur reference:
http://msdn.microsoft.com/en-us/library/x4k5wbx4(VS.85).aspx