Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Break up a string of text and variables
#1
Not Solved
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.
Reply
#2
Not Solved
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.
Reply
#3
Not Solved
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.
Reply
#4
Not Solved
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
Basanth
Give a fish to a man and you feed him for a day..Teach a man how to fish and you feed him for life.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Need to Validate Text filed is blank after clicking on the Text box balak89 3 4,856 09-13-2015, 12:06 AM
Last Post: ADITI1992
  How to retrieve specied string from text file nsuresh316 1 2,434 06-09-2015, 12:24 AM
Last Post: nsuresh316
  Replace a string in a word document with another string rekha.naik 8 15,440 11-14-2013, 12:58 PM
Last Post: pranikgarg
  where to declare variables?? ACCBAJPA 0 2,345 10-01-2013, 07:20 PM
Last Post: ACCBAJPA
  I am trying to extract text from a webelement but it is generating blank text scenari excellentpawan 2 4,614 08-13-2013, 08:37 PM
Last Post: excellentpawan

Forum Jump:


Users browsing this thread: 1 Guest(s)