SPONSORS:






User Tag List

Thanks Thanks:  0
Likes Likes:  0
Dislikes Dislikes:  0
Results 1 to 9 of 9

Thread: CR, LF

  1. #1
    Member
    Join Date
    Oct 2002
    Posts
    60
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    CR, LF

    Dear all,

    steps:

    1. Multi-line "html_edit" object.

    2. I am using edit_get_text("object",outtext) TSL statement.

    3. All lines are coming in 'outtext' variable with \r\n (carriage return and line feed) for each word.

    4. Is there any way to get the count no of items in multiline edit object.

    eg:

    outtext = ABCD\r\nEFGH\r\nIJKL\r\n....


    How to extract each line without "carriage return '\r' and Linefeed '\n' special characters.

    expected output should be:

    ABCD
    EFGH
    IJKL

  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: CR, LF

    I would probably strip out the \r's with some sort of loop and substr(), then do a split() on the \n character to create an array of text lines.
    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.</i] (The Song of Roland)

  3. #3
    SQA Knight
    Join Date
    Jun 2002
    Location
    Cupertino, CA, USA
    Posts
    2,164
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: CR, LF

    I would capture the lines of the edit one by one:

    </font><blockquote><font size="1" face="Verdana, Arial, Helvetica">code:</font><hr /><pre style="font-size:x-small; font-family: monospace;">set_window(&quot;YourWindow&quot;, 1);
    edit_get_rows_count(&quot;YourEdit&quot;,row_count );
    for(row = 0; row &lt; row_count; row++)
    {
    edit_get_row_length(&quot;YourEdit&quot;,row,row_l ength);
    edit_get_block(&quot;YourEdit&quot;,row,0,row,row_ length,str);
    out_text = out_text &amp; str;
    }

    pause(out_text);</pre><hr /></blockquote><font size="2" face="Verdana, Arial, Helvetica">

  4. #4
    Member
    Join Date
    Oct 2002
    Posts
    60
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: CR, LF

    Thanks for the response.

    1. when I execute following statements, its winrunner cannot find the object though object exists.

    edit_get_row_length("YourEdit",row,row_length);
    edit_get_block "YourEdit",row,0,row,row_length,str

    2. How to split \r\n special characters using 'split' TSL command. bcoz I have tried that I couldnot get the required output.

  5. #5
    SQA Knight
    Join Date
    Jun 2002
    Location
    Cupertino, CA, USA
    Posts
    2,164
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: CR, LF

    The problem is that the split function only works with one character. Here is a function split_ex which works like the standard split function except it can take more then one character:

    </font><blockquote><font size="1" face="Verdana, Arial, Helvetica">code:</font><hr /><pre style="font-size:x-small; font-family: monospace;">function split_ex(in str, inout array[], in FieldSeparator)
    {
    auto ind,counter,len;
    counter = 1;
    len = length(FieldSeparator);
    while(ind = index(str,FieldSeparator))
    {
    array[counter++] = substr(str,1,ind- 1);
    str = substr(str,ind + len);
    }
    array[counter++] = str;
    return --counter;
    }
    split_ex(out_var,array,&quot;\r\n&quot;</pre><hr /></blockquote><font size="2" face="Verdana, Arial, Helvetica">

  6. #6
    Member
    Join Date
    Oct 2002
    Posts
    60
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: CR, LF

    function split_ex also didn't work for me.

    suppose outtext = "ABCD\r\nCDEF\r\n"
    when am taking a=length("\r\n");
    a is shown as 0.

    can we can do replace \r\n with some character and split again.

  7. #7
    Senior Member
    Join Date
    Feb 2003
    Posts
    141
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: CR, LF

    Try as

    split_ex(out_var,array,"\\r\\n");

  8. #8
    Member
    Join Date
    Oct 2002
    Posts
    60
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: CR, LF

    split_ex(out_var,array,"\\r\\n") function is also FAILED... [img]images/icons/frown.gif[/img]

  9. #9
    Member
    Join Date
    Nov 2004
    Location
    36th floor
    Posts
    34
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: CR, LF

    bumping this thread as i'm encountering this very same problem.

    i tried all the suggestions in this thread but all failed.

    i'm particularly curious in this one:
    </font><blockquote><font size="1" face="Verdana, Arial, Helvetica">code:</font><hr /><pre style="font-size:x-small; font-family: monospace;">set_window(&quot;YourWindow&quot;, 1);
    edit_get_rows_count(&quot;YourEdit&quot;,row_count );
    for(row = 0; row &lt; row_count; row++)
    {
    edit_get_row_length(&quot;YourEdit&quot;,row,row_l ength);
    edit_get_block(&quot;YourEdit&quot;,row,0,row,row_ length,str);
    out_text = out_text &amp; str;
    }

    pause(out_text);</pre><hr /></blockquote><font size="2" face="Verdana, Arial, Helvetica">somehow my edit box is not seen during run time. weird.

 

 

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 11:45 AM.

Copyright BetaSoft Inc.