Micro Focus QTP (UFT) Forums
Break up a string of text and 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: UFT / QTP Beginners (https://www.learnqtp.com/forums/Forum-UFT-QTP-Beginners)
+--- Thread: Break up a string of text and variables (/Thread-Break-up-a-string-of-text-and-variables)



Break up a string of text and variables - csutter2002 - 03-15-2013

Hi, I am looking at a table with many "columns" of data actually being just one cell that looks like it has many. Parts of that returned cell I need to make a variable.

So the first thing I need to do is to grab the variable items out of the sentence and then put the sentence back together and check it? Or should I check the 1st part of the sentence, a variable, the 2nd part of the sentence, the 2nd variable and the 3rd part of the sentence?

So here is an example of what I am trying to parse:

"WebTableTitleProduct :TypeOfProductExpiration :N/AOrder Status :Order Initiation Project Id :<variable number>Opportunity Id :N/ARequest Id :<variable number>Brand :N/ATerm :N/ACommitment :N/A"

Taken apart it would like this:
"WebTableTitle
Product :TypeOfProduct
Expiration :N/A
Order Status :Order Initiation
Project Id :<variable number>
Opportunity Id :N/A
Request Id :<variable number>
Brand :N/A
Term :N/A
Commitment :N/A"

Thanks for any help you can give me.


RE: Break up a string of text and variables - csutter2002 - 03-18-2013

I expect using a string would be a good idea. I also wonder how to get QTP to see / as a character and not a special character. I would search for the answers to these questions but the Search function is not working on my computer -- I get:

Home
About
Certification
Jobs
Training
Contact

// uh oh!

Learn LoadRunner

RSS feed for Learn LoadRunner

Oops!

Looks like the page you're looking for has been moved or had its name changed. Or maybe it's just fate. You could use the search box in the header to search for what you're looking for, or begin again from the home page.


RE: Break up a string of text and variables - csutter2002 - 03-19-2013

In case anyone is interested, we used the functions right/left/mid.

We can go right 87 characters to the end of the area we expect, we could do the same thing using left.

Ultimately we used mid:

nProjId=mid(sTemp, 87, 7)
nProjId is the number we need.
sTemp holds the string we expect to get back.
we go in 87 characters and then nProjId becomes the 7 characters from there.

Just thought you might want to know.


RE: Break up a string of text and variables - basanth27 - 03-20-2013

What would happen if a charachter is introduced? Probably this would upset if a dynamic text happens to come up.
Honestly, I wasnt quite able to understand completely as to what you intended to do.
Parsing is always an issue and at times requires quite a bit of tweak. Here is one simple example, see if this helps you to achieve what you intend to.
Code:
ostrValue = "WebTableTitleProduct :TypeOfProductExpiration :N/AOrder Status :Order Initiation Project Id :<variable number>Opportunity Id :N/ARequest Id :<variable number>Brand :N/ATerm :N/ACommitment :N/A"
oValue = Split(ostrValue,":")

For i = Lbound(oValue) to Ubound(oValue)
    msgbox oValue(i)
Next