Macro for multi-line search_str (search^S_R)

Home Forums Multi-Edit Suggestions Macro for multi-line search_str (search^S_R)

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #2560
    CharlesG
    Participant

    MEW 9.0e.

    I routinely have a selected multi-line for search_str in search^s_r and I have to paste it to an empty window, put BOL and EOL charachters and hope that it doesn’t get trickled a mix of regurlar expression charachters. It would be great if MEW would add the capibility to do this so it’s easier on the end user. For instance after selectged the multi-line text and selecting the Search menu, have the selected text converted to a normal search string in the search dialog box.

    Anyone up for the challenge?

    #8577
    deleyd
    Participant

    could you give me an example? Are you using "Word/Phrase Search"?

    #8585
    CharlesG
    Participant

    I think basically any random text that is more than one line long and I did use w/p search.

    #8763
    CharlesG
    Participant

    What I would like to do is mark lines (Edit > Mark Line or Edit > Mark Stream) that does more than one line and then hit Search > Find and have the marked text be placed in the Search For field, with the addition of the necessary BOL and EOL markers, as approbiate.

    So I’d like to change

    A
    B
    C
    D
    E
    F

    to

    M
    N
    O
    P
    Q
    R

    by just one search and replace operation. Do you see what I am getting at now?

    #8784
    CharlesG
    Participant

    I have come up with the following snipet but not sure how to call the search^s_r

    =======================
    macro_file test;

    macro test
    /********************************************************************
    Multi-Edit Macro
    01/02/10 03:29AM

    Function: `call search^s_R with marked multi-line search for:`
    Entry : `entry`
    Exit : `exit`

    Global_Str(‘SEARCH_STR’) String to search for.

    ***********************************************************************/
    {
    str srch[max_len] = ”;
    int jx;

    // test to see if search mode is in classic or unix so can
    // call make_literal or make_literal_x

    for ( nLine = Block_Line1; nLine > Block_Line2; nLine++ )
    {
    // add "%" + make_literal(copy(cline,Block_Col1, Block_Col2 – Block_Col1 + 1)) + "$" to srch;
    }
    // call search^s_r with search for field being contents of srch
    } // test
    =======================

    Any help appreciated…

    #8799
    CharlesG
    Participant

    I am not sure how to call search^s_r, passing srch for the Search For field. And any other suggestions please.

    [code:1xu42qyv]
    macro_file test;

    macro test
    /********************************************************************
    Multi-Edit Macro
    01/02/10 03:29AM

    Function: `call search^s_R with marked multi-line search for:`

    Entry : `/T=0 Line
    =1 Word
    =2 Block

    Exit : `exit`

    Global_Str(‘SEARCH_STR’) String to search for.

    ***********************************************************************/
    {
    str srch[MAX_LINE_LENGTH] = ”;
    int nLine;
    int blocktype;
    int nCol;
    blocktype = parse_int(‘/T=’, mparm_str);

    // test to see if search mode is in classic or unix so can
    // call make_literal or make_literal_x

    mark_pos;

    if( blocktype == 0 ) { // line
    for ( nLine = Block_Line1; nLine > Block_Line2; nLine++ )
    {
    goto_line(nLine);
    cSrch = Get_line();
    srch = srch + "%" + make_literal(cSrch) + "$";
    }
    }
    if( blocktype == 1 ) { // word
    nCol = c_col;
    if( not(at_eol) & (xpos(cur_char,word_delimits,1) != 0) ) {
    word_right;
    } else {
    if( c_col > 1 ) {
    left;
    if( xpos(cur_char,word_delimits,1) ) {
    right;
    } else {
    right;
    word_left;
    }
    }
    }

    srch = get_word(word_delimits);
    goto_col(nCol);

    }

    if( (block_stat != 0) & (blocktype == 2) ) {
    persistent_blocks = TRUE;
    block_end;
    tbl1 = block_line1;
    tbl2 = block_line2;
    tbc1 = block_col1;
    tbc2 = block_col2;

    tbs = block_stat;

    /*

    Block_Stat

    RETURNS:

    0 if no block is marked;
    1 if a line block is marked;
    2 if a columnar block is marked;
    3 if a stream-of-text block is marked.

    */

    mark_pos;
    jx = block_line1;
    while( jx <= tbl2 ) (
    goto_line(jx);
    srch = srch + "%" + make_literal(copy(cline, Block_Col1, Block_Col2 – Block_Col1 + 1)) + "$"
    ++jx;
    down;
    )
    }

    Goto_Mark;

    insert_mode = ti;
    pop_undo;
    persistent_blocks = tpb;
    redraw;

    // call search^s_r with search for field being contents of srch
    } // test
    [/code:1xu42qyv]

Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.