SPONSORS:






User Tag List

Thanks Thanks:  0
Likes Likes:  0
Dislikes Dislikes:  0
Page 1 of 2 12 LastLast
Results 1 to 10 of 11
  1. #1
    Junior Member
    Join Date
    Nov 2007
    Posts
    29
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    QTP Split function usage

    Hi,

    I need help in split function...

    I have the following string

    var = "AA/GL 25,000/50,000 BB 15,000 CC 1,000 DD - 1,000 HH - 1,000 SS 25,000/50,000 SU 25,000/50,000"

    Now I want to use the split function to split the value until the next character...

    Like

    var1 = AA/GL 25,000/50,000
    var2 = BB 15,000
    var3 = CC 1,000 etc...

    Can someone help me in this regard.

    Thanks,
    Hima

  2. #2
    Senior Member
    Join Date
    Feb 2008
    Location
    Los Angeles, CA, USA
    Posts
    861
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: QTP Split function usage

    You will have to create a custom function. You can have two variables current and next.

    You can use array to store your substrings.

    Use Instr to find the position of next sequence. e.g. current="AA"; next="BB"

    nextIndex=Instr(0, inputString, next, 1) will give you position of the next delimiter (which in this case is "BB").

    Now use left method to extract your next substring

    nextSubstring=left(inputString, nextIndex-1)

    inputString=right(inputString, len(inputString)-nextIndex+1)

    'use the above mentioned logic. The index values may be needed to change.
    -Suchit

  3. #3
    Moderator
    Join Date
    Jul 2005
    Location
    Delhi
    Posts
    15,575
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    7 Thread(s)
    Total Downloaded
    0

    Re: QTP Split function usage

    The normal Split function can't help you in this case. You need to create your own login as Suchit suggested. Normal Split is based on a single delimiter.

  4. #4
    Junior Member
    Join Date
    Nov 2007
    Posts
    29
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: QTP Split function usage

    I do understand that . I am using custom logic similar to what suchit mentioned but my input data always does not contain the same character/value for the search character [eg.BB]. So I want to use soemthing like for example the instr looks for the next char/word in the entire string and gives me the position of that word.

    Like in what suchit mentioned below next = BB.Instead of BB as fixed value, Is there anyway that we can query for the next word/char and retrieve the position.

    Use Instr to find the position of next sequence. e.g. current="AA"; next="BB"

    nextIndex=Instr(0, inputString, next, 1)

    Thanks,
    Hima

  5. #5
    Senior Member
    Join Date
    Nov 2007
    Posts
    263
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: QTP Split function usage

    You might want to look at using Regular Expressions.

  6. #6
    Junior Member
    Join Date
    Nov 2007
    Posts
    29
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: QTP Split function usage

    I found the solution ,

    Thanks everyone..

    Hima

  7. #7
    Senior Member
    Join Date
    Oct 2005
    Location
    London, U.K
    Posts
    1,804
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: QTP Split function usage

    Hima,

    Someone is going to have the same problem as you, get to the bottom of this thread, then be really p*ssed when they read "I found the solution" !!!!

    It's a courtesy when you have been pointed in the right direction to supply the solution.

  8. #8
    Junior Member
    Join Date
    Nov 2007
    Posts
    29
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: QTP Split function usage

    Oops...

    I am Sorry ...I didnt mean to frustate anyone..I did not use the instr function...

    Here is the solution

    inputString="AA/GL 25,000/50,000 BB 15,000 CC 1,000 DD - 1,000 HH - 1,000 SS 25,000/50,000 SU 25,000/50,000"

    val = Split(inputString, "-")
    result = Trim(Join(val))
    'msgbox result

    FinalTemp = Split(result, " ")
    FinalInputString = Join(FinalTemp)
    'msgbox FinalInputString

    Dim coverage(7)
    temp = split(FinalInputString, " ")
    j = 0
    For i = 0 to Ubound(temp)
    'msgbox temp(i)
    If IsNumeric(left(temp(i),1)) Then
    coverage(j) = temp(i-1) & " " & temp(i)
    'msgbox coverage(j)
    j = j+1
    End If
    Next

    j=0
    m=0
    Dim limits(10)
    For k = 0 to UBound(coverage)
    'msgbox coverage(k)
    temp = Split(coverage(k), " ")
    For i = 0 to Ubound(temp)
    'msgbox temp(i)
    If IsNumeric(left(temp(i),1)) Then
    limits(j) = temp(i)
    'msgbox limits(j)
    j = j+1
    Else
    coverage(m) = temp(i)
    'msgbox coverage(m)
    m = m + 1
    End If
    Next
    Next

    Thanks,
    Hima

  9. #9
    Junior Member
    Join Date
    Mar 2009
    Posts
    4
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: QTP Split function usage

    How can I use delimiter double quote in split function?
    Ex: String1=<value="SQA Forum">
    How can I get the value SQA Forum using split.

  10. #10
    Junior Member
    Join Date
    Mar 2009
    Posts
    4
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: QTP Split function usage

    May be simple.

    I am new to the forum.

    How can I post a new question on SQA forums?
    How can I see all my posts?
    Is there any inbox where I can see them all?

 

 
Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Search Engine Optimisation provided by DragonByte SEO v2.0.36 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Resources saved on this page: MySQL 9.38%
vBulletin Optimisation provided by vB Optimise v2.6.4 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
User Alert System provided by Advanced User Tagging v3.2.8 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
vBNominate (Lite) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Feedback Buttons provided by Advanced Post Thanks / Like (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Username Changing provided by Username Change (Free) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
BetaSoft Inc.
Digital Point modules: Sphinx-based search
All times are GMT -8. The time now is 10:39 AM.

Copyright BetaSoft Inc.