Micro Focus QTP (UFT) Forums

Full Version: How to Split an Array
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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!
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, ",")
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?



--------------------------------------------------------------------------------
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
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!
u can use Join to combine the array elements to a string
Thanks vIns!