Micro Focus QTP (UFT) Forums
Split function without delimiter - 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 Beginners (https://www.learnqtp.com/forums/Forum-UFT-QTP-Beginners)
+--- Thread: Split function without delimiter (/Thread-Split-function-without-delimiter)



Split function without delimiter - NeedQTPHelp - 06-09-2009

Hi Everyone,
I have a number of links in one string and I want to click on them 1 by 1. But the problem I am facing is that there is no delimiter in the string. No space, decimal or anything. Its just one long line of letters with no space in between.

The code I'm using is
Code:
str=Browser("").Page("").WebElement(Desc).GetROProperty("innertext")
msgbox str
MyArray = Split(str, "", -1, 1)
Msgbox MyArray (0)
(it just gives me the string without splitting it)

My question is how do I split the string with no delimiter.
Thanks in advance


RE: Split function without delimiter - Ankur - 06-09-2009

Can you post that string here?


RE: Split function without delimiter - NeedQTPHelp - 06-09-2009

The string is
"Library AssistantAudiovisual TechnicianReference LibrarianMedia Library SpecialistPhoto Library Assistant"
These are job titles in the form of link
Library Assistant
Audiovisual Technician
Reference Librarian
Media Library Specialist
Photo Library Assistant


RE: Split function without delimiter - NeedQTPHelp - 06-10-2009

Hi Again,
Can someone help me with this problem. I need a code to split the above string in the form of the job title links.
Thanks in advance for the help.


RE: Split function without delimiter - Ankur - 06-10-2009

I see. Splitting may not be possible in this case. (unless you know the job titles beforehand which I am sure is not the case.)

You can get all the links using .childobject and then you can click on them one by one. (I guess this was the requirement in your OP)
Let me know if it works for you.


RE: Split function without delimiter - VREntropy - 06-11-2009

If you are getting a string like that, then unless you know what text will be coming and in what order I don't think there is a way to split it programmatically. Possibly build a dictionary and compare bits of the string against the dictionary entries.

If you know what will be coming in the string you can use the VBS Left() and Right() functions to grab parts of the string and put them into other variables, but you will need to know the length of each string and the order that is appears in.

Best bet would be to have the DB query that returns the string throw some delimiters. Pass the work upstream! Wink