Micro Focus QTP (UFT) Forums
How to Split an Array - 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 Split an Array (/Thread-How-to-Split-an-Array)



How to Split an Array - Arena - 04-05-2012

I am trying to split an array but I am not sure what string parameter should I use?

arrPV = Split(arrPV,",")

QTP is not liking the first parameter. I can see why since it is the array name: arrPV

What can I use?
Is there a ToString function I can use with arrays?

Code:
Public Function createSingleObj(t,arrPV)
        Set o = Description.Create
        o("micclass").Value = t
        arrPV = Split(arrPV,",")
        For iLoop = 0 to UBound(arrPV)
                Prop= Split(arrPV(iLoop),":=")(0)
                Val= Split(arrPV(iLoop),":=")(1)
                o(Prop).Value = Val
        Next
        Set createSingleObj = o
End Function


Thanks!


RE: How to Split an Array - vIns - 04-05-2012

here arrPV highlighted in red colour is a string. We split it as an array and store it .

or for better understanding,
arrPV = Split(ipPropValues, ",")


RE: How to Split an Array - Arena - 04-05-2012

hI vIns,
Hmm...this is not working for me:
arrPV = Split(ipPropValues, ",")

All I want is to split this array:

arrPV = array("title","name")

I am not sure what ipPropValues does...
Can you help me, please?



--------------------------------------------------------------------------------



RE: How to Split an Array - vIns - 04-05-2012

Code:
createSingleObj("Browser","CreationTime:=0,title:=AOL.*")

Public Function createSingleObj(t,arrPV)
        Set o = Description.Create
        o("micclass").Value = t
        arrPV = Split(arrPV,",")
        For iLoop = 0 to UBound(arrPV)
                Prop= Split(arrPV(iLoop),":=")(0)
                Val= Split(arrPV(iLoop),":=")(1)
                o(Prop).Value = Val
        Next
        Set createSingleObj = o
End Function

Please check the format. "CreationTime:=0,title:=AOL.*"
This is how you need to send your property value pairs


RE: How to Split an Array - Arena - 04-05-2012

Just one last question vIns,

Let's say that I have an array 'R'

Dim R
R=ARRAY("VALUE1","VALUE2")

Is there a way to convert array R into a STRING value?

Thanks!


RE: How to Split an Array - vIns - 04-05-2012

u can use Join to combine the array elements to a string


RE: How to Split an Array - Arena - 04-05-2012

Thanks vIns!