Macro for multi-line search_str (search^S_R)

Discuss Multi-Edit related topics and new feature requests here. Please not post support requests or bug reports! Non-Multi-Edit questions, discussion goes in General Chat!

Moderator: Moderators

Macro for multi-line search_str (search^S_R)

Postby CharlesG on Fri Jul 03, 2009 9:34 am

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?
CharlesG
Registered User
 
Posts: 116
Joined: Thu Aug 28, 2003 10:37 pm
Location: Raleigh, NC USA

Postby deleyd on Sat Jul 25, 2009 8:00 pm

could you give me an example? Are you using "Word/Phrase Search"?
User avatar
deleyd
Developer
 
Posts: 1023
Joined: Tue Jul 29, 2003 4:27 pm
Location: Santa Barbara, CA

Postby CharlesG on Tue Jul 28, 2009 1:52 am

I think basically any random text that is more than one line long and I did use w/p search.
CharlesG
Registered User
 
Posts: 116
Joined: Thu Aug 28, 2003 10:37 pm
Location: Raleigh, NC USA

Re: Macro for multi-line search_str (search^S_R)

Postby CharlesG on Sat Jan 02, 2010 8:02 am

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?
CharlesG
Registered User
 
Posts: 116
Joined: Thu Aug 28, 2003 10:37 pm
Location: Raleigh, NC USA

Re: Macro for multi-line search_str (search^S_R)

Postby CharlesG on Fri Jan 29, 2010 4:35 am

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...
CharlesG
Registered User
 
Posts: 116
Joined: Thu Aug 28, 2003 10:37 pm
Location: Raleigh, NC USA

Re: Macro for multi-line search_str (search^S_R)

Postby CharlesG on Wed Feb 17, 2010 4:36 am

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

Code: Select all
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
CharlesG
Registered User
 
Posts: 116
Joined: Thu Aug 28, 2003 10:37 pm
Location: Raleigh, NC USA


Return to Suggestions

Who is online

Users browsing this forum: No registered users and 1 guest

cron