home *** CD-ROM | disk | FTP | other *** search
/ Piper's Pit BBS/FTP: ibm 0010 - 0019 / ibm0010-0019 / ibm0010.tar / ibm0010 / ME494-6.ZIP / SRC / MEUTIL2.SRC < prev    next >
Encoding:
Text File  |  1990-05-25  |  40.5 KB  |  1,508 lines

  1. $MACRO_FILE MEUTIL2;
  2. {******************************************************************************
  3. S_AND_R        - The general purpose search and search/replace macro.
  4. SEARCH        - This is the user interface for a SEARCH.
  5. S_REPL        - This is the user interface for a SEARCH AND REPLACE.
  6. REPSRCH        - This repeats the last search or search/replace.
  7. UNDBLK        - Undent block macro.
  8. INDBLK        - Indent block macro.
  9. MARKBLCK    - Mark line block macro.
  10. MCOLBLCK    - Mark columnar block macro.
  11. MSTRBLCK    - Mark stream of text block macro.
  12. BLOCKOFF    - Turn block mark off.
  13. BLOCKOP        - Move, copy, and delete block operations.
  14. CUT                - Copies, Moves or Appends text into a hidden buffer.
  15. PASTE            - Copies block from buffer into current file.
  16. BLCKMATH    - Performs math operations on blocks of text.
  17.  
  18.                                 Copyright 1989 by American Cybernetics, Inc.
  19. ******************************************************************************}
  20.  
  21. $MACRO S_AND_R;
  22. {*******************************MULTI-EDIT MACRO*******************************
  23.  
  24. Name:    S_AND_R
  25.  
  26. Description:    Search and search/replace interface.
  27.  
  28. Parameters:
  29.                             /BC=    Number of boxes to kill after exiting
  30.                             /Y=        The Y coordinate for the prompt box
  31.  
  32. Returns:            Return_Int = 0 if <ESC> was pressed at the prompts.
  33.                             Return_Int = 1 if search was carried through.
  34.                             Global_Int('FOUND_COUNT') = # of occurrences found.
  35.  
  36. Globals used:
  37.  
  38.                             Global_Str('Switches')      The search switches:
  39.                                                                                 I - Ignore case
  40.                                                                                 G - Global, search entire file
  41.                                                                                 N - No prompts, search and replace
  42.                                                                                         unconditionally
  43.                                                                                 P - Prompt for repeated searches/replaces
  44.                                                                                 B - Search backwards
  45.                                                                                 X - Regular expressions off.  Faster if
  46.                                                                                         regs not needed.
  47.                                                                                 R - Restrict search to marked block
  48.                                                                                 C - Don't move cursor to the right after
  49.                                                                                         a replace has occured between
  50.                                                                                         multiple searches and replaces.
  51.                                                                                         Applies only to search and replace.
  52.                             GLOBAL_STR('SEARCH_STR')    String to search for.
  53.                             GLOBAL_STR('REPLACE_STR')    String to replace with.
  54.                             GLOBAL_INT('SEARCH_MODE')    Mode 0=search 1=seach and replace
  55.                             GLOBAL_INT('REPSEARCH')        Simply repeat search or search/replace
  56.                                                                                 according to previous search.  No box
  57.                                                                                 with prompts.
  58.  
  59.                              (C) Copyright 1989 by American Cybernetics, Inc.
  60. ******************************************************************************}
  61.  
  62.     DEF_INT( FoundNum, count, jm, jz, JX, Start_Row, Box_Ofs,t_col, kill_count, tp,hl );
  63.     DEF_INT( Back_Search, Search_Mode, Restrict, Restrict_Count, orig_line );
  64.     DEF_INT( GLOBALSEARCH, noprompt, S_Prompt,Searching,temp_ins, S_RES ,
  65.                     No_Cursor_Movement,New_Line_Num);
  66.     DEF_STR( Search_Str,Replace_Str,SpareString[200], Switches_Str[20], help_str[20],
  67.                     Interface_Mac );
  68.  
  69.  
  70.     kill_count := parse_int('/BC=', mparm_str );
  71.     start_row := parse_int('/Y=', mparm_str);
  72.     if start_Row = 0 then
  73.         start_row := 3;
  74.     end;
  75.     Box_Ofs := 0;
  76.  
  77.     Push_Undo;
  78.  
  79.     help_str := 'SEARCH';
  80.     Search_Str := GLOBAL_STR('SEARCH_STR');
  81.     Replace_Str := GLOBAL_STR('REPLACE_STR');
  82.     Search_Mode := GLOBAL_INT('SEARCH_MODE');
  83.  
  84.     if search_mode then
  85.         sparestring := 'REPL_SWITCHES';
  86.     else
  87.         sparestring := 'SWITCHES';
  88.     end;
  89.     Switches_Str := Global_Str(sparestring);
  90.  
  91.     FoundNum := 0;
  92.     count := 0;
  93.  
  94.     IF GLOBAL_INT('REPSEARCH') = 0 THEN
  95.  
  96.         If Search_Mode THEN
  97.             Box_Ofs := 1;
  98.         END;
  99.         if search_mode then
  100.             help_str := 'SRCHREPL';
  101.         end;
  102.         Set_Global_Int('MENU_RESULT',FALSE);
  103.  
  104. {This allows the user to call an alternate search interface}
  105.         Interface_Mac := Global_Str('@SRCH_INTR_MACRO!');
  106.         IF (Interface_Mac = '') THEN
  107.             Interface_Mac := 'SRCHINTR ';
  108.         END;
  109.         IF (XPOS(' ',Interface_Mac,1) = 0) THEN
  110.             Interface_Mac := Interface_Mac + ' ';
  111.         END;
  112.  
  113.             {Call the search/replace user interface macro}
  114.         RM(Interface_Mac + '/M=' + str( search_mode ) + '/H=' + help_str +
  115.                     '/X=1/Y=' + str(start_Row) + '/SRG=SEARCH_STR/RPG=REPLACE_STR/SWG='
  116.                 + sparestring);
  117.  
  118.         search_str := Global_Str('SEARCH_STR');
  119.         replace_str := Global_Str('REPLACE_STR');
  120.         switches_str := Global_Str( sparestring );
  121.         IF NOT( Return_Int ) THEN
  122.             Goto S_AND_R_EXIT;
  123.         END;
  124.     END;
  125.  
  126.     Return_Int := True;
  127.     while box_count > kill_count do
  128.         kill_box;
  129.     end;
  130.     refresh := true;
  131.  
  132. Start_Search:
  133.     Switches_Str := CAPS( Switches_Str );
  134.     Ignore_Case := (XPos('I',Switches_Str,1) <> 0);
  135.  
  136.     GlobalSearch := (XPos('G',Switches_Str,1) <> 0);
  137.     If Global_Int('REPSEARCH') <> 0 THEN
  138.         GlobalSearch := false;
  139.     end;
  140.     NoPrompt := (XPos('N',Switches_Str,1) <> 0);
  141.     S_Prompt := (XPos('P',Switches_Str,1) <> 0);
  142.     Back_Search := (XPos('B',Switches_Str,1) <> 0);
  143.     No_Cursor_Movement := False;
  144.     IF (Search_Mode = True) THEN
  145.         SpareString := Search_Str;
  146.         Return_Str := Replace_Str;
  147.         IF (Ignore_Case) THEN
  148.             SpareString := Caps(SpareString);
  149.             Return_Str := Caps(Return_Str);
  150.         END;
  151.         IF (SpareString <> Return_Str) THEN
  152. {Don't allow 'C' switch if search_str = replace_str.  This would cause a
  153. continuous loop}
  154.             No_Cursor_Movement := (XPos('C',Switches_Str,1) <> 0);
  155.         END;
  156.         Set_Global_Str('!SREV#1', '/T=Replace/KC=<ENTER>/W=14/K1=13/K2=28/R=1/Y=' + str(message_row) + '/X=' + str(message_col));
  157.         Set_Global_Str('!SREV#2', '/T= Skip/KC=<Space>/W=12/K1=32/K2=57/R=2/Y=' + str(message_row) + '/X=' + str(message_col + 14));
  158.         Set_Global_Str('!SREV#3', '/T= Abort/KC=<ESC>/W=11/K1=27/K2=1/R=3/Y=' + str(message_row) + '/X=' + str(message_col + 26));
  159.         Set_Global_Str('!SREV#4', '/T= Non-Stop/KC=<CtrlN>/W=16/K1=14/K2=49/R=4/Y=' + str(message_row) + '/X=' + str(message_col + 37));
  160.     ELSE
  161.         Set_Global_Str('!SREV#1', '/T=Search again/KC=<Any key>/W=21/K1=13/K2=28/R=1/Y=' + str(message_row) + '/X=' + str(message_col));
  162.         Set_Global_Str('!SREV#2', '/T= Abort/KC=<ESC>/W=11/K1=27/K2=1/R=2/Y=' + str(message_row) + '/X=' + str(message_col + 21));
  163.     END;
  164.     Reg_Exp_Stat := (XPos('X',Switches_Str,1) = 0);
  165.     restrict_count := 0;
  166.     orig_line := c_line;
  167.     Mark_Pos;
  168.     Restrict := XPos('R',Switches_Str,1) <> 0;
  169.     If (Restrict) THEN
  170.         if block_stat = 0 THEN
  171.             RM('USERIN^VERIFY /H=SR/BL=NO BLOCK MARKED/T=Perform search on file?');
  172.             IF return_int = 0 THEN
  173.                 make_message('No block marked.');
  174.               refresh := true;
  175.               redraw;
  176.               Error_level := 0;
  177.                 goto s_and_r_exit;
  178.             END;
  179.             restrict := 0;
  180.         END;
  181.         IF restrict and ((C_Line < Block_Line1) or (C_Line > Block_Line2)) THEN
  182.             Goto Restrict1;
  183.         END;
  184.     END;
  185.  
  186.     IF GlobalSearch = TRUE THEN
  187.     Restrict1:
  188.         IF Back_Search THEN
  189.             If Restrict THEN
  190.                 Goto_Line( Block_Line2 );
  191.                 EOL;
  192.             ELSE
  193.                 EOF;
  194.             END;
  195.         ELSE
  196.             If Restrict THEN
  197.                 Goto_Line( Block_Line1 );
  198.                 Goto_Col( 1 );
  199.             ELSE
  200.                 GOTO_Line(1);
  201.                 Goto_Col(1);
  202.             END;
  203.         END;
  204.     END;
  205.  
  206.     make_message('');
  207.     Temp_Ins := Insert_Mode;
  208.     Insert_Mode := TRUE;
  209.     searching := TRUE;
  210.  
  211.     IF NoPrompt AND Search_Mode THEN
  212.         Refresh := FALSE;
  213.     END;
  214.  
  215.     Error_level := 0;
  216.  
  217.     WHILE Searching do
  218.         refresh := false;
  219.         IF NoPRompt THEN
  220.             If Search_Mode THEN
  221.                 make_message( 'Searching... Replaces:' + str(count) + ' <CtrlBREAK> to abort.');
  222.             ELSE
  223.                 make_message( 'Searching... Occurrences:' + str(foundnum) + ' <CtrlBREAK> to abort.');
  224.             END;
  225.         ELSE
  226.             make_message('Searching...   <CtrlBREAK> to abort.');
  227.         END;
  228.         WORKING;
  229.         orig_line := c_line;
  230.         IF Back_Search THEN
  231.             If Restrict Then
  232.                 Restrict_Count := C_Line - Block_Line1 + 1;
  233.                 if restrict_count < 1 then
  234.                     goto search_out;
  235.                 end;
  236. sagain2:
  237.                 S_Res := Search_BWD(Search_Str, Restrict_Count );
  238.                 if s_res then
  239.                     if block_stat > 1 then
  240. {
  241.                     if block_stat = 2 then
  242. }
  243.                         if (c_col < block_col1) or (c_col > block_Col2) then
  244.                             call searchmove;
  245.                             goto sagain2;
  246.                         end;
  247.                     end;
  248.                 end;
  249.             ELSE
  250.                 S_Res := Search_BWD(Search_Str, Restrict_Count );
  251.             END;
  252.         ELSE
  253.             If Restrict Then
  254.                 Restrict_Count := Block_Line2 - C_Line + 1;
  255.                 if restrict_count < 1 then
  256.                     goto search_out;
  257.                 end;
  258. sagain:
  259.                 S_Res := Search_FWD(Search_Str, Restrict_Count );
  260.                 if s_res then
  261.                     if block_stat > 1 then
  262. {
  263.                     if block_stat = 2 then
  264. }
  265.                         if (c_col < block_col1) or (c_col > block_Col2) then
  266.                             call searchmove;
  267.                             goto sagain;
  268.                         end;
  269.                     end;
  270.                 end;
  271.             ELSE
  272.                 S_Res := Search_FWD(Search_Str, Restrict_Count );
  273.             END;
  274.         END;
  275. {This only occurs if user pressed <CTRL-BREAK>}
  276.         If Error_Level = 1015 Then
  277.             Make_message('Search aborted by user.');
  278.             refresh := true;
  279.             redraw;
  280.             Error_level := 0;
  281.             GOTO S_And_R_Exit;
  282.         end;
  283.         IF S_Res THEN
  284.             IF FoundNum = 0 THEN
  285.                 Pop_Mark;
  286.             END;
  287.             ++FoundNum;
  288.             IF NOPROMPT = FALSE THEN
  289.                 make_message('');
  290.             END;
  291.             IF Search_Mode THEN
  292.                 CALL Do_Replace_Prompt;
  293.             ELSE
  294.                 CALL Do_Search_Prompt;
  295.             END;
  296.         ELSE
  297.             Searching := FALSE;
  298.             IF FoundNum = 0 THEN
  299.                 Goto_Mark;
  300.             END;
  301.         END;
  302.     END;
  303. search_out:
  304.     Set_Global_Int('MENU_RESULT',TRUE);
  305.  
  306.   if Search_Mode then                                                 { ldh }
  307.     call Center_Line;                                                 { ldh }
  308.   end;                                                                { ldh }
  309.     Make_Message('String Found ' + STR(FoundNum) + ' Times.');
  310.     Refresh := TRUE;
  311.     Insert_Mode := Temp_Ins;
  312.     GOTO S_And_R_Exit;
  313.  
  314.  
  315. Do_Replace_Prompt:
  316.     IF noprompt = FALSE THEN
  317.         call highlight_find;
  318.         IF NOT(S_Prompt) THEN
  319.             Searching := False;
  320.         END;
  321.         Make_Message('');
  322.         RM('UserIn^CheckEvents /M=2/G=!SREV#/#=4');
  323. key_loop1:
  324.         Read_Key;
  325.         IF (key1 = 0) AND (key2 = 250) THEN
  326.             RM('UserIn^CheckEvents /M=1/G=!SREV#/#=4');
  327.         ELSE
  328.             RM('UserIn^CheckEvents /M=0/G=!SREV#/#=4');
  329.         END;
  330.         IF return_int THEN
  331.             return_int := parse_int('/R=', return_str);
  332.         ELSE
  333.             goto key_loop1;
  334.         END;
  335.         make_message('');
  336.         IF return_int = 2 THEN
  337.             call searchmove;
  338.             RET;
  339.         ELSIF return_int = 4 THEN
  340.             noprompt := true;
  341.             goto NON_STOP;
  342.         ELSIF return_int = 3 THEN
  343.             Searching := FALSE;
  344.             RET;
  345.         ELSIF return_int = 1 THEN
  346.             T_Col := C_Col;
  347.             Replace( Replace_Str );
  348.             IF (No_Cursor_Movement) THEN
  349.                 Goto_Col(T_Col);
  350.             ELSE
  351.                 If Back_Search THEN
  352.                     Goto_Col(T_Col);
  353.                     Left;
  354.                 ELSE
  355.                     while NOT(at_eol) and (cur_char = '|255') do
  356.                         right;
  357.                     END;
  358.                     IF At_Eol then
  359.                         right;
  360.                     end;
  361.                 END;
  362.             END;
  363.             ++count;
  364.             Redraw;
  365.             RET;
  366.         END;
  367.         goto do_replace_prompt;
  368.     ELSE
  369. NON_STOP:
  370.         T_Col := C_Col;
  371.         Replace( Replace_Str );
  372.         IF (No_Cursor_Movement) THEN
  373.             Goto_Col(T_Col);
  374.         ELSE
  375.             If Back_Search THEN
  376.                 Goto_Col(T_Col);
  377.                 Left;
  378.             ELSE
  379.                 while NOT(at_eol) and (cur_char = '|255') do
  380.                     right;
  381.                 END;
  382.                 IF At_Eol then
  383.                     right;
  384.                 end;
  385.             END;
  386.         END;
  387.         ++count;
  388.     END;
  389.     RET;
  390.  
  391. highlight_find:
  392.     refresh := false;
  393.     if c_line > orig_line then
  394.         if (c_line - orig_line) <= ((win_y2 - win_y1) - c_row) then
  395.             tp := c_line;
  396.             goto_line(orig_line);
  397.             while c_line <> tp do
  398.                 down;
  399.             end;
  400.     else                                                              { ldh }
  401.       call Center_Line;                                               { ldh }
  402.         end;
  403.     else
  404.         if (orig_line - c_line) <= ((win_y2 - win_y1) - ((win_y2 - (win_y1 + c_row)))) then
  405.             tp := c_line;
  406.             goto_line(orig_line);
  407.             while c_line <> tp do
  408.                 up;
  409.             end;
  410.     else                                                              { ldh }
  411.       call Center_Line;                                               { ldh }
  412.         end;
  413.     end;
  414.     refresh := true;
  415.     redraw;
  416.     sparestring := found_str;
  417.     expand_tabs( sparestring, hl );
  418.     hl := length( sparestring );
  419.     tp := c_col;
  420.     goto_col(c_col + hl);
  421.     goto_col(tp);
  422.     if (win_x2 - wherex) < hl then
  423.         hl := win_x2 - wherex;
  424.     end;
  425.     draw_attr( wherex, wherey, h_color or ($80), hl);
  426.     ret;
  427.  
  428. Do_Search_Prompt:
  429. IF (Noprompt) THEN
  430.     Call searchmove;
  431.     ret;
  432. END;
  433.  
  434.     IF NOT(S_Prompt) THEN
  435.         call highlight_find;
  436.         Make_Message('String Found ' + STR(FoundNum) + ' Times.');
  437.         Searching := False;
  438.         Read_Key;
  439.         push_key(key1,key2);
  440.         RET;
  441.     END;
  442.     call highlight_find;
  443.     Make_Message('');
  444.     RM('UserIn^CheckEvents /M=2/G=!SREV#/#=2');
  445. key_loop2:
  446.     Read_Key;
  447.     IF (key1 = 0) AND (key2 = 250) THEN
  448.         RM('UserIn^CheckEvents /M=1/G=!SREV#/#=2');
  449.     ELSE
  450.         RM('UserIn^CheckEvents /M=0/G=!SREV#/#=2');
  451.         IF return_int = 0 THEN
  452.             return_int := 1;
  453.             goto search_promptx;
  454.         END;
  455.     END;
  456.     IF return_int THEN
  457.         return_int := parse_int('/R=', return_str);
  458.     ELSE
  459.         goto key_loop2;
  460.     END;
  461. search_promptx:
  462.     make_message('');
  463.     IF return_int = 2 THEN
  464.         Searching := FALSE;
  465.     ELSE
  466.         call searchmove;
  467.     END;
  468.     RET;
  469.  
  470. searchmove:
  471.         IF Back_Search THEN
  472.             LEFT;
  473.         ELSE
  474.             RIGHT;
  475.             while not(at_eol) and (cur_char = '|255') do
  476.                 right;
  477.             end;
  478.             IF At_Eol then
  479.                 right;
  480.             end;
  481.         END;
  482.         ret;
  483.  
  484. {<<<Added 12-Apr-90 ldh *****************************************************}
  485. Center_Line:
  486.   New_Line_Num := C_Line;
  487. {These 6 lines will center the selected line on the screen if possible}
  488.   WHILE (C_Row > ((Win_Y2 - Win_Y1) / 2)) DO
  489.     Up;
  490.   END;
  491.   WHILE (C_Row < ((Win_Y2 - Win_Y1) / 2)) DO
  492.     Down;
  493.   END;
  494.   Goto_Line(New_Line_Num);
  495.   ret;
  496. {******************************************************************* Added>>>}
  497.  
  498. s_and_r_exit:
  499.     RM('UserIn^CheckEvents /M=3/F=1/G=!SREV#/#=4');
  500.     Set_Global_Int('FOUND_COUNT', foundnum);
  501.     Pop_Undo;
  502.     SET_GLOBAL_INT('REPSEARCH',0);
  503.     Reg_Exp_Stat := True;
  504.     redraw;
  505. END_MACRO;
  506.  
  507. $MACRO SrchIntr;
  508. {*******************************MULTI-EDIT MACRO******************************
  509.  
  510. Name: SrchIntr
  511.  
  512. Description:  Search (and Replace) User Interface.  This macro is called
  513.                             by S_AND_R.
  514.  
  515. Parameters:        /M=n    Mode, 0 = Search, 1 = Search and Replace
  516.                             /H=str Help String
  517.                             /X=n    X coordinate
  518.                             /Y=n    Y coordinate
  519.                             /SRG=str  Name of the global_str to put the search str in
  520.                             /RPG=str  Name of the global_str to put the replace str in
  521.                             /SWG=str  Name of the global_str to put the switches str in
  522.                             /SWONLY=1    Edit switches only
  523.  
  524. Returns:
  525.                         Return_Int > 0 IF START_SEARCH WAS SELECTED
  526.  
  527.                (C) Copyright 1989 by American Cybernetics, Inc.
  528. ******************************************************************************}
  529.         Def_Int( search_mode,x,y, sr_pos, rp_pos, sw_pos, go_pos );
  530.         Def_Int( ic, gs, ps, regs, rb, continuous, bs, np, smode, cs, count, am );
  531.         Def_Str( help_str[40] );
  532.  
  533.         help_str := Global_Str(parse_str('/SWG=', mparm_str));
  534.  
  535.         ic := (xpos( 'I', help_str, 1 ) = 0);
  536.         gs := (xpos( 'G', help_str, 1 ) <> 0);
  537.         ps := (xpos( 'P', help_str, 1 ) <> 0);
  538.       bs := (xpos( 'B', help_str, 1 ) = 0);
  539.         continuous := (xpos( 'N', help_str, 1 ) <> 0);
  540.         regs := (xpos( 'X', help_str, 1 ) = 0);
  541.         rb := (xpos( 'R', help_str, 1 ) <> 0);
  542.         np := (xpos( 'N', help_str, 1 ) <> 0);
  543.         cs := (xpos( 'C', help_str, 1 ) <> 0);
  544.         smode := 1;
  545.         IF np THEN
  546.             smode := 3;
  547.         END;
  548.         IF ps THEN
  549.             smode := 2;
  550.         END;
  551. {
  552.         help_str := global_str( '@SEARCH_ORDER' );
  553.         IF help_str <> '' THEN
  554.             sr_pos := parse_int('/SR=', help_str );
  555.             rp_pos := parse_int('/RP=', help_str );
  556.             sw_pos := parse_int('/SW=', help_str );
  557.             go_pos := parse_int('/GO=', help_str );
  558.         ELSE
  559. }
  560.             sr_pos := 1;
  561.             rp_pos := 2;
  562.             go_pos := 3;
  563.             sw_pos := 4;
  564. {
  565.         END;
  566. }
  567.  
  568.         x := parse_int('/X=',mparm_str);
  569.         y := parse_int('/Y=',mparm_str);
  570.         IF x = 0 THEN
  571.             x := 2;
  572.         END;
  573.         IF y = 0 THEN
  574.             y := 3;
  575.         END;
  576.  
  577.         search_mode := parse_int( '/M=', mparm_str );
  578.  
  579.         IF search_mode = 0 THEN
  580.             sr_pos := sr_pos - (rp_pos < sr_pos);
  581.             sw_pos := sw_pos - (rp_pos < sw_pos);
  582.             go_pos := go_pos - (rp_pos < go_pos);
  583.         END;
  584.  
  585.         IF parse_int('/SWONLY=', mparm_str) THEN
  586.             am := 2;
  587.             sw_pos := 1;
  588.             count := 6 + search_mode;
  589.         ELSE
  590.             am := 3;
  591.             count := (search_mode * 2) + 8;
  592.             Set_Global_Str('SRISTR_' + str(sr_pos),
  593.                                                     Global_Str(parse_str('/SRG=', mparm_str)));
  594.             Set_Global_Str('SRIPARM_'+ str(sr_pos),'/T=Search For:/C=1/W=63/ML=254/HISTORY=SEARCH_HISTORY');
  595.             If Search_Mode THEN
  596.                 Set_Global_Str('SRISTR_' + str(rp_pos),Global_Str(parse_str('/RPG=', mparm_str)));
  597.                 Set_Global_Str('SRIPARM_' + str(rp_pos),'/HISTORY=REPLACE_HISTORY/T=Replace With:/C=1/W=61/ML=254');
  598.             Set_Global_Str('SRIPARM_' + str(go_pos),'/T=>>>>/TP=6/W=24/C=1');
  599.             Set_Global_Str('SRISTR_' + str(go_pos),'START SEARCH AND REPLACE');
  600.             ELSE
  601.             Set_Global_Str('SRIPARM_' + str(go_pos),'/T=>>>>/TP=6/W=12/C=1');
  602.             Set_Global_Str('SRISTR_' + str(go_pos),'START SEARCH');
  603.             END;
  604.         END;
  605.         Set_Global_Str('SRISTR_' + str(sw_pos + 0),'/F=Backward/T=Forward');
  606.         Set_Global_Int('SRIINT_' + str(sw_pos + 0), bs);
  607.         Set_Global_Str('SRIPARM_' + str(sw_pos + 0),'/TP=5/T=Search direction:   /C=1/W=8');
  608.         IF search_mode THEN
  609.       Set_Global_Str('SRISTR_' + str(sw_pos + 1),'Replace first occurrence only()Prompt for each replace()replace All occurrences()');
  610.             Set_Global_Int('SRIINT_' + str(sw_pos + 1), smode);
  611.             Set_Global_Str('SRIPARM_' + str(sw_pos + 1),'/TP=3/T=Mode:               /C=1/W=29');
  612.         ELSE
  613.       Set_Global_Str('SRISTR_' + str(sw_pos + 1),'Stop on first occurrence()Prompt for next search()Find all occurrences without stopping()');
  614.             Set_Global_Int('SRIINT_' + str(sw_pos + 1), smode);
  615.             Set_Global_Str('SRIPARM_' + str(sw_pos + 1),'/TP=3/T=Mode:               /C=1/W=37');
  616.         END;
  617.  
  618.         Set_Global_Str('SRISTR_' + str(sw_pos + 2),'/T=X');
  619.         Set_Global_Int('SRIINT_' + str(sw_pos + 2), ic);
  620.         Set_Global_Str('SRIPARM_' + str(sw_pos + 2),'/TP=5/T=Case sensitive:     /C=1/W=1/L=' + str(sw_pos + 3));
  621.  
  622.         Set_Global_Str('SRISTR_' + str(sw_pos + 4),'/T=X');
  623.         Set_Global_Int('SRIINT_' + str(sw_pos + 4), regs);
  624.         Set_Global_Str('SRIPARM_' + str(sw_pos + 4),'/TP=5/T=Regular expressions:/C=1/W=1/L=' + str(sw_pos + 4));
  625.  
  626.         Set_Global_Str('SRISTR_' + str(sw_pos + 3),'/T=X');
  627.         Set_Global_Int('SRIINT_' + str(sw_pos + 3), gs);
  628.         Set_Global_Str('SRIPARM_' + str(sw_pos + 3),'/TP=5/T=Global search:           /C=37/W=1/L=' + str(sw_pos + 3));
  629.  
  630.         Set_Global_Str('SRISTR_' + str(sw_pos + 5),'/T=X');
  631.         Set_Global_Int('SRIINT_' + str(sw_pos + 5), rb);
  632.         Set_Global_Str('SRIPARM_' + str(sw_pos + 5),'/TP=5/T=Restrict to marked block:/C=37/W=1/L=' + str(sw_pos + 4));
  633.  
  634.         Set_Global_Str('SRISTR_' + str(sw_pos + 6),'/F=End of replace string/T=Start of replace string');
  635.         Set_Global_Int('SRIINT_' + str(sw_pos + 6), cs);
  636.         Set_Global_Str('SRIPARM_' + str(sw_pos + 6),'/TP=5/T=Leave cursor at:    /C=1/W=23');
  637.  
  638.         IF search_mode THEN
  639.             help_str := 'SEARCH AND REPLACE';
  640.         ELSE
  641.             help_str := 'SEARCH';
  642.         END;
  643.         RM('USERIN^Data_In /PRE=SR/S=1/A=' + str(am) + '/#=' + str( count ) +
  644.                     '/X=' + str(x) + '/Y='+Str(y) +'/T=' + help_str + '/H=' + parse_str('/H=', mparm_str));
  645.         IF search_mode and (parse_int('/SWONLY=', mparm_str) = 0) THEN
  646.             Set_Global_Str(parse_str('/RPG=', mparm_str), Global_Str('SRISTR_' + str(rp_pos)));
  647.         END;
  648.  
  649.         help_str := '';
  650.         IF global_int('SRIINT_' + str(sw_pos)) = 0 THEN
  651.             help_str := help_str + 'B';
  652.         END;
  653.         smode := global_int('SRIINT_' + str(sw_pos + 1));
  654.         IF smode = 2 THEN
  655.             help_str := help_str + 'P';
  656.         ELSIF smode = 3 THEN
  657.             help_str := help_str + 'N';
  658.         END;
  659.  
  660.         IF global_int('SRIINT_' + str(sw_pos + 2)) = 0 THEN
  661.             help_str := help_str + 'I';
  662.         END;
  663.         IF global_int('SRIINT_' + str(sw_pos + 3)) THEN
  664.             help_str := help_str + 'G';
  665.         END;
  666.         IF global_int('SRIINT_' + str(sw_pos + 4)) = 0 THEN
  667.             help_str := help_str + 'X';
  668.         END;
  669.         IF global_int('SRIINT_' + str(sw_pos + 5)) THEN
  670.             help_str := help_str + 'R';
  671.         END;
  672.         IF global_int('SRIINT_' + str(sw_pos + 6)) THEN
  673.             help_str := help_str + 'C';
  674.         END;
  675.  
  676.  
  677.         Set_Global_Str(parse_str('/SWG=', mparm_str), help_str);
  678.         IF parse_int('/SWONLY=', mparm_str) = 0 THEN
  679.             Set_Global_Str(parse_str('/SRG=', mparm_str), Global_Str('SRISTR_' + str(sr_pos)));
  680.         END;
  681.  
  682.         ic := 0;
  683.         WHILE ic < 15 DO
  684.             Set_Global_Str( 'SRISTR_' + str(ic),'');
  685.             Set_Global_Int( 'SRIINT_' + str(ic),0);
  686.             ++ic;
  687.         END;
  688. END_MACRO;
  689.  
  690. $MACRO SEARCH FROM EDIT;
  691. {*******************************MULTI-EDIT MACRO*******************************
  692.  
  693. Name:    SEARCH
  694.  
  695. Description:    Calls S_and_R in search only mode.
  696.  
  697.                              (C) Copyright 1989 by American Cybernetics, Inc.
  698. ******************************************************************************}
  699.     SET_GLOBAL_INT('SEARCH_MODE',0);
  700.     SET_GLOBAL_INT('REPSEARCH',0);
  701.     RM( 'S_AND_R '+mparm_str);
  702. END_MACRO;
  703.  
  704. $MACRO S_REPL FROM EDIT;
  705. {*******************************MULTI-EDIT MACRO*******************************
  706.  
  707. Name:    S_REPL
  708.  
  709. Description:    Calls S_and_R in search and replace mode.
  710.  
  711.                              (C) Copyright 1989 by American Cybernetics, Inc.
  712. ******************************************************************************}
  713.     SET_GLOBAL_INT('SEARCH_MODE',1);
  714.     SET_GLOBAL_INT('REPSEARCH',0);
  715.     RM( 'S_AND_R '+mparm_str );
  716. END_MACRO;
  717.  
  718. $MACRO REPSRCH;
  719. {*******************************MULTI-EDIT MACRO*******************************
  720.  
  721. Name:    S_REPL
  722.  
  723. Description:    Calls S_and_R in search and replace mode.
  724.  
  725.                              (C) Copyright 1989 by American Cybernetics, Inc.
  726. ******************************************************************************}
  727.  
  728.     Mark_Pos;
  729.  
  730.     IF XPOS('B',Caps(Global_Str('SWITCHES')),1) THEN
  731.         Left;
  732.     ELSE
  733.         Right;
  734.         while NOT(at_eol) and (cur_char = '|255') do
  735.             right;
  736.         END;
  737.     END;
  738.     IF (Global_Str('SEARCH_STR') <> '') THEN
  739.         SET_GLOBAL_INT('REPSEARCH',1);
  740.     END;
  741.     RM( 'S_AND_R /NG=1' + mparm_str );
  742.  
  743.     If (return_int > 0) and (global_int('FOUND_COUNT') = 0) Then
  744.         Goto_Mark;
  745.         Make_Message('No more occurrences.');
  746.     ELSE
  747.         Pop_Mark;
  748.     END;
  749. END_MACRO;
  750.  
  751.  
  752. $MACRO FS TRANS;
  753. {*******************************MULTI-EDIT MACRO******************************
  754.  
  755. Name: fs
  756.  
  757. Description:  Multi-File search.  Will prompt for a filespec (wild cards are
  758.                             allowed), a search string    and search switches, and (using
  759.                             MEFIND.EXE) perform a search through all the files matching the
  760.                             filespec, and then put up a list of all the matching files.  The
  761.                             user may then select one of the files, and the cursor will
  762.                             automatically go the the line where the match was found.
  763.  
  764. Parameters:        /N=        Skips directly to the filename list, using the last
  765.                                         set of files found by MEFIND.
  766.                             /Y=        The Y coordinate of the prompt box
  767.                             /X=        The X coordinate of the prompt box
  768.  
  769.  
  770.                              (C) Copyright 1989 by American Cybernetics, Inc.
  771. ******************************************************************************}
  772.  
  773.         def_str( search_str[80], switches_str[10], filespec[80], sstr );
  774.         def_int( t_win, file_count, str_count, nl, nc, jx, x1, y1, t_swap_mem );
  775.         def_int( search_dirs, use_reg_exp, case_sensitive, result );
  776.         def_str( tc[1] );
  777.  
  778.  
  779.         t_win := window_id;
  780.         refresh := false;
  781.  
  782.         result := 0;
  783.  
  784.         switches_str := caps(Global_Str('FSWITCHES'));
  785.         use_reg_exp := xpos('R',switches_str, 1) <> 0;
  786.         case_sensitive := xpos('C',switches_str, 1) <> 0;
  787.         search_dirs := xpos('S',switches_str, 1) <> 0;
  788.  
  789.         y1 := parse_int('/Y=', mparm_str);
  790.         if y1 = 0 then
  791.             y1 := 4;
  792.         ELSE
  793.             --Y1;
  794.         end;
  795.  
  796.         x1 := parse_int('/X=', mparm_str);
  797.         if x1 = 0 then
  798.             x1 := 4;
  799.         end;
  800.  
  801.         if xpos('/N', caps(mparm_str), 1 ) then
  802.             sstr := me_path + user_id + 'MEFIND.TMP';
  803.             if switch_file(sstr) then
  804.                 goto make_file_menu;
  805.             else
  806.                 goto load_find_file;
  807.             end;
  808.         end;
  809.  
  810.         search_str := Global_Str('SEARCH_STR');
  811.  
  812.         filespec := Global_Str('FFILESPEC');
  813.  
  814.         Set_Global_Str('ISTR_1',filespec);
  815.         Set_Global_Str('IPARM_1','/HISTORY=FILESPEC_HISTORY/T=Filespec:/C=1/W=60/ML=80/L=1');
  816.         Set_Global_Str('ISTR_2',Search_Str);
  817.         Set_Global_Str('IPARM_2','/HISTORY=SEARCH_HISTORY/T=Search For:/C=1/W=63/ML=128/H=FILESEARCH/L=2');
  818.     Set_Global_Str('IPARM_3','/T=>>>>/C=1/H=FILESEARCH/W=17/L=3/TP=6');
  819.     Set_Global_Str('ISTR_3','START FILE SEARCH');
  820.  
  821.         Set_Global_Int('IINT_4',search_dirs);
  822.         Set_Global_Str('ISTR_4','/T=X');
  823.         Set_Global_Str('IPARM_4','/T=Search Subdirectories:/C=1/W=1/L=4/TP=5');
  824.         Set_Global_Str('ISTR_5',global_str('FSEARCH_PATH'));
  825.         Set_Global_Str('IPARM_5','/T=Starting path:        /C=1/W=40/L=5');
  826.         Set_Global_Int('IINT_6',case_sensitive);
  827.         Set_Global_Str('ISTR_6','/T=X');
  828.         Set_Global_Str('IPARM_6','/T=Case Sensitive:       /C=1/W=1/L=6/TP=5');
  829.         Set_Global_Int('IINT_7',use_reg_exp);
  830.         Set_Global_Str('ISTR_7','/T=X');
  831.         Set_Global_Str('IPARM_7','/T=Regular Expressions:  /C=1/W=1/L=7/TP=5');
  832.  
  833.         RM('UserIn^Data_In /H=FILESEARCH/S=1/A=3/#=7/X=1/T=SEARCH FILES/Y=' + str(y1));
  834.         filespec := global_str('ISTR_1');
  835.         search_str := global_str('ISTR_2');
  836.         SET_GLOBAL_STR('FLAST_CHOICE', '');
  837.         set_Global_Str('FFILESPEC', filespec);
  838.         set_Global_Str('SEARCH_STR', search_str);
  839.         set_Global_Str('FSEARCH_STR', search_str);
  840.  
  841.         search_dirs := global_int('IINT_4');
  842.         set_global_str('FSEARCH_PATH', global_str('ISTR_5'));
  843.         case_sensitive := global_int('IINT_6');
  844.         use_reg_exp := global_int('IINT_7');
  845.  
  846.         set_global_str('ISTR_1','');
  847.         set_global_str('ISTR_2','');
  848.         set_global_str('ISTR_3','');
  849.         set_global_str('ISTR_4','');
  850.         set_global_str('ISTR_5','');
  851.         set_global_str('ISTR_6','');
  852.         set_global_str('ISTR_7','');
  853.  
  854.         switches_str := '';
  855.         sstr := '/D /F' + ME_PATH + USER_ID + 'MEFIND.TMP ' +
  856.                         '/P' +  global_str('FSEARCH_PATH') + ' ';
  857.         if use_reg_exp then
  858.             sstr := sstr + '/R ';
  859.             switches_str := 'R';
  860.         end;
  861.         if case_sensitive then
  862.             sstr := sstr + '/C ';
  863.             switches_str := switches_str + 'C';
  864.         end;
  865.         if search_dirs then
  866.             sstr := sstr + '/S ';
  867.             switches_str := switches_str + 'S';
  868.         end;
  869.  
  870.         set_Global_Str('FSWITCHES', switches_str);
  871.  
  872.         if return_int then
  873.             working;
  874.             put_box(4,y1,72,y1 + 15, 0, m_b_color, 'Searching through files', true);
  875.             draw_char(196,5,y1+2,m_b_color,64);
  876.             write('Press <ESC> to abort search.',23,y1 + 14, 0, m_b_color );
  877.             gotoxy(5, y1 + 1);
  878.             if switch_file( me_path + user_id + 'MEFIND.TMP' ) then
  879.                 delete_window;
  880.             end;
  881.             t_swap_mem := swap_mem;
  882.             swap_mem := 6250;
  883.             shell_to_dos(me_path + 'MEFIND.EXE ' + filespec + ' ' + sstr + '/X /E' + search_str, false);
  884.             swap_mem := t_swap_mem;
  885.             kill_box;
  886.  
  887.             set_Global_Str('SEARCH_STR', search_str);
  888.             sstr := '';
  889.             if case_sensitive = 0 then
  890.                 sstr := sstr + 'I';
  891.             end;
  892.             if use_reg_exp = 0 then
  893.                 sstr := sstr + 'X';
  894.             end;
  895.  
  896.             set_global_str('SWITCHES', sstr);
  897.             SET_GLOBAL_INT('SEARCH_MODE',0);
  898.  
  899.             jx := exit_code;
  900.             if jx <> 0 then
  901.                 IF jx = 2 THEN
  902.                     sstr := 'Error writing to ' + me_path + USER_ID +
  903.                             'MEFIND.TMP, file may be marked READ-ONLY.  To reset, load in the file,' +
  904.                             ' toggle its LOCKED status from the MAIN - File - Information menu, and then save the file.';
  905.                 ELSIF jx = 3 THEN
  906.                     sstr := 'Multi-file search aborted by user.';
  907.                 ELSE
  908.                     sstr := 'Search string may be invalid.';
  909.                 END;
  910.                 rm('MEERROR^MessageBox /B=2/T=Multi-File Search Error/M=' + sstr );
  911.                 goto exitx;
  912.             end;
  913.             if error_level = 0 then
  914.      load_find_file:
  915.                 if switch_file( me_path + user_id + 'MEFIND.TMP' ) then
  916.                     delete_window;
  917.                 end;
  918.                 switch_window( window_count );
  919.                 create_window;
  920.      no_create:
  921.                 window_attr := window_attr or $81;  {make it hidden and invisible}
  922.                 if error_level = 0 then
  923.                     load_file( ME_PATH + USER_ID + 'MEFIND.TMP' );
  924.                     if error_level = 0 then
  925.  
  926.         make_file_menu:
  927.                         tof;
  928.                         IF at_eof THEN
  929.               RM('MEERROR^MESSAGEBOX /B=2/T=NO MATCHED FILES FOUND');
  930.                             goto exitx;
  931.                         end;
  932.                         Set_Global_Str('FSEV1', '/T=Edit file/K1=13/K2=28/R=1/LL=1');
  933.                         Set_Global_Str('FSEV2', '/T=Cancel/K1=27/K2=1/R=0/LL=1');
  934.                         RM('USERIN^WMENU /EV=FSEV/EV#=2/B=1/K=1/T=MATCHED FILES/H=FILESEARCH/X=' + str(x1) +
  935.                                 '/S=' + str(global_int('@FLAST_CHOICE')) +
  936.                                         '/Y=' + str(y1));
  937.  
  938.                         window_attr := window_attr or $81;  {make it hidden and invisible}
  939.                         if return_int <> 1 then
  940.                             switch_win_id(t_win);
  941.                             goto exit;
  942.                         end;
  943.  
  944.                         result := 1;
  945.  
  946.                         jx := insert_mode;
  947.                         insert_mode := FALSE;
  948.                         text('|175');
  949.                         insert_mode := jx;
  950.                         file_changed := false;
  951.                         return_str := shorten_str(get_word(' '));
  952.                         forward_till(':');
  953.                         right;
  954.                         sstr := get_word(' ');
  955.                         if val(nl,sstr) <> 0 then
  956.                         end;
  957.                         set_global_int('@FLAST_CHOICE', c_line);
  958.                         forward_till_not(' ');
  959.                         return_str := fexpand( get_word('') + return_str);
  960.                         IF xpos('|254', return_str,1) <> 0 THEN
  961.                             goto exitx;
  962.                         END;
  963.                         IF switch_file( return_str ) THEN
  964.                             make_message( return_str + ' already loaded.');
  965.                             tof;
  966.                             goto no_load;
  967.                         END;
  968.                         RM('LdFiles /LC=1');
  969.                         if error_level = 0 then
  970.                             Make_Message('"' + File_Name + '" loaded.');
  971.                 no_load:
  972.                             down; down; down; down;
  973.                             goto_line( nl );
  974.                             if format_stat then
  975.                                 up;
  976.                             end;
  977.                             goto_col( 1 );
  978.                             left;
  979.                             reg_exp_stat := XPos('R',switches_str,1);
  980.                             ignore_case := (XPos('C',switches_str,1) = 0);
  981.                             If search_fwd(global_str('FSearch_Str'),0) then
  982.                             end;
  983.                             reg_exp_stat := true;
  984.                         else
  985.                             switch_win_id(t_win);
  986.                         end;
  987.                     else
  988.                         RM('MEERROR^Beeps /C=1');
  989.                         delete_window;
  990.                         error_level := 0;
  991.                     end;
  992.                 end;
  993.             end;
  994.         end;
  995. exit:
  996.     if error_level <> 0 then
  997. exitx:
  998.         switch_win_id(t_win);
  999.     end;
  1000.     return_int := result;
  1001.     update_status_line;
  1002. END_MACRO;
  1003.  
  1004.  
  1005. $MACRO UNDBLK TRANS;
  1006. {*******************************MULTI-EDIT MACRO*******************************
  1007.  
  1008. Name:    UNDBLK
  1009.  
  1010. Description:    Undents the current line marked block
  1011.  
  1012.                              (C) Copyright 1989 by American Cybernetics, Inc.
  1013. ******************************************************************************}
  1014.  
  1015.     Def_Int(jx,j1);
  1016.  
  1017.     Working;
  1018.     Push_Undo;
  1019.     Refresh := False;
  1020.     Messages := False;
  1021.     Mark_Pos;
  1022.     If Marking then
  1023.         block_end;
  1024.     end;
  1025.     IF Block_Stat = 1 THEN
  1026.         Goto_Line(Block_Line1);
  1027.         WHILE C_Line <= Block_Line2 DO
  1028.             First_Word;
  1029.             J1 := C_Col;
  1030.             Tab_Left;
  1031.             If AT_EOL = FALSE THEN
  1032.                 Del_Chars(j1 - C_Col);
  1033.             END;
  1034.             DOWN;
  1035.         END;
  1036.     END;
  1037. Macro_Exit:
  1038.     Refresh := True;
  1039.     Goto_Mark;
  1040.     Messages := True;
  1041.     Pop_Undo;
  1042. END_MACRO;
  1043.  
  1044. $MACRO INDBLK FROM EDIT TRANS;
  1045. {*******************************MULTI-EDIT MACRO*******************************
  1046.  
  1047. Name:    INDBLK
  1048.  
  1049. Description:    Indents the current line marked block
  1050.  
  1051.                              (C) Copyright 1989 by American Cybernetics, Inc.
  1052. ******************************************************************************}
  1053.  
  1054.     Def_Int(Temp_Ins);
  1055.     Push_Undo;
  1056.     Temp_Ins := Insert_Mode;
  1057.     Insert_Mode := True;
  1058.     Refresh := False;
  1059.     Messages := False;
  1060.     Mark_Pos;
  1061.     If Marking then
  1062.         block_end;
  1063.     end;
  1064.     IF Block_Stat = 1 THEN
  1065.         Goto_Line(Block_Line1);
  1066.         WHILE C_Line <= Block_Line2 DO
  1067.             First_Word;
  1068.             IF Not(At_Eol) THEN
  1069.                 Tab_Right;
  1070.             END;
  1071.             DOWN;
  1072.         END;
  1073.     END;
  1074.  
  1075. Macro_Exit:
  1076.     Refresh := True;
  1077.     Insert_Mode := Temp_Ins;
  1078.     Goto_Mark;
  1079.     Pop_Undo;
  1080.     Messages := True;
  1081. END_MACRO;
  1082.  
  1083. $MACRO MARKBLCK FROM EDIT;
  1084. {*******************************MULTI-EDIT MACRO*******************************
  1085.  
  1086. Name:    MARKBLCK
  1087.  
  1088. Description:    Starts and stops line oriented block marking.
  1089.  
  1090.                              (C) Copyright 1989 by American Cybernetics, Inc.
  1091. ******************************************************************************}
  1092.  
  1093.     IF Marking THEN
  1094.         BLOCK_END;
  1095.         Make_Message('Block marked.');
  1096.     ELSE
  1097.         BLOCK_BEGIN;
  1098.         Make_Message('Block marking on.  Press ' + Global_Str('!BM_KEY15') + ' to stop.');
  1099.     END;
  1100. END_MACRO;
  1101.  
  1102. $MACRO MCOLBLCK FROM EDIT;
  1103. {*******************************MULTI-EDIT MACRO*******************************
  1104.  
  1105. Name:    MCOLBLCK
  1106.  
  1107. Description:    Starts and stops column oriented block marking.
  1108.  
  1109.                              (C) Copyright 1989 by American Cybernetics, Inc.
  1110. ******************************************************************************}
  1111.  
  1112.     IF Marking THEN
  1113.         BLOCK_END;
  1114.         Make_Message('Block marked.');
  1115.     ELSE
  1116.         COL_BLOCK_BEGIN;
  1117.         Make_Message('Columnar block marking on.  Press ' + Global_Str('!BM_KEY15') + ' to stop.');
  1118.     END;
  1119. END_MACRO;
  1120.  
  1121. $MACRO MSTRBLCK FROM EDIT;
  1122. {*******************************MULTI-EDIT MACRO*******************************
  1123.  
  1124. Name:    MSTRBLCK
  1125.  
  1126. Description:    Starts and stops stream oriented block marking.
  1127.  
  1128.                              (C) Copyright 1989 by American Cybernetics, Inc.
  1129. ******************************************************************************}
  1130.  
  1131.     IF Marking THEN
  1132.         BLOCK_END;
  1133.         Make_Message('Block marked.');
  1134.     ELSE
  1135.         STR_BLOCK_BEGIN;
  1136.         Make_Message('Stream block marking on.  Press ' + Global_Str('!BM_KEY15') + ' to stop.');
  1137.     END;
  1138. END_MACRO;
  1139.  
  1140. $MACRO BLOCKOFF FROM EDIT TRANS;
  1141. {*******************************MULTI-EDIT MACRO*******************************
  1142.  
  1143. Name:    MARKBLK
  1144.  
  1145. Description:    Turns the current block marking off.
  1146.  
  1147.                              (C) Copyright 1989 by American Cybernetics, Inc.
  1148. ******************************************************************************}
  1149.  
  1150.     IF BLOCK_STAT > 0 THEN
  1151.         Block_Off;
  1152.         Make_Message('Block turned off.');
  1153.     ELSE
  1154.         Make_Message('No Block Marked.');
  1155.     END;
  1156. END_MACRO;
  1157.  
  1158. $MACRO BLOCKOP;
  1159. {*******************************MULTI-EDIT MACRO******************************
  1160.  
  1161. Name:    BLOCKOP
  1162.  
  1163. Description:    Does a block copy or move and then, if hard_cr is being used,
  1164.                             does a reformat on the area under the block.
  1165.  
  1166. Parameters:        /BT=nn        nn is the operation type.
  1167.                                                 0 = Block copy
  1168.                                                 1 = Block Move
  1169.                                                 2 = Block Delete
  1170.                                                 3 = Inter-Window Copy
  1171.                                                 4 = Inter-Window Move
  1172.  
  1173.                              (C) Copyright 1989 by American Cybernetics, Inc.
  1174. ******************************************************************************}
  1175.  
  1176.     def_int( old_refresh, bt, bl, tb );
  1177.  
  1178.     bt := parse_int( '/BT=', mparm_str );
  1179.     tb := block_stat;
  1180.  
  1181.     bl := block_line1;
  1182.  
  1183.     if bt = 3 then
  1184.         RM( 'WINDOW^COPYBL' );
  1185.         tb := block_stat;
  1186.     end;
  1187.     if bt = 4 then
  1188.         RM( 'WINDOW^MOVEBL' );
  1189.         tb := block_stat;
  1190.     end;
  1191.  
  1192.     if block_stat = 0 then
  1193.         make_message('No block marked.');
  1194.         goto exit;
  1195.     end;
  1196.  
  1197.     if bt = 0 then
  1198.         Copy_Block;
  1199.         Make_Message('Block copied.');
  1200.     end;
  1201.     if bt = 1 then
  1202.         Move_Block;
  1203.         Make_Message('Block moved.');
  1204.     end;
  1205.     if bt = 2 then
  1206.         Delete_Block;
  1207.         Make_Message('Block deleted.');
  1208.     end;
  1209.  
  1210.  
  1211.     Old_refresh := refresh;
  1212.     Refresh := false;
  1213.     If (tb <> 0) and (Hard_Cr <> '|0') and (Hard_Cr <> '') THEN
  1214.         Mark_Pos;
  1215.         PUSH_UNDO;
  1216.         goto_line( bl );
  1217.         While C_Line <= Block_Line2 Do
  1218.             RM( 'TEXT^REFORMAT /NR' );
  1219.         end;
  1220.  
  1221.         Goto_Mark;
  1222.         POP_UNDO;
  1223.     END;
  1224. exit:
  1225.     refresh := old_refresh;
  1226. END_MACRO;
  1227.  
  1228. $MACRO CUT TRANS;
  1229. {*******************************MULTI-EDIT MACRO******************************
  1230.  
  1231. Name: CUT
  1232.  
  1233. Description:  Copies, Moves or Appends text into a hidden buffer.
  1234.  
  1235. Parameters:  /M    Move text (else copy text)
  1236.                          /A    Append text (else erase old buffer);
  1237.                          /B=n  n = the buffer # (0 is the default);
  1238.                          /E    Erase buffer, perform no move or copy
  1239.  
  1240.                              (C) Copyright 1989 by American Cybernetics, Inc.
  1241. ******************************************************************************}
  1242.  
  1243.     def_int( buf_num, temp_refresh, source_win, erase_buf, Append_buf, t_block_stat );
  1244.     def_str( buf_name );
  1245.  
  1246.     temp_refresh := refresh;
  1247.     refresh := false;
  1248.     source_win := cur_window;
  1249.     error_level := 0;
  1250.     t_block_stat := block_stat;
  1251.  
  1252.     erase_buf := XPOS('/E', MParm_Str, 1);
  1253.     append_buf := XPOS('/A', MParm_Str, 1);
  1254.     buf_num := parse_int('/B=', Mparm_Str);
  1255.     if buf_num > 999 then
  1256.         buf_num := 999;
  1257.     end;
  1258.     if buf_num < 0 then
  1259.         buf_num := 0;
  1260.     end;
  1261.     buf_name := me_path + '!BUF' + User_Id + '.' + Str(Buf_Num);
  1262.     if switch_file(buf_name) = 0 then
  1263.         switch_window(window_count);
  1264.         create_window;
  1265.         if error_level <> 0 then
  1266.             goto exit;
  1267.         end;
  1268.         window_attr := $81;
  1269.         file_name := buf_name;
  1270.     else
  1271.         window_attr := $81;
  1272.         if (append_buf = 0) or (erase_buf) THEN
  1273.             Erase_Window;
  1274.             file_name := buf_name;
  1275.         ELSE
  1276.             EOF;
  1277.             If (c_col <> 1) then
  1278.                 down;
  1279.                 goto_col(1);
  1280.             end;
  1281.         END;
  1282.     end;
  1283.  
  1284.     if erase_buf = 0 then
  1285.         if t_block_stat = 0 then
  1286.             make_message('No block marked.');
  1287.             goto exit;
  1288.         end;
  1289.         if XPos('/M', MParm_Str,1) = 0 THEN
  1290.             Window_Copy(source_win);
  1291.             IF append_buf THEN
  1292.                 Make_Message('Block appended to buffer ' + Str(buf_num));
  1293.             ELSE
  1294.                 Make_Message('Block copied to buffer ' + Str(buf_num));
  1295.             END;
  1296.         ELSE
  1297.             Window_Move(source_win);
  1298.             Make_Message('Block moved to buffer ' + Str(buf_num));
  1299.         END;
  1300.         if append_buf then
  1301.             eof;
  1302.             block_begin;
  1303.             tof;
  1304.             block_end;
  1305.         end;
  1306.     else
  1307.         Make_Message('Erased buffer ' + str(buf_num));
  1308.     end;
  1309.  
  1310.     file_changed := false;
  1311. exit:
  1312.     switch_window( source_win );
  1313.     refresh := temp_refresh;
  1314. END_MACRO;
  1315.  
  1316. $MACRO PASTE TRANS;
  1317. {*******************************MULTI-EDIT MACRO******************************
  1318.  
  1319. Name:    paste
  1320.  
  1321. Description: Copies block from buffer into current file.
  1322.  
  1323. Parameters:  /B=n     buffer number
  1324.  
  1325.                              (C) Copyright 1989 by American Cybernetics, Inc.
  1326. ******************************************************************************}
  1327.  
  1328.     def_int( buf_num, temp_refresh, source_win, buf_win );
  1329.     def_str( buf_name );
  1330.  
  1331.     temp_refresh := refresh;
  1332.     refresh := false;
  1333.     source_win := cur_window;
  1334.     error_level := 0;
  1335.  
  1336.     buf_num := parse_int('/B=', Mparm_Str);
  1337.     if buf_num > 999 then
  1338.         buf_num := 999;
  1339.     end;
  1340.     if buf_num < 0 then
  1341.         buf_num := 0;
  1342.     end;
  1343.     buf_name := me_path + '!BUF' + User_Id + '.' + Str(Buf_Num);
  1344.  
  1345.     if switch_file(buf_name) = 0 then
  1346. bufferempty:
  1347.         make_message('Nothing to paste in buffer ' +str(buf_num));
  1348.         switch_window( source_win );
  1349.         goto exit;
  1350.     end;
  1351.  
  1352.     window_attr := $81;
  1353.     if block_stat = 0 then
  1354.         goto bufferempty;
  1355.     end;
  1356.     buf_win := cur_window;
  1357.     switch_window( source_win );
  1358.     window_copy( buf_win );
  1359.  
  1360.     make_message( 'Block copied from buffer ' + str(buf_num));
  1361. exit:
  1362.     refresh := temp_refresh;
  1363.  
  1364. END_MACRO;
  1365.  
  1366. $MACRO BLCKMATH TRANS;
  1367. {*******************************MULTI-EDIT MACRO******************************
  1368.  
  1369. Name: BLCKMATH
  1370.  
  1371. Description:  Performs math operations on blocks of numbers.
  1372.  
  1373. Parameters: /O=  [*/-+]   the math operation to perform.
  1374.                                                 If /O= is not specified, the user will be
  1375.                                                 prompted for the operation.
  1376.                         /BC=    Amount of boxes to kill upon exit.
  1377.  
  1378.                              (C) Copyright 1989 by American Cybernetics, Inc.
  1379. ******************************************************************************}
  1380.  
  1381.     def_real( rx, ry );
  1382.     def_str( tstr[80], operation[1] );
  1383.     def_int( jx, tbc , commas, jy,Negative);
  1384.  
  1385.     refresh := false;
  1386.  
  1387.     operation := parse_str('/O=', mparm_str );
  1388.     Commas := false;
  1389.     IF operation = '' THEN
  1390.         tbc := parse_int('/BC=', mparm_str);
  1391.         RM('userin^xmenu /L=Select Operation/B=1' + mparm_str +
  1392.                 '/M=+  (BLOCKMATH)-  ()*  ()/  ()');
  1393.         IF return_int < 1 THEN
  1394.             goto exit;
  1395.         END;
  1396.         operation := copy('+-*/', return_int, 1 );
  1397.         while box_count > tbc do
  1398.             kill_box;
  1399.         end;
  1400.     END;
  1401.  
  1402.     Push_Undo;
  1403.     mark_pos;
  1404.     If marking then
  1405.         block_end;
  1406.     end;
  1407.     rx := 0.0;
  1408.     jx := 0;
  1409.     goto_line( block_line1 );
  1410.     IF block_stat = 2 THEN
  1411.         while (c_line <= block_line2) do
  1412.             goto_col( block_col1 );
  1413.      col_again:
  1414.             while NOT(at_eol) AND
  1415.                         (XPOS(cur_char,'0123456789-.',1) = 0) AND
  1416.                         (c_col < block_col2) DO
  1417.                 RIGHT;
  1418.             END;
  1419.             IF (c_col <= block_col2) THEN
  1420.                 tstr := get_word_in( '0123456789.-,' );
  1421.                 call perform_operation;
  1422.                 IF (c_col < block_col2) AND NOT( at_eol ) THEN
  1423.                     goto col_again;
  1424.                 END;
  1425.             END;
  1426.             down;
  1427.         end;
  1428.     ELSE
  1429.         goto_col( 1 );
  1430.         goto_col( block_col1 );
  1431.         IF (block_stat = 1) or (block_stat = 3) THEN
  1432.             while (c_line <= block_line2) do
  1433.                 while NOT(at_eol) AND
  1434.                             (XPOS(cur_char,'0123456789-.',1) = 0)
  1435.                             DO
  1436.                     RIGHT;
  1437.                 END;
  1438.                 IF (at_eol) or ( (c_line = block_line2) and (c_col > block_col2)) THEN
  1439.                     down;
  1440.                     first_word;
  1441.                 ELSE
  1442.                     tstr := get_word_in( '0123456789.-,' );
  1443.                     call perform_operation;
  1444.                 end;
  1445.             end;
  1446.         END;
  1447.     END;
  1448.     goto_mark;
  1449.     tstr := rstr( rx, 0, 10 );
  1450.     IF xpos( '.', tstr, 1 ) THEN
  1451.         while (copy( tstr, svl(tstr),1 ) = '0') DO
  1452.             tstr := copy( tstr, 1, svl(tstr) - 1 );
  1453.         end;
  1454.         IF (copy( tstr, svl(tstr),1 ) = '.') THEN
  1455.             tstr := copy( tstr, 1, svl(tstr) - 1 );
  1456.         end;
  1457.     END;
  1458.     IF (Commas) THEN
  1459.         Negative := (Xpos('-',Tstr,1) > 0);
  1460.         Jx := Xpos('.',Tstr,1);
  1461.         IF (Jx = 0) THEN
  1462.             Jx := Svl(tstr);
  1463.         ELSE
  1464.             --jx;
  1465.         END;
  1466.         Jx := Jx - Negative;
  1467.         Jy := (jx / 3) - ((Jx mod 3) = 0);
  1468.         WHILE (Jy) DO
  1469.             tstr := Str_Ins(',',tstr,(jx - (Jy * 3)) + 1 + Negative);
  1470.             ++jx
  1471.             --Jy;
  1472.         END;
  1473.     END;
  1474.     text( tstr );
  1475.     Pop_Undo;
  1476.     goto exit;
  1477.  
  1478. perform_operation:
  1479. remove_commas:
  1480.     Jy := XPos(',',Tstr,1);
  1481.     IF (Jy) THEN
  1482.         Commas := True;
  1483.         Tstr := Str_Del(TStr,Jy,1);
  1484.         Goto REMOVE_COMMAS;
  1485.     END;
  1486.     IF rval( ry, tstr ) = 0 THEN
  1487.         ++jx;
  1488.         IF jx = 1 THEN
  1489.             rx := ry;
  1490.         ELSE
  1491.             IF operation = '+' THEN
  1492.                 rx := rx + ry;
  1493.             END;
  1494.             IF operation = '*' THEN
  1495.                 rx := rx * ry;
  1496.             END;
  1497.             IF operation = '-' THEN
  1498.                 rx := rx - ry;
  1499.             END;
  1500.             IF operation = '/' THEN
  1501.                 rx := rx / ry;
  1502.             END;
  1503.         END;
  1504.     END;
  1505.     ret;
  1506. exit:
  1507.  
  1508. END_MACRO;