Micro Focus QTP (UFT) Forums
How to store all output values in different variables - 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: VB Scripting/Descriptive Programming (https://www.learnqtp.com/forums/Forum-VB-Scripting-Descriptive-Programming)
+--- Thread: How to store all output values in different variables (/Thread-How-to-store-all-output-values-in-different-variables)



How to store all output values in different variables - Jyobtech - 10-12-2010

Dear All,

I am getting out values 4, 78, 44 from this function but I want to store all output values(4, 78, 44) in different variables.Can you please help me out to solve this.

-----------------------------------------------------
Code:
Dim Matches,Match,re
Set re=new RegExp 'creates a new regexp object
s="he4llo78ty44"
re.Global = True 'This tells the regexp to keep looking for more matches after the first one.
re.pattern="\d+"
set Matches=re.execute(s)
For each Match in Matches
   msgbox "value is"& Match.value
Next
------------------------------------------------------

Thanks,
Jyo


RE: How to store all output values in different variables - KavitaPriyaCR - 10-12-2010

Either you can use Array OR Dictionary


RE: How to store all output values in different variables - sasi1982 - 10-13-2010

Yes, you can return more than one value to a function using arrays. Below example gives more clarity.

Code:
<function_name> = array(a,b,c) // a,b,c are variables.
or
x = array(a,b,c)
<function_name> = x



RE: How to store all output values in different variables - Jyobtech - 10-13-2010

Dear KavitaPriyaCR and sasi1982,

Thanks for your replay.

Here my input is.....> s="he4llo78ty44"

From msgbox "value is"& Match.value stmt I am getting tha numeric values 4,78,44.

If I execute the above code in notepad .vbs format ,I am getting only one value (Last value ...44 ) but I nedd to caputure 4,78 also.

I think now you may understand the problem....Can you please guide

Regards,
jyo


RE: How to store all output values in different variables - KavitaPriyaCR - 10-13-2010

Hi Jyo, i have tried your script with no chenges, just copy pasted...I am getting all the values displayed (MsgBox...will display ech value we have to click OK when displayed)when i run the .vbs file. Pls check the same and lemme know.