SPONSORS:






User Tag List

Thanks Thanks:  0
Likes Likes:  0
Dislikes Dislikes:  0
Results 1 to 5 of 5
  1. #1
    Senior Member
    Join Date
    May 2001
    Location
    Hickory,NC, USA
    Posts
    122
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    String manipulation..

    I have been trying many way to get this work but hope that you guys could help me out. Suppose i have a string
    of 12 alpha numeric characters which Winrunner is this sets of data of the datatable.

    E.G Datatable:

    Data

    61FA7DCFACDC
    53DGTH6D3FG5
    DG616DG16E56


    From each set of 12 characters, i wish to group them (capture) 2 characters in sequential order. So i will
    have 61 then FA then 7D ...... After stripping this data i would like it to output into a excel spreadsheet in
    one single column. The next set of string numbers should also go in the same column. Therefore the expected
    result should look like this:

    COLUMN A

    61
    FA
    7D
    CF
    AC
    DC
    53
    DG
    TH
    6D
    3F
    G5
    DG
    ..
    ..

    Please help.Thanks in advance!

    ------------------

  2. #2
    Senior Member
    Join Date
    May 2001
    Location
    Ankh-Morpork
    Posts
    2,882
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: String manipulation..

    Basically, read in each value, parse through it 2 characters at a time with substr(), and add them to an array. Then loop through the array and write it to the new table, something like (untested):

    # open up desired table, then...
    public myArray[];
    row = 1;
    ix = 1;
    ddt_get_row_count(table,rows);
    for(row = 1; row <= rows; row++)
    {
    value = ddt_val_by_row(table,row,parameter);
    for(strix = 1, strix < length(value); strix += 2)
    {
    myArray[ix] = substr(value, strix, 2);
    ix++;
    }
    }
    # close source table, then open target table...
    for(ix = 1; ix in myArray; ix++)
    {
    ddt_set_val_by_row(table,ix,parameter,myArray[ix]);
    }

    ------------------
    Charles Reace

    charles{DOT}reace{AT}verizon{DOT}net
    web site | [url=http://www.ebookworm.us/[/url]

    [i]...Sound trumpets! Every trumpet in the host! / Sixty thousand, on these words, sound, so high the mountains sound, and the valleys resound.&lt;/i] (The Song of Roland)

  3. #3
    Junior Member
    Join Date
    Mar 2002
    Location
    Argentina
    Posts
    11
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: String manipulation..

    I Atlee0, I've been working on your problem and I think here is a solution:

    input = "C:\\program files\\Mercury Interactive\\WinRunner\\tmp\\foratlee0\\input.xls" ;
    output = "C:\\program files\\Mercury Interactive\\WinRunner\\tmp\\foratlee0\\output.xls ";

    rc = ddt_open(input,DDT_MODE_READ);
    if (rc != E_OK )
    tl_step("Open input", FAIL, "Input opening failed");

    ddt_open(output,DDT_MODE_READWRITE);
    if (rc != E_OK )
    tl_step("Open output", FAIL, "Output opening failed");

    ddt_get_row_count(input,RowCount);

    for (i=1; i<=RowCount; i++)
    {
    ddt_set_row(input, i);
    inputstr=ddt_val(input,"Input");
    for ( y=0; y < 6 ; y++)
    {
    start = (y*2)+1;
    OutputRow = substr(inputstr,start,"2");
    rc =ddt_set_val(output, "Output",OutputRow);
    rc =ddt_save(output);

    ddt_next_row(output);
    }
    }
    ddt_close(output);
    ddt_close(input);

    You will just have to change input and output table by the correspondings. Input table must have a "Input" column with the strings to be splitted, and Output table mus have a column named "Output" where splitted string are to be saved. Please don't forget to initialize the output table, it is fill with dots(.) or spaces for example, the number of rows will be used.
    I hope it helps you.

    If you want the full script, just send me an email to jose@blue-peaks.com


    ------------------

  4. #4
    Junior Member
    Join Date
    Jun 2002
    Location
    Dulles, VA, US
    Posts
    2
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: String manipulation..

    About the above two solutions, don't forget to open your table in DDT_MOD_READ_WRITE and then do a ddt_save() on the table before closing it.

    ------------------

  5. #5
    Junior Member
    Join Date
    Jun 2002
    Location
    Dulles, VA, US
    Posts
    2
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: String manipulation..

    (sorry, I didn't read the second one carefully enough. it does everything right.)


    ------------------

 

 

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 10.00%
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 11:16 AM.

Copyright BetaSoft Inc.