Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to Split an Array
#1
Solved: 11 Years, 3 Months, 3 Weeks ago
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!
Reply
#2
Solved: 11 Years, 3 Months, 3 Weeks ago
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, ",")
Reply
#3
Solved: 11 Years, 3 Months, 3 Weeks ago
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?



--------------------------------------------------------------------------------
Reply
#4
Solved: 11 Years, 3 Months, 3 Weeks ago
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
Reply
#5
Solved: 11 Years, 3 Months, 3 Weeks ago
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!
Reply
#6
Solved: 11 Years, 3 Months, 3 Weeks ago
u can use Join to combine the array elements to a string
Reply
#7
Solved: 11 Years, 3 Months, 3 Weeks ago
Thanks vIns!
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Is the split array method the correct tool for the job? qatestbrian 0 2,092 01-06-2010, 02:06 AM
Last Post: qatestbrian
  How to use Array of Array in QTP dineshb 1 16,632 12-12-2009, 02:00 AM
Last Post: rdemers25
  Array function for Static Array anbarasu 2 3,839 11-20-2009, 12:18 PM
Last Post: anbarasu

Forum Jump:


Users browsing this thread: 3 Guest(s)