home *** CD-ROM | disk | FTP | other *** search
/ Piper's Pit BBS/FTP: ibm 0010 - 0019 / ibm0010-0019 / ibm0010.tar / ibm0010 / ME494-6.ZIP / MESYS.SRC < prev    next >
Encoding:
Text File  |  1990-06-13  |  52.0 KB  |  1,966 lines

  1. $MACRO_FILE MESYS;
  2. {******************************************************************************
  3. MESYS is loaded automatically by Multi-Edit upon startup.  Multi-Edit will
  4. abort if it cannot find the MESYS macro file.
  5.  
  6. MESYS contains the following macros:
  7.  
  8. UNDO                    Executes an UNDO or REDO
  9. SETSCRN                Sets up the screen based on the selected style.
  10. XZOOM                    Toggles between screen styles.
  11. INSTGL                Toggles insert/overwrite mode.
  12. BSWORD                Deletes the word before the cursor.
  13. DELWORD                Deletes the word under the cursor.
  14. DELEOL                Delete to end of line.
  15. HOME                    Implements the multi-stroke start of line/window/file function.
  16. END                        Implements the multi-stroke end of line/window/file function.
  17. CR                        Implements carriage return with indenting styles.
  18. DATETIME            Stamps the date and time into a file.
  19. GOTOLINE            Prompts for a line number to go to.
  20. TOPBLOCK            Cursor to top of block.
  21. ENDBLOCK            Cursor to end of block.
  22. TOPWIN                Cursor to top of window.
  23. BOTWIN                Cursor to bottom of window.
  24. SCROLLUP            Scroll the window up one line.
  25. SCROLLDN            Scroll the window down one line.
  26. PAGEBRK                Insert a line with a page break.
  27. FIND_EXT          Retrieves the extension specific setup from EXT.DB.
  28. MAKEUSERPATH    Searches for a user specific file name.  Creates it if neccesary.
  29. XLATECMDLINE    Translates special "aliases", like <FILE>, <EXT>, etc.
  30. SETTABS                Creates a temporary format line from the tab spacing parameter.
  31. EXTSETUP            Setup a file/window format based on its extension.
  32. PATHSEARCH        Searches for a filename in a given path
  33. SETFILENAME     Adds in the default    directory for an extension.
  34. CREATEWINDOW    Creates a new window at the end of the window list.
  35. LDFILES                Load files into windows.  Allows wildcards.
  36. AUTOSAVE            Implements the automatic save feature.
  37. PARMS1                Process command line switches.
  38. PARMLOAD            Load files from the command line.
  39.  
  40. *******************************************************************************}
  41.  
  42.  
  43. $MACRO UNDO;
  44. {*******************************MULTI-EDIT MACRO******************************
  45.  
  46. Name: UNDO
  47.  
  48. Description:  Performs an UNDO or REDO
  49.  
  50. Parameters:        /R                causes a REDO instead of an UNDO
  51.  
  52.                              (C) Copyright 1989 by American Cybernetics, Inc.
  53. ******************************************************************************}
  54.  
  55.     if xpos('/R', caps(mparm_str),1) then
  56.         redo;
  57.     else
  58.         undo;
  59.     end;
  60. END_MACRO;
  61.  
  62. $MACRO SETSCRN;
  63. {*******************************MULTI-EDIT MACRO*******************************
  64.  
  65. Name: SETSCRN
  66.  
  67. Description:    Sets up the screen based on the screen style set in the global
  68.             int CUR_SCRN.  This is setup in the installation and setup menu.
  69.  
  70.                              (C) Copyright 1989 by American Cybernetics, Inc.
  71. ******************************************************************************}
  72.  
  73.         def_int( jx, wx, temp_win, old_row, old_min_col, old_max_col );
  74.         def_int( mb, fx,sx,mx, old_max, old_min, ny1, ny2, tr, nx1, nx2 );
  75.         def_int( w_id, skipg,
  76.                         ignore_icons );
  77.         def_str( win_parms[100], tstr[80]);
  78.         def_char( tchar );
  79.  
  80.         tr := refresh;
  81.         refresh := false;
  82.  
  83.         temp_win := cur_window;
  84.         SET_GLOBAL_INT('@MENUROW@', 0);
  85.  
  86.         old_max := max_window_row;
  87.         old_min := min_window_row;
  88.         old_max_col := max_window_col;
  89.         old_min_col := min_window_col;
  90.  
  91.         ignore_icons := parse_int('/ICON=', mparm_str );
  92.  
  93.         win_parms := parse_str('/P=', mparm_str);
  94.         If parse_int('/M=',mparm_str) = 1 THEN
  95.             min_window_row := parse_int('/MWR=', mparm_str);
  96.             goto set_windows_only;
  97.         END;
  98.         tchar := Char(Global_Int('CUR_SCRN') + 64);
  99.         If (tchar = 'A') or (tchar = 'B') then
  100.             win_parms := global_str('@SCREEN_SET' + tchar);
  101.  
  102.             fx := parse_int( '/F=',win_parms );
  103.             sx := parse_int( '/S=',win_parms );
  104.             mx := parse_int( '/M=',win_parms );
  105.             mb := parse_int( '/MB=', win_parms );
  106.  
  107.             min_window_col := parse_int( '/LB=', win_parms );
  108.             max_window_col := (screen_width + 1) - parse_int( '/RB=', win_parms );
  109.  
  110.             status_macro('');
  111.  
  112.             status_str :=
  113.                 'L:      C:      Multi-Edit ' + version + copy('        ', 1, 8 - length(version)) +
  114.                     '[         ]                                  ';
  115.  
  116.             mode_col := 37;
  117.             insert_col := 54;
  118.             mem_col := 58;
  119.             time_col := 65;
  120.             caps_col := 52;
  121.             record_col := 50;
  122.             line_col := 3;
  123.             col_col := 11;
  124.             message_col := 1;
  125.             message_length := 80;
  126.             working_col := 37;
  127.             Set_Global_Int('COM_MENU_BAR', 0 );
  128.  
  129.  
  130.             IF FX = 0 THEN
  131.                 Fkey_Row := 0;
  132.             ELSE
  133.                 Fkey_Row := Screen_Length;
  134.             END;
  135.  
  136.             If SX = 0 THEN
  137.                 Status_Row := 0;
  138.                 message_row := 1 + (mb <> 0);
  139.             else
  140.                 Status_Row := 1;
  141.                 message_row := 2  + (mb <> 0);
  142.             end;
  143.  
  144.  
  145.             if mx = 0 then
  146.                 message_Row := 0;
  147.                 min_window_row := status_row + 1  + (mb <> 0);
  148.             else
  149.                 min_window_row := message_row + 1;
  150.             end;
  151.             if mb <> 0 THEN
  152.                 Set_Global_Int('COM_MENU_BAR', 1 );
  153.                 menu_bar_row := status_row + 1;
  154.                 menu_bar_col := 1;
  155.             Else
  156.                 menu_bar_row := 0;
  157.             end;
  158.  
  159.             max_window_Row := Screen_Length + (fx = 0);
  160.  
  161.     set_windows_only:
  162.             jx := xpos('/MACRO=', win_parms, 1 );
  163.             if jx <> 0 then
  164.                 tstr := shorten_str(copy( win_parms, jx + 7, 40 ));
  165.                 if tstr <> '' then
  166.                     RM(tstr);
  167.                 end;
  168.             end;
  169. set_windows:
  170.             jx := 0;
  171.             while jx < window_count do
  172.                 IF NOT(ignore_icons AND ((window_attr AND $40) <> 0)) THEN
  173.                     nx1 := win_x1;
  174.                     nx2 := win_x2;
  175.                     IF nx1 = old_min_col THEN
  176.                         nx1 := min_window_col;
  177.                     END;
  178.                     IF nx2 = old_max_col THEN
  179.                         nx2 := max_window_col;
  180.                     END;
  181.                     wx := win_y1 - old_min;
  182.                     ny1 := min_window_row + wx;
  183.  
  184.                     if ny1 > (max_window_Row - 2) then
  185.                         ny1 := max_window_row - 2;
  186.                     end;
  187.                     wx := old_max - win_y2;
  188.                     ny2 := max_window_row - wx;
  189.                     if ny2 < (min_window_row + 2) then
  190.                         ny2 := min_window_row + 2;
  191.                     end;
  192.                     IF (window_attr and $40) <> 0 THEN
  193.                         ny2 := ny1;
  194.                     END;
  195.  
  196.                     Size_window(nx1,ny1,nx2,ny2);
  197.                 END;
  198.                 ++jx;
  199.                 Switch_Window(cur_window + 1);
  200.             end;
  201.         end;
  202.         Mouse := Mouse;
  203.         Mou_Set_Limits( 1, 1, Screen_Width, Screen_Length );
  204.         new_screen;
  205.         refresh := tr;
  206. END_MACRO;
  207.  
  208. $MACRO XZOOM TRANS;
  209. {*******************************MULTI-EDIT MACRO*******************************
  210.  
  211. Name: XZOOM
  212.  
  213. Description:    toggles between screen styles.
  214.  
  215.                              (C) Copyright 1989 by American Cybernetics, Inc.
  216. ******************************************************************************}
  217.  
  218.     def_int(jx);
  219.     jx := Global_Int('CUR_SCRN');
  220.     if jx = 1 then
  221.         jx := 2;
  222.     else
  223.         jx := 1;
  224.     end;
  225.     set_global_int('Cur_Scrn',jx);
  226.     RM('SETSCRN');
  227.     new_screen;
  228. END_MACRO;
  229.  
  230. $MACRO INSTGL;
  231. {*******************************MULTI-EDIT MACRO*******************************
  232.  
  233. Name: INSTGL
  234.  
  235. Description:  toggles between insert and overwrite modes.
  236.  
  237.                              (C) Copyright 1989 by American Cybernetics, Inc.
  238. ******************************************************************************}
  239.  
  240.     Insert_Mode := NOT( Insert_Mode );
  241. END_MACRO;
  242.  
  243. $MACRO BSWORD FROM EDIT;
  244. {*******************************MULTI-EDIT MACRO*******************************
  245.  
  246. Name: BSWORD
  247.  
  248. Description:    This macro deletes the word before the cursor(And you thought it
  249.                             had something to do with cow pies).
  250.  
  251.                              (C) Copyright 1989 by American Cybernetics, Inc.
  252. ******************************************************************************}
  253.  
  254.  
  255.     Push_Undo;
  256.  
  257.     IF C_Col = 1 THEN
  258.         BACK_SPACE;
  259.         GOTO EXIT;
  260.     END;
  261.  
  262.     IF at_eol THEN
  263.         eol;
  264.     END;
  265.     LEFT;
  266.     IF xpos(cur_char,' |9|255',1) THEN
  267. kill_white_space:
  268.         while xpos(cur_char,' |9|255',1) AND (c_col > 1) do
  269.             del_char;
  270.             left;
  271.         END;
  272.     END;
  273.  
  274.  
  275.     IF xpos(cur_char,word_delimits,1) = 0 THEN
  276.         while (xpos(cur_char,word_delimits,1) = 0) AND (c_col > 1) DO
  277.             del_char;
  278.             left;
  279.         END;
  280.         right;
  281.         goto exit;
  282.     END;
  283.  
  284.     while (xpos(cur_char,word_delimits,1) <> 0) AND (c_col > 1) DO
  285.         del_char;
  286.         left;
  287.     END;
  288.     right;
  289.  
  290. EXIT:
  291.     Pop_Undo;
  292. END_MACRO;
  293.  
  294. $MACRO DELWORD FROM EDIT;
  295. {*******************************MULTI-EDIT MACRO*******************************
  296.  
  297. Name: DELWORD
  298.  
  299. Description:    This macro deletes the word after the cursor
  300.  
  301.                              (C) Copyright 1989 by American Cybernetics, Inc.
  302. ******************************************************************************}
  303.     def_int(jx,tr);
  304.  
  305.     tr := refresh;
  306.     jx := 0;
  307.  
  308.     Push_Undo;
  309.  
  310.     If (AT_EOL) THEN
  311.         Del_Char;
  312.         Goto Exit;
  313.     End;
  314.  
  315.     refresh := false;
  316.  
  317. Delete1:
  318.     {IF on white space, then delete only to non-white space }
  319.     IF xpos(cur_char,' |255|9', 1) <> 0 THEN
  320.  
  321.     delete_white_space:
  322.         WHILE NOT(At_Eol) AND (xpos(cur_char,' |255|9', 1) <> 0) DO
  323.             ++jx;
  324.             Del_Char;
  325.         END;
  326.         IF jx = 1 THEN
  327.             goto delete_word_delimits;
  328.         END;
  329.         goto exit;
  330.     END;
  331.  
  332.     ++jx
  333.     IF (XPOS(Cur_Char,Word_Delimits,1) <> 0) THEN
  334.     delete_word_delimits:
  335.         WHILE (NOT(AT_EOL)) AND (XPOS(Cur_Char,Word_Delimits,1) <> 0) DO
  336.             ++jx;
  337.             del_char;
  338.         END;
  339.         GOTO Exit;
  340.     END;
  341.     WHILE (NOT(AT_EOL)) AND (XPOS(Cur_Char,Word_Delimits,1) = 0) DO
  342.         ++jx;
  343.         Del_Char;
  344.     END;
  345.     goto delete_white_space;
  346.  
  347. EXIT:
  348.     refresh := tr;
  349.     Pop_Undo;
  350.  
  351. END_MACRO;
  352.  
  353. $MACRO DELEOL FROM EDIT;
  354. {*******************************MULTI-EDIT MACRO*******************************
  355.  
  356. Name: DELEOL
  357.  
  358. Description:    Deletes to the end of a line
  359.  
  360.                              (C) Copyright 1989 by American Cybernetics, Inc.
  361. ******************************************************************************}
  362.  
  363.     Def_Int(jx);
  364.     Jx := Length(Get_Line);
  365.     Del_Chars(jx - c_col + 1);
  366. END_MACRO;
  367.  
  368. $MACRO HOME;
  369. {*******************************MULTI-EDIT MACRO*******************************
  370.  
  371. Name:    HOME
  372.  
  373. Description:    Implements the home function as follows:
  374.  
  375.             If the home key is pressed once, then the cursor will go to:
  376.                     A.  The current indent level if the cursor is beyond the current
  377.                             indent level.
  378.                     B.    Column 1 if the cursor is less than or equal to the current
  379.                             indent level.
  380.  
  381.             The following stuff requires that the /T=nn parameter be passed to HOME
  382.             where nn is the number of milliseconds to wait for the next keypress.
  383.  
  384.             If the home key is pressed twice in rapid succession and the cursor is NOT
  385.                     at the top of the window, then the cursor will go to the top of the
  386.                     window.  If the cursor is at the top of the window, then the cursor
  387.                     will be moved to the top of the file.
  388.  
  389.             If the home key is pressed three times in rapid succession, then the cursor
  390.                     will be moved to the top of the file.
  391.  
  392.                              (C) Copyright 1989 by American Cybernetics, Inc.
  393. ******************************************************************************}
  394.  
  395.     def_int( k1, k2, tm, tc );
  396.  
  397.     k1 := key1;  k2 := key2;
  398.  
  399.     PUSH_UNDO;
  400. loop:
  401.     tc := c_col;
  402.   IF tc > 1 THEN
  403.     first_word;
  404.   END;
  405.   IF (c_col > 1) AND (c_col < tc) THEN
  406.     goto exit;
  407.   END;
  408.     if (at_eol) then
  409.         if tc > indent_level then
  410.             goto_col(indent_level);
  411.         end;
  412.     else
  413.         if c_col >= tc then
  414.             goto_col(1);
  415.         end;
  416.     end;
  417.  
  418.     tm := Parse_Int( '/T=', MParm_Str );
  419.     IF ( tm > 0 ) THEN
  420.         if check_key then
  421.             goto home_on;
  422.         end;
  423.         delay(TM);
  424.         if check_key then
  425. home_on:
  426.             if (key1 = k1) and (key2 = k2) then
  427.                 if c_row = 1 then
  428.                     goto try_tof;
  429.                 end;
  430.                 while c_row > 1 do
  431.                     up;
  432.                 end;
  433.                 goto_col(1);
  434.                 if check_key then
  435.                     goto home_on2;
  436.                 end;
  437.                 delay(TM);
  438.                 if check_key then
  439.          home_on2:
  440.                     if (key1 = k1) and (key2 = k2) then
  441.     try_tof:
  442.                         tof;
  443.                         goto exit;
  444.                     end;
  445.                 end;
  446.             end;
  447.             goto push_exit;
  448.         end;
  449.     END;
  450.  
  451.     goto exit;
  452.  
  453. push_exit:
  454.     push_key( key1, key2 );
  455.  
  456. exit:
  457.     POP_UNDO;
  458. END_MACRO;
  459.  
  460. $MACRO END;
  461. {*******************************MULTI-EDIT MACRO*******************************
  462.  
  463. Name:    END
  464.  
  465. Description:    Implements the end of line function as follows:
  466.             If the end key is pressed once then, the cursor will go to the end of line.
  467.  
  468.             The following stuff requires that the /T=nn parameter be passed to END
  469.             where nn is the number of milliseconds to wait for the next keypress.
  470.  
  471.             If the end key is pressed twice in rapid succession and the cursor is NOT
  472.                     at the bottom of the window, then the cursor will go to the bottom
  473.                     of the window.  If the cursor is at the bottom of the window, then
  474.                     the cursor will be moved to the end of the file.
  475.  
  476.             If the end key is pressed three times in rapid succession, then the cursor
  477.                     will be moved to the end of the file.
  478.  
  479.                              (C) Copyright 1989 by American Cybernetics, Inc.
  480. ******************************************************************************}
  481.     def_int( k1, k2, wl, tm );
  482.  
  483.     k1 := key1;  k2 := key2;
  484.     PUSH_UNDO;
  485. loop:
  486.     eol;
  487.  
  488.     tm := Parse_Int( '/T=', MParm_Str );
  489.     IF ( tm > 0 ) THEN
  490.         if check_key then
  491.             goto end_on;
  492.         end;
  493.         delay(TM);
  494.         if check_key then
  495.      end_on:
  496.             if (key1 = k1) and (key2 = k2) then
  497.                 wl := win_y2 - win_y1 - 1;
  498.                 if c_row = wl then
  499.                     goto try_eof;
  500.                 end;
  501.                 while c_row < wl do
  502.                     down;
  503.                 end;
  504.                 eol;
  505.                 if at_eof then
  506.                     eof;
  507.                 end;
  508.                 if check_key then
  509.                     goto end_on2;
  510.                 end;
  511.                 delay(TM);
  512.                 if check_key then
  513.             end_on2:
  514.                     if (key1 = k1) and (key2 = k2) then
  515.     try_eof:
  516.                         eof;
  517.                         goto exit;
  518.                     end;
  519.                 end;
  520.             end;
  521.             goto push_exit;
  522.         end;
  523.     END;
  524.  
  525.     goto exit;
  526. push_exit:
  527.     push_key( key1, key2 );
  528.  
  529. exit:
  530.     POP_UNDO;
  531. END_MACRO;
  532.  
  533. $MACRO CR;
  534. {*******************************MULTI-EDIT MACRO******************************
  535.  
  536. Name: CR
  537.  
  538. Description:    Performs a carriage return according to INDENT_STYLE:
  539.                             0 = None.  Just do a plain carriage return
  540.                             1 = Auto.  Indents to first word of previous line.
  541.                             2 = Smart.  Uses language specific smart indenting.
  542.  
  543.                              (C) Copyright 1989 by American Cybernetics, Inc.
  544. ******************************************************************************}
  545.  
  546.     Def_Str(tstr);
  547.     Def_Int(jx, temp_ins);
  548.  
  549.     Push_Undo;
  550.  
  551.         {If auto-indent then}
  552.     IF Indent_Style = 1 THEN
  553.         JX := C_COL;
  554.         FIRST_WORD;
  555.         IF At_EOL = False THEN
  556.             SET_INDENT_LEVEL;
  557.         END;
  558.         GOTO_COL(JX);
  559.         Goto ExitX;
  560.     END;
  561.     IF Indent_Style = 2 THEN
  562.         TStr := Global_Str('.'+Get_Extension(file_name));
  563.         TStr := Parse_Str('LS=',TStr);
  564.         IF TStr <> '' THEN
  565.             RM( TSTR + '^' + Copy(TStr,1,3) + '_IND' );
  566.             If Error_Level <> 0 THEN
  567.                 Error_Level := 0;
  568.                 Make_Message('Smart indent macro NOT found.');
  569.                 Goto ExitX;
  570.             END;
  571.             Goto Exit;
  572.         END;
  573.         GOTO EXITX;
  574.     END;
  575. EXITX:
  576.  
  577.             {If in then insert a hard carriage return if one
  578.              is defined}
  579.     IF  (HARD_CR <> '') and (HARD_CR <> '|0') THEN
  580.         Temp_Ins := Insert_Mode;
  581.         Insert_Mode := True;
  582.         Text(Hard_CR);
  583.         CR;
  584.         IF wrap_stat THEN
  585.             word_wrap_line( FALSE, TRUE );
  586.         END;
  587.         Insert_Mode := Temp_Ins;
  588.     ELSE
  589.         jx := c_col;
  590.         CR;
  591.         if (insert_mode = false) and (jx >= indent_level) then
  592.             goto_col(indent_level);
  593.         end;
  594.     END;
  595. EXIT:
  596.     Pop_Undo;
  597. END_MACRO;
  598.  
  599. $MACRO DATETIME;
  600. {*******************************MULTI-EDIT MACRO******************************
  601.  
  602. Name: DATETIME
  603.  
  604. Description:    Writes the current date and time onto the current line.
  605.  
  606.                              (C) Copyright 1989 by American Cybernetics, Inc.
  607. ******************************************************************************}
  608.  
  609.      TEXT( DATE + ' ' + STR_DEL(TIME,6,3));
  610. END_MACRO;
  611.  
  612. $MACRO GOTOLINE;
  613. {*******************************MULTI-EDIT MACRO******************************
  614.  
  615. Name: GOTOLINE
  616.  
  617. Description:    Prompts for a line number, then moves the cursor to that line.
  618.  
  619. Parameters:
  620.                             /X=        The column to place the prompt box.
  621.                             /Y=        The line to place the prompt box.
  622.  
  623.                              (C) Copyright 1989 by American Cybernetics, Inc.
  624. ******************************************************************************}
  625.  
  626.         DEF_INT(jx,jj);
  627.         Return_Str := '';
  628.         Return_Int := Global_Int('@GOTOLINE#');
  629.         IF return_int < 1 then
  630.             return_int := 1;
  631.         end;
  632.         RM('userin^QUERYBOX /N=1/Min=1/L=' + parse_str('/Y=', mparm_str) +
  633.                     '/C=' + parse_str('/X=', mparm_str) + '/W=12/P=Line number: /T=GO TO LINE/H=GOTOLINE');
  634.         IF Return_Str = 'TRUE' THEN
  635.             GOTO_LINE(return_int);
  636.             Set_Global_Int('@GOTOLINE#', return_int);
  637.             return_int := 100;
  638.         Else
  639.             return_int := 0;
  640.         END;
  641. END_MACRO;
  642.  
  643. $MACRO TOPBLOCK;
  644. {*******************************MULTI-EDIT MACRO******************************
  645.  
  646. Name: TOPBLOCK
  647.  
  648. Description:    Take cursor to top of currently defined block
  649.  
  650.                              (C) Copyright 1989 by American Cybernetics, Inc.
  651. ******************************************************************************}
  652.  
  653.     If Block_Stat <> 0 THEN
  654.         Goto_Line( Block_Line1 );
  655.         If Block_Stat <> 1 THEN
  656.             Goto_Col( Block_Col1 );
  657.         END;
  658.         Redraw;
  659.     END;
  660. END_MACRO;
  661.  
  662. $MACRO ENDBLOCK;
  663. {*******************************MULTI-EDIT MACRO******************************
  664.  
  665. Name: ENDBLOCK
  666.  
  667. Description:    Take cursor to bottom of currently defined block
  668.  
  669.                              (C) Copyright 1989 by American Cybernetics, Inc.
  670. ******************************************************************************}
  671.  
  672.     If Block_Stat <> 0 THEN
  673.         Goto_Line( Block_Line2 );
  674.         If Block_Stat <> 1 THEN
  675.             Goto_Col( Block_Col2 );
  676.         END;
  677.         Redraw;
  678.     END;
  679. END_MACRO;
  680.  
  681. $MACRO TOPWIN;
  682. {*******************************MULTI-EDIT MACRO******************************
  683.  
  684. Name: TOPWIN
  685.  
  686. Description:    Take cursor to top of the window
  687.  
  688.                              (C) Copyright 1989 by American Cybernetics, Inc.
  689. ******************************************************************************}
  690.  
  691.     WHILE (C_Row > 1) DO
  692.         Up;
  693.     END;
  694. END_MACRO;
  695.  
  696. $MACRO BOTWIN;
  697. {*******************************MULTI-EDIT MACRO******************************
  698.  
  699. Name: BOTWIN
  700.  
  701. Description:    Take cursor to bottowm of the window
  702.  
  703.                              (C) Copyright 1989 by American Cybernetics, Inc.
  704. ******************************************************************************}
  705.  
  706.     WHILE (C_Row < ((Win_Y2 - Win_Y1) - 1)) DO
  707.         Down;
  708.     END;
  709. END_MACRO;
  710.  
  711. $MACRO SCROLLUP;
  712. {*******************************MULTI-EDIT MACRO******************************
  713.  
  714. Name: SCROLLUP
  715.  
  716. Description:    Scroll screen up one line
  717.  
  718.                              (C) Copyright 1989 by American Cybernetics, Inc.
  719. ******************************************************************************}
  720.  
  721.     def_int( jx );
  722.     jx := refresh;
  723.     refresh := false;
  724.     Goto_Line(C_Line + 1);
  725.     Redraw;
  726.     refresh := jx;
  727. END_MACRO;
  728.  
  729. $MACRO SCROLLDN;
  730. {*******************************MULTI-EDIT MACRO******************************
  731.  
  732. Name: SCROLLDN
  733.  
  734. Description:    Scroll screen down one line
  735.  
  736.                              (C) Copyright 1989 by American Cybernetics, Inc.
  737. ******************************************************************************}
  738.  
  739.     def_int( jx );
  740.     jx := refresh;
  741.     refresh := false;
  742.     Goto_Line( C_Line - 1 );
  743.     Redraw;
  744.     refresh := jx;
  745. END_MACRO;
  746.  
  747. $MACRO PAGEBRK;
  748. {*******************************MULTI-EDIT MACRO******************************
  749.  
  750. Name: PAGEBRK
  751.  
  752. Description:    Insert a page break
  753.  
  754.                              (C) Copyright 1989 by American Cybernetics, Inc.
  755. ******************************************************************************}
  756.  
  757.     UP;
  758.     EOL;
  759.     CR;
  760.     GOTO_COL(1);
  761.     TEXT( PAGE_STR );
  762.     UP;
  763.     DOWN;
  764. END_MACRO;
  765.  
  766. $MACRO FIND_EXT;
  767. {*******************************MULTI-EDIT MACRO******************************
  768.  
  769. Name: FIND_EXT
  770.  
  771. Description: Makes sure extension specific setup globals are loaded for
  772.     the passed extension.
  773.  
  774. Parameters:        /EXT=str        Str is the extension to use (including the
  775.                                                     leading ".").
  776.  
  777. Returns:
  778.             RETURN_STR contains the name of the global to use to access
  779.             the extension specific setup.
  780.  
  781.                              (C) Copyright 1989 by American Cybernetics, Inc.
  782. ******************************************************************************}
  783.  
  784.     Def_Str(Ext[8]);
  785.  
  786.     Ext := Caps(Parse_Str('/EXT=',MParm_Str));
  787.     IF (Ext = '.') THEN
  788.         Goto DEFAULT;
  789.     END;
  790.     IF (Global_Str(Ext) = '!DEFAULT!') THEN
  791.         goto DEFAULT;
  792.     END;
  793.     IF (Global_Str(Ext) = '') THEN
  794.         RM('USERIN^DB /F=MECONFIG.DB/NDF=1/DPT=EXT.DB/GLO=' + Ext + '/RR=1/FV=' + Copy(Ext,2,3));
  795.         IF (Return_Int = -1) THEN
  796. DEFAULT:
  797.             Set_Global_Str(Ext, '!DEFAULT!');
  798.             Ext := '.DEFAULT';
  799.             IF (Global_Str(Ext) = '') THEN
  800.                 RM('USERIN^DB /F=MECONFIG.DB/NDF=1/DPT=EXT.DB/GLO=' + Ext + '/RR=1/FV=DEFAULT');
  801.             END;
  802.             Return_Int := -1;
  803.         ELSE
  804.             Return_Int := 0;
  805.         END;
  806.         IF xpos( ext + '', Global_Str('EXTENSIONS'), 1 ) = 0 THEN
  807.             Set_Global_Str('EXTENSIONS',Global_Str('EXTENSIONS') + Ext + '');
  808.         END;
  809.     ELSE
  810.         Return_Int := 0;
  811.     END;
  812. EXIT:
  813.     return_str := ext;
  814. END_MACRO;
  815.  
  816. $MACRO MAKEUSERPATH;
  817. {*******************************MULTI-EDIT MACRO******************************
  818.  
  819. Name: MakeUserPath
  820.  
  821. Description: Takes the filename in RETURN_STR and converts it to a
  822.     complete path and filename for the current USER_ID.  Automatically creates
  823.     a .USR subdirectory if one doesn't exist for the current USER_ID.
  824.  
  825. Parameters: /DF=n        1 = Copy default file if specified file doesn't exist.
  826.  
  827.                              (C) Copyright 1989 by American Cybernetics, Inc.
  828. ******************************************************************************}
  829.  
  830.     def_int( t_attr, jx );
  831.     def_str( tstr[120], t_search_rec[64] );
  832.  
  833.     Return_Str := Truncate_Path( return_str );
  834.     t_attr := File_Search_Attr;
  835.     t_search_rec := file_search_rec;
  836.  
  837.     File_Search_Attr := $37;
  838.  
  839.     IF user_id = '' THEN
  840.         Return_Str := Me_Path + Return_Str;
  841.         goto exit;
  842.     END;
  843.     tstr := me_path + user_id + '.USR';
  844.     IF (first_file( tstr ) <> 0) THEN
  845.         IF MkDir( tstr ) <> 0 THEN
  846.             error_level := 3003;
  847.             tstr := me_path;
  848.             goto exit2;
  849.         END;
  850.     END;
  851.     tstr := tstr + '\';
  852. exit2:
  853.     return_str := tstr + return_str;
  854.     File_Search_Attr := $27;
  855.     IF (first_file( return_str ) <> 0) THEN
  856.         IF parse_int('/DF=',mparm_Str) THEN
  857.             jx := Copy_File( me_path + truncate_path(return_str), return_str, false );
  858.         END;
  859.     END;
  860.  
  861. exit:
  862.     file_search_rec := t_search_rec;
  863.     File_Search_Attr := t_attr;
  864. END_MACRO;
  865.  
  866.  
  867. $MACRO XLATECMDLINE;
  868. {*******************************MULTI-EDIT MACRO******************************
  869.  
  870. Name: XlateCmdLine
  871.  
  872. Description:  Translates RETURN_STR so that any occurances of
  873.                             <FILE>, <NAME>, <EXT>, <PATH>, <ME_PATH>, <USER_PATH>
  874.                              are expanded out.
  875.  
  876. Parameters:
  877.                             /F=str    The filename to use.
  878.  
  879.                              (C) Copyright 1989 by American Cybernetics, Inc.
  880. ******************************************************************************}
  881.  
  882.     def_str( fname[128] );
  883.     def_int( jx );
  884.     fname := parse_str('/F=', mparm_str );
  885.  
  886. INSERT_FILE:
  887.     JX := XPOS('<FILE>',Caps(return_str),1);
  888.     IF jx <> 0 THEN
  889.         return_str := Str_Del(return_str,jx,6);
  890.         return_str := Str_Ins(Truncate_Extension(fname),return_str,jx);
  891.         Goto INSERT_FILE;
  892.     END;
  893.  
  894. INSERT_EXT:
  895.     JX := XPOS('<EXT>',Caps(return_str),1);
  896.     IF jx <> 0 THEN
  897.         return_str := Str_Del(return_str,jx,5);
  898.         return_str := Str_Ins(Get_Extension(fname),return_str,jx);
  899.         Goto INSERT_EXT;
  900.     END;
  901.  
  902. INSERT_NAME:
  903.     JX := XPOS('<NAME>',Caps(return_str),1);
  904.     IF jx <> 0 THEN
  905.         return_str := Str_Del(return_str,jx,6);
  906.         return_str := Str_Ins(Truncate_Path(Truncate_Extension(fname)),return_str,jx);
  907.         Goto INSERT_NAME;
  908.     END;
  909.  
  910. INSERT_PATH:
  911.     JX := XPOS('<PATH>',Caps(return_str),1);
  912.     IF jx <> 0 THEN
  913.         return_str := Str_Del(return_str,jx,6);
  914.         return_str := Str_Ins(Get_Path(fname),return_str,jx);
  915.         Goto INSERT_PATH;
  916.     END;
  917.  
  918. INSERT_ME_PATH:
  919.     JX := XPOS('<ME_PATH>',Caps(return_str),1);
  920.     IF jx <> 0 THEN
  921.         return_str := Str_Del(return_str,jx,9);
  922.         return_str := Str_Ins(me_path,return_str,jx);
  923.         Goto INSERT_ME_PATH;
  924.     END;
  925.  
  926. INSERT_COMSPEC:
  927.     JX := XPOS('<COMSPEC>',Caps(return_str),1);
  928.     IF jx <> 0 THEN
  929.         return_str := Str_Del(return_str,jx,9);
  930.         return_str := Str_Ins(comspec,return_str,jx);
  931.         Goto INSERT_COMSPEC;
  932.     END;
  933.  
  934. INSERT_USER_PATH:
  935.     JX := XPOS('<USER_PATH>',Caps(return_str),1);
  936.     IF jx <> 0 THEN
  937.         return_str := Str_Del(return_str,jx,11);
  938.         IF user_id = '' THEN
  939.             return_str := Str_Ins(me_path,return_str,jx);
  940.         ELSE
  941.             return_str := Str_Ins(me_path + user_id + '.USR\',return_str,jx);
  942.         END;
  943.         Goto INSERT_USER_PATH;
  944.     END;
  945.  
  946. INSERT_USER_ID:
  947.     JX := XPOS('<USER_ID>',Caps(return_str),1);
  948.     IF jx <> 0 THEN
  949.         return_str := Str_Del(return_str,jx,9);
  950.         return_str := Str_Ins(User_id,return_str,jx);
  951.         Goto INSERT_USER_ID;
  952.     END;
  953.  
  954. END_MACRO;
  955.  
  956. $MACRO SETTABS;
  957. {*******************************MULTI-EDIT MACRO******************************
  958.  
  959. Name: SETTABS
  960.  
  961. Description: Sets up even interval tab spacing.
  962.  
  963. Parameters: /TS=nn    Tab spacing.
  964.  
  965.                              (C) Copyright 1989 by American Cybernetics, Inc.
  966. ******************************************************************************}
  967.  
  968.     Def_Int( Tab_Size, jx, margin );
  969.     Def_Str( tformat[2048]);
  970.     Tab_Size := Parse_Int('/TS=', mparm_str );
  971.     Margin := Parse_Int('/RM=', mparm_str );
  972.     IF (Margin < 1) or (Margin > 2048) THEN
  973.         Margin := 128;
  974.     END;
  975.     TFormat := ' ';
  976.     While SVL(TFormat) < Margin DO
  977.         Jx := 1;
  978.         While jx < Tab_Size DO
  979.             TFormat := TFormat + ' ';
  980.             ++jx;
  981.         END;
  982.         TFormat := TFormat + '|16';
  983.     END;
  984.     Format_Line := TFormat;
  985.     Format_Stat := False;
  986. END_MACRO;
  987.  
  988.  
  989. $MACRO EXTSETUP;
  990. {*******************************MULTI-EDIT MACRO******************************
  991.  
  992. Name: EXTSETUP
  993.  
  994. Description:    Is called to setup a window/file based on the files extension.
  995.                         If the extension is not found in the global extension list, then
  996.                         the default extension setup is used.
  997.  
  998. Parameters:
  999.                             /PRE=  If 1, then post-load macro will not be run, such as would
  1000.                             be the case if this was run after the file had already been loaded.
  1001.  
  1002. Returns:  Return_Str = default directory for file.
  1003.                              (C) Copyright 1989 by American Cybernetics, Inc.
  1004. ******************************************************************************}
  1005. {Need to find out how right_margin is getting set to 254, then make it so
  1006. that if UT=0 and TS=0 and RM>0, then right_margin will still be set correctly.
  1007. Make_Message('Before RM=' + Str(Right_Margin));
  1008. Read_Key;
  1009. Right_margin := 0;
  1010. }
  1011.     Def_Str(TStr1[2048],TStr2,Tstr3);
  1012.     Def_Int(JX,jy,default);
  1013.  
  1014.     default := false;
  1015.  
  1016.     RM( 'FIND_EXT /EXT=.' + get_extension( file_name ) );
  1017.     Tstr3 := Return_Str;
  1018.     TStr1 := Global_Str(tstr3);
  1019.  
  1020.     Wrap_Stat := Parse_Int('WW=', TStr1 );
  1021.     indent_style := Parse_Int('IND=', TStr1 );
  1022.     IF (Indent_Style > 0) THEN
  1023.         Indent_Style := Indent_Style - 1;
  1024.     END;
  1025.     Doc_Mode := Parse_Int('DOC=', TStr1 );
  1026.  
  1027.     IF Format_Stat = 0 THEN
  1028.         IF (Parse_Int('UF=',TStr1) = 0) THEN
  1029.             JX := Parse_Int('TS=',TStr1);
  1030.             IF (JX <> 0) THEN
  1031.                 RM('SETTABS /TS=' + str( jx ) + '/RM=' + PARSE_str( 'RM=',TStr1 ) );
  1032.                 JX := Parse_Int('RM=',TStr1);
  1033.                 IF (JX <> 0) THEN
  1034.                     Right_Margin := jx;
  1035.                 ELSE
  1036.                     Right_Margin := 80;
  1037.                 END;
  1038. {Here, we are deleting any defined format line from the global to conserve ram}
  1039.                 Jx := XPos('FORMAT=',Tstr1,1);
  1040.                 IF (Jx) THEN
  1041.                     Jy := Length(Parse_Str('FORMAT=',Tstr1));
  1042.                     Set_Global_Str(TStr3,Str_Del(TStr1,Jx,Jy + 8));
  1043.                 END;
  1044.             ELSE
  1045.                 Goto USE_FORMAT;
  1046.             END;
  1047.         ELSE
  1048. USE_FORMAT:
  1049.             TStr2 := Parse_Str('FORMAT=',TStr1);
  1050.             If Tstr2 <> '' then
  1051.                 Format_Line := TStr2;
  1052.                 Format_Stat := false;
  1053.             END;
  1054.             IF (XPos('R',Caps(Format_Line),1) = 0) THEN
  1055. {If there is no right_margin defined in the format line, see if there is one
  1056. defined explicity}
  1057.                 Right_Margin := Parse_Int('RM=',TStr1);
  1058.             END;
  1059.         END;
  1060.     END;
  1061.  
  1062.     IF Parse_Int('/PRE=', MParm_Str) = 0 THEN
  1063.         TStr3 := Parse_Str('LS=', tstr1);
  1064.         RM( copy(tstr3,1,8) + '^' + copy(tstr3,1,3) + 'SETX');
  1065.         error_level := 0;
  1066.         TStr3 := Parse_Str('MAC=',TStr1);
  1067.         If TStr3 <> '' THEN
  1068.             RM(TStr3);
  1069.         END;
  1070.     END;
  1071. EXIT:
  1072. {
  1073. Make_Message('After RM=' + Str(Right_Margin));
  1074. Read_Key;
  1075. }
  1076. END_MACRO;
  1077.  
  1078. $MACRO PATHSEARCH;
  1079. {*******************************MULTI-EDIT MACRO******************************
  1080.  
  1081. Name: PathSearch
  1082.  
  1083. Description: Searches for a filename in a given path
  1084.  
  1085. Parameters:  /F=str     The filename
  1086.  
  1087.                         RETURN_STR contains the path. For example:  "\;C:\ME;C:\MASM"
  1088.  
  1089.                              (C) Copyright 1989 by American Cybernetics, Inc.
  1090. ******************************************************************************}
  1091.  
  1092.     def_str( fname[20], fpath[120] );
  1093.     def_int( jx, jy );
  1094.     fname := parse_str('/F=',mparm_str);
  1095.     jy := 0;
  1096.     fpath := '';
  1097.     goto first_time;
  1098. LOOP:
  1099.     IF jy > length(return_str) THEN
  1100.         RETURN_INT := 0;
  1101.         goto exit;
  1102.     END;
  1103.     CALL parse_path;
  1104. first_time:
  1105.     IF file_exists( fpath + fname ) THEN
  1106.         return_int := 1;
  1107.         return_str := fexpand(fpath + fname);
  1108.         goto exit;
  1109.     END;
  1110.     goto loop;
  1111.  
  1112.     Parse_Path:
  1113.         jx := XPos( ';', return_str, jy + 1 );
  1114.         IF jx = 0 THEN
  1115.             jx := LENGTH( return_str ) + 1;
  1116.         END;
  1117.         fpath := Copy( return_str, jy + 1, jx - jy - 1 );
  1118.         if (SVL(fpath) > 0) AND (copy(fpath,SVL(fpath),1) <> '\') then
  1119.             fpath := fpath + '\';
  1120.         end;
  1121.         jy := jx;
  1122.         RET;
  1123.  
  1124. EXIT:
  1125. END_MACRO;
  1126.  
  1127.  
  1128. $MACRO SETFILENAME;
  1129. {*******************************MULTI-EDIT MACRO******************************
  1130.  
  1131. Name: SETFILENAME
  1132.  
  1133. Description:    Completes a filename (no wildcards).  Adds in the default
  1134.     directory for that extension if none is specified.
  1135.  
  1136. Parameters:        Return_Str = Filename
  1137.  
  1138. Returns:            Return_Str = new Filename
  1139.                              (C) Copyright 1989 by American Cybernetics, Inc.
  1140. ******************************************************************************}
  1141.  
  1142.     def_str( tstr[128], gstr[20] );
  1143.     def_int( jx );
  1144.  
  1145.     tstr := return_str;
  1146.     if get_path(tstr) = '' then
  1147.         RM( 'FIND_EXT /EXT=.' + get_extension( tstr ) );
  1148.         gstr := return_str;
  1149.         return_str := parse_str('DIR=',Global_Str(gstr));
  1150.         RM('PathSearch /F=' + tstr);
  1151.         IF return_int = 0 THEN
  1152.             return_str := parse_str('DIR=',Global_Str(gstr));
  1153.             jx := xpos(';', return_str, 1);
  1154.             IF jx = 0 THEN
  1155.                 jx := length(return_str) + 1;
  1156.             END;
  1157.             return_str := copy(return_str,1, jx - 1);
  1158.             if (Length(return_str) > 0) AND (copy(return_str,Length(Return_Str),1) <> '\') then
  1159.                 return_str := return_str + '\';
  1160.             end;
  1161.             return_str := return_str + tstr;
  1162.         END;
  1163.     END;
  1164. Expand_Exit:
  1165.     return_str := fexpand( return_str );
  1166. END_MACRO;
  1167.  
  1168. $MACRO CREATEWINDOW;
  1169. {*******************************MULTI-EDIT MACRO******************************
  1170.  
  1171. Name: CreateWindow
  1172.  
  1173. Description: Creates a new window at the end of the window list.
  1174.  
  1175.                              (C) Copyright 1989 by American Cybernetics, Inc.
  1176. ******************************************************************************}
  1177.  
  1178.     def_int( jx, tr, x1, x2, y1, y2, ox1,oy1 );
  1179.     def_str( tstr[40] );
  1180.     tr := refresh;
  1181.     refresh := FALSE;
  1182.  
  1183.     jx := cur_window;
  1184.     Switch_Window(Window_COunt);
  1185.     Error_Level := 0;
  1186.     CREATE_WINDOW;
  1187.     IF error_level = 0 THEN
  1188.         screen_num := global_int('@SCREEN_COUNT') + 1;
  1189.         if screen_num <= 1 then
  1190.             screen_num := 2;
  1191.         end;
  1192.         set_global_int('@SCREEN_COUNT', screen_num );
  1193.         tstr := global_str('@INIT_WINDOW_PARMS');
  1194.         IF tstr <> '' THEN
  1195.             x1 := parse_int('/X1=', tstr);
  1196.             x2 := parse_int('/X2=', tstr);
  1197.             y1 := parse_int('/Y1=', tstr);
  1198.             y2 := parse_int('/Y2=', tstr);
  1199.             IF x1 < min_window_col THEN
  1200.                 x1 := min_window_col;
  1201.             END;
  1202.             IF (x2 = 0) OR (x2 > max_window_col) THEN
  1203.                 x2 := max_window_col;
  1204.             END;
  1205.             IF y1 < min_window_row THEN
  1206.                 y1 := min_window_row;
  1207.             END;
  1208.             IF (y2 = 0) OR (y2 > max_window_row) THEN
  1209.                 y2 := max_window_row;
  1210.             END;
  1211.             size_window( x1, y1, x2, y2 );
  1212.         END;
  1213.     ELSE
  1214.         switch_window(jx);
  1215.     END;
  1216.  
  1217.     refresh := TR;
  1218. END_MACRO;
  1219.  
  1220. $MACRO LDFILES;
  1221. {*******************************MULTI-EDIT MACRO******************************
  1222.  
  1223. Name: LDFILES
  1224.  
  1225. Description:    Loads files into windows.  Handles wild card characters.
  1226.                         Normally, LDFILES checks to see if the file is already loaded.
  1227.  
  1228. Parameters:    RETURN_STR = the filename;
  1229.                         /LC=load_count
  1230.                         /MC=max_count
  1231.                         /NW=1            no wildcards allowed.
  1232.                         /NC=1            no check for the file already loaded.
  1233.                         /X=            X coordinate for prompt box.
  1234.                         /Y=            Y coordinate for prompt box.
  1235.                         /PRE=   Will pass this parameter to EXTSETUP
  1236.                         /CW=1        create new window immediately, regardless of /LC=
  1237.  
  1238.  
  1239.                         If LDFILES is entered with LOAD_COUNT
  1240.                         set to zero, then the first file will be loaded into the current
  1241.                         window.  Subsequent files will be loaded into new windows.
  1242.  
  1243. Returns:        Return_Int = LOAD_COUNT.
  1244.  
  1245.                         Also, Global integer LOAD_COUNT will be set to /LC=nn + the
  1246.                         number of    files loaded.
  1247.  
  1248.                              (C) Copyright 1989 by American Cybernetics, Inc.
  1249. ******************************************************************************}
  1250.  
  1251.     Def_Int( Load_Count, lc2 , good_load);
  1252.     Def_Str( Tstr[128], TStr2[128], t_search_rec[64] ,MSTr[128]);
  1253.     def_int( t_win, x1, y1, tr, max_count, wild_cards, load_check,T_File_Search_Attr );
  1254.  
  1255.     x1 := parse_int('/X=', mparm_str);
  1256.     y1 := parse_int('/Y=', mparm_str);
  1257.  
  1258.  
  1259.     good_load := False;
  1260.     t_search_rec := file_search_rec;
  1261.     T_File_Search_Attr := File_Search_Attr;
  1262.     File_Search_Attr := $27;
  1263.  
  1264.     if x1 = 0 then
  1265.         x1 := 2;
  1266.     end;
  1267.     if y1 = 0 then
  1268.         y1 := 2;
  1269.     end;
  1270.     TStr := return_str;
  1271.  
  1272.     load_check := (parse_int('/NC=', mparm_str) = 0);
  1273.     wild_cards := (parse_int('/NW=', mparm_str) = 0);
  1274.     Load_Count := parse_int('/LC=',mparm_str);
  1275.     max_count := parse_int('/MC=',mparm_str);
  1276.     if max_count = 0 then
  1277.         max_count := 1000;
  1278.     end;
  1279.     lc2 := parse_int('/CW=', mparm_str );
  1280.  
  1281.     IF (wild_cards) and ((POS('*',TStr) > 0) or (POS('?',TStr) > 0)) THEN
  1282.         TStr2 := Get_Path(TStr);
  1283.         IF FIRST_FILE(TSTR) = 0 THEN
  1284.             TStr := TStr2 + LAST_FILE_NAME;
  1285.             Call Do_Load_File;
  1286.             WHILE (NEXT_FILE = 0) and (Load_Count < max_count) DO
  1287.                 TStr := TStr2 + LAST_FILE_NAME;
  1288.                 Call Do_Load_File;
  1289.             END;
  1290.         END;
  1291.     ELSE
  1292.         return_str := tstr;
  1293.         RM('SetFileName');
  1294.         tstr := return_str;
  1295.         Call DO_LOAD_FILE;
  1296.     END;
  1297.  
  1298.     Set_Global_Int('LOAD_COUNT',Load_Count);
  1299.     return_int := load_count;
  1300.  
  1301.     GOTO Exit;
  1302.  
  1303. DO_LOAD_FILE:
  1304.     tstr := caps(FExpand(TStr));
  1305.     t_win := cur_window;
  1306.     tr := refresh;
  1307.     refresh := false;
  1308.     if load_check then
  1309.         if switch_file( tstr ) then
  1310.             RM( 'USERIN^VERIFY /H=FL/T=' + tstr + ' already loaded, load again? /L='
  1311.                 + str(y1) + '/C=' + str(x1)  );
  1312.             IF return_int <= 0 then
  1313.                 ++Load_Count;
  1314.                 window_attr := 0;
  1315.                 refresh := tr;
  1316.                 good_load := False;
  1317.               ret;
  1318.             end;
  1319.              switch_window( t_win );
  1320.         end;
  1321.     end;
  1322.  
  1323.     IF (Load_Count + lc2) > 0 THEN
  1324.         Error_Level := 0;
  1325.         If Window_Count >= 100 THEN
  1326.             Goto NO_WINDOWS;
  1327.         END;
  1328.         IF load_count > 0 THEN
  1329.             refresh := FALSE;
  1330.         ELSE
  1331.             refresh := TRUE;
  1332.         END;
  1333.         RM('CreateWindow');
  1334.         Redraw;
  1335.         IF Error_Level <> 0 THEN
  1336. no_windows:
  1337.             Load_Count := 20000;
  1338.             Error_Level := 0;
  1339.             Make_Message('OUT OF WINDOWS!!!');
  1340.             good_load := False;
  1341.             RET;
  1342.         END;
  1343.     END;
  1344.  
  1345.     if load_count = 0 then
  1346.         refresh := tr;
  1347.     end;
  1348.     Make_Message('Loading "' + TStr + '"...');
  1349.  
  1350.     If Load_Count > 0 then
  1351.         XLoad_File(Tstr);
  1352.     Else
  1353.         Load_File(TStr);
  1354.     END;
  1355.  
  1356.     If Error_Level = 3002 then
  1357.         mstr := '';
  1358.         Error_Level := 0;
  1359.         RETURN_INT := 0;
  1360.         IF global_str('@FNF_LOAD_MACRO@') <> '' THEN
  1361.             RM( global_str('@FNF_LOAD_MACRO@') + ' /F=' + tstr );
  1362.         END;
  1363.         IF return_int = 0 THEN
  1364.             If File_Name = '?No-File?' THEN
  1365.                 MStr := TStr + ' NOT Found,  NEW file assumed.';
  1366.                 File_Name := FExpand(TStr);
  1367.             Else
  1368.                 Error_level := 3002;
  1369.                 Mstr := 'Error:'+Str(Error_Level)+' occured loading "' + TStr + '"';
  1370.             END;
  1371.         END;
  1372.     ELSIf error_level <> 0 then
  1373.         RM('MEERROR^ERRMSG');
  1374.         Mstr := '"' + TStr + '":  Error ' + str(error_level) + ' ' + return_str;
  1375.     ELSIF (Load_Count > 0) or (EOF_IN_MEM > 0) THEN
  1376.         If Read_Only THEN
  1377.             TStr := ' (Read-Only).';
  1378.         ELSE
  1379.             TStr := '.';
  1380.         END;
  1381.         Mstr := '"' + File_Name + '" loaded' + tstr;
  1382.     ELSE
  1383.         Mstr := 'Insufficient RAM to load all of file, swapping will occur.';
  1384.     END;
  1385.     IF mstr <> '' THEN
  1386.         Make_Message(MStr);
  1387.     END;
  1388.     if error_level = 0 then
  1389.         RM( 'EXTSETUP /PRE=' + parse_str('/PRE=',mparm_str));
  1390.     end;
  1391.     ++Load_Count;
  1392.     File_Changed := False;
  1393.     good_load := True;
  1394.     RET;
  1395.  
  1396. EXIT:
  1397. test2:
  1398.     file_search_rec := t_search_rec;
  1399.     File_Search_Attr := T_File_Search_Attr;
  1400.     RM('WINDOW^SetWindowNames');
  1401.  
  1402. END_MACRO;
  1403.  
  1404. $MACRO AUTOSAVE;
  1405. {*******************************MULTI-EDIT MACRO******************************
  1406.  
  1407. Name: AUTOSAVE
  1408.  
  1409. Description:    Checks all windows and saves all modified files.  Can be invoked
  1410.                             by the autosave timer system, or as part of the exit macro.
  1411.  
  1412. Parameters:
  1413.               /EX=1  tells autosave to clean up autosave files and save all
  1414.                      changed files if the global autosave_ext was defined.
  1415.  
  1416.               /EX=2  tells autosave to clean up autosave files and exit
  1417.                      if the global autosave_ext was defined.
  1418.  
  1419.   if the global autosave_ext is not defined the parameter /EX has no effect
  1420.  
  1421.                              (C) Copyright 1989 by American Cybernetics, Inc.
  1422. ******************************************************************************}
  1423.  
  1424.     Def_Int(Save_Count,JX,OLD_WIN, t_error, b1, old_refresh);
  1425. {Start of .ASV modification block 1 }
  1426.   Def_Str(f_name, flg_name, ASV_name, save_ext);
  1427.   def_int (t_Ex, tmp_backup);
  1428.  
  1429.   t_Ex := Parse_Int('/EX=', mparm_str);
  1430. {End of .ASV modification block 1 }
  1431.  
  1432.     old_refresh := refresh;
  1433.     Refresh := False;
  1434.     OLD_WIN := CUR_WINDOW;
  1435.     Save_Count := 0;
  1436.     t_error := 0;
  1437.     b1 := 0;
  1438.  
  1439.     JX := 1;
  1440.     While jx <= Window_Count DO
  1441.         Switch_Window(jx);
  1442.         ++jx;
  1443.  
  1444. {Start of .ASV modification block 2 }
  1445.     save_ext := '.' + global_str( 'autosave_ext' );
  1446.     flg_name   := Truncate_Extension(Truncate_Path(File_Name)) + save_ext;
  1447.     IF (t_Ex) THEN
  1448.       IF (Global_Int(flg_name)) THEN
  1449.         if (backups = 2) Then
  1450.           ASV_Name := Backup_Path +
  1451.                       Truncate_Extension(Truncate_Path(File_Name)) +
  1452.                       save_ext;
  1453.         else
  1454.           ASV_Name := Truncate_Extension(File_name) +
  1455.                       save_ext;
  1456.         end;
  1457.         Put_Box( 20, 5, 60, 8, 0, m_s_color, 'REMOVING AUTOSAVE FILES...', TRUE );
  1458.         Draw_Char( 32, 22, 6, m_t_color, 35 );
  1459.         Write( truncate_path( ASV_name ), 26, 6, 0, m_t_color );
  1460.         Set_File_Attr(ASV_name,0);
  1461.         del_file(ASV_name);           {delete autosave file if exiting}
  1462.         File_changed := TRUE;
  1463.       END;
  1464.       save_ext := '.';
  1465.     END;
  1466.     IF ((t_Ex = 2) and (global_str( 'autosave_ext' ) <> '')) THEN
  1467.       goto ASV_quit;
  1468.     END;
  1469. {End of .ASV modification block 2 }
  1470.  
  1471.         IF (File_Changed <> 0) AND ((window_attr AND $80) = 0) THEN
  1472.             IF NOT(b1) THEN
  1473.                 b1 := TRUE;
  1474.                 Put_Box( 20, 5, 60, 8, 0, m_s_color, 'SAVING FILES...', TRUE );
  1475.             END;
  1476.             Draw_Char( 32, 22, 6, m_t_color, 35 );
  1477.             Write( truncate_path( file_name ), 26, 6, 0, m_t_color );
  1478.             If CAPS(File_Name) = '?NO-FILE?' THEN
  1479.                 Refresh := True;
  1480.                 Redraw;
  1481.                 RM( 'MEUTIL1^SAVEFILE' );
  1482.                 Refresh := False;
  1483.             ELSE
  1484. {Start of .ASV modification block 3}
  1485.         IF (save_ext <> '.') THEN
  1486.           f_name := File_Name;
  1487.           if (backups = 2) Then
  1488.             File_Name := Backup_Path +
  1489.                         Truncate_Extension(Truncate_Path(File_Name)) +
  1490.                         save_ext;
  1491.           else
  1492.             File_Name := Truncate_Extension(File_name) +
  1493.                         save_ext;
  1494.           end;
  1495.           Set_Global_Int(flg_name,1);
  1496.           if (CAPS(TRUNCATE_PATH(File_Name)) <> '!BUF.0') and
  1497.             (CAPS(TRUNCATe_PATH(File_Name)) <> 'MEFIND.TMP') then
  1498.             tmp_backup := backups;
  1499.             Backups := 0;
  1500.             SAVE_FILE;
  1501.             Backups := tmp_backup;
  1502.           end;
  1503.           File_Name := f_name;
  1504.           File_Changed := 0;
  1505.         ELSE
  1506.           SAVE_FILE;
  1507.         END;
  1508. {End of .ASV modification block 3}
  1509.             END;
  1510.             IF Error_Level <> 0 THEN
  1511.                 RM( 'MEERROR' );
  1512.                 t_error := true;
  1513.             END;
  1514.             ++Save_Count;
  1515.         END;
  1516. ASV_quit:
  1517.     END;
  1518.     IF b1 THEN
  1519.         kill_box;
  1520.     END;
  1521.     Switch_Window(OLD_WIN);
  1522.     Refresh := old_refresh;
  1523.     return_int := t_error;
  1524. END_MACRO;
  1525.  
  1526. $MACRO AUTOSAVETIMER;
  1527. {*******************************MULTI-EDIT MACRO******************************
  1528.  
  1529. Name: AUTOSAVETIMER
  1530.  
  1531. Description:    Manages autosave timer events.  The timer can be based on the
  1532. amount of time that has passed since the last time the user    pressed a key (or moved
  1533. the mouse), or on an absolute interval.  This macro is only intended to be run
  1534. by assigning it as a timer event macro.  EXAMPLE:
  1535. Timer_Handle := SET_TIMER_EVENT('AUTOSAVETIMER /NOW=0/T=10/S=0', 18, EDIT);
  1536.  
  1537. Parameters:
  1538.                         /NOW= If <> 0, will immediately autosave.  This is for the absolute
  1539.                         interval method.  IF 0, then the keyboard inactivity method is used.
  1540.                         /S= If <> 0, then the complete status of the editor is saved as
  1541.                         well as the files.
  1542.  
  1543.  
  1544.                              (C) Copyright 1989 by American Cybernetics, Inc.
  1545. ******************************************************************************}
  1546.     IF (Global_Int('Menu_Level')) THEN
  1547. {We don't want to autosave in the middle of a menu or prompt}
  1548.         Goto EXIT;
  1549.     END;
  1550.     IF parse_int('/NOW=', mparm_str) THEN
  1551.         goto GO_AUTOSAVE;
  1552.     END;
  1553.     IF global_int('@LAST_AUTOSAVE_TIME') < last_keypress_time THEN
  1554.         IF (last_event_time - last_keypress_time) >= parse_int('/T=', mparm_str) THEN
  1555. GO_AUTOSAVE:
  1556.             set_global_int( '@LAST_AUTOSAVE_TIME', last_event_time );
  1557.             SET_GLOBAL_INT('@TEMP_RETURN_INT', return_int );
  1558.             SET_GLOBAL_STR('@TEMP_RETURN_STR', return_str );
  1559.             RM('AUTOSAVE');
  1560.       IF (Parse_Int('/S=',MParm_Str)) THEN
  1561.                 RM('EXIT^STATUS');
  1562.             END;
  1563.             return_int := Global_Int('@TEMP_RETURN_INT');
  1564.             return_str := Global_Str('@TEMP_RETURN_STR');
  1565.             set_global_int('@TEMP_RETURN_INT',0);
  1566.             set_global_str('@TEMP_RETURN_STR','');
  1567.             update_status_line;
  1568.         END;
  1569.     END;
  1570. EXIT:
  1571. END_MACRO;
  1572.  
  1573. $MACRO SETAUTOSAVE;
  1574. {*******************************MULTI-EDIT MACRO******************************
  1575.  
  1576. Name: SETAUTOSAVE
  1577.  
  1578. Description:    Creates 1 or 2 autosave events from parameters passed by the
  1579. installation and setup screen.
  1580.  
  1581. Parameters:
  1582.                         /H1= Existing timer event handle.  This macro will release this
  1583.                                  handle before assigning a new one to replace it.  The new
  1584.                                  handles are saved into GLOBAL_STR( '@AUTOSAVEPARMS') using
  1585.                                  identical parameter syntax.  You must pass these handles to
  1586.                                  this macro, or they will remain in force.
  1587.                         /H2= Same as above.
  1588.  
  1589.                         /T1= Timeout factor for event 1 in seconds.
  1590.                         /T2= Timeout factor for event 2.
  1591.  
  1592.                         /M1= Timeout method for event 1.
  1593.                                 0=Keyboard inactivity method.
  1594.                                 1=Absolute interval method.
  1595.                         /M2= Timeout method for event 2.
  1596.  
  1597.                              (C) Copyright 1989 by American Cybernetics, Inc.
  1598. ******************************************************************************}
  1599.  
  1600.     def_int( h1,h2,T1,T2,M1,M2,S1,S2);
  1601.     def_str( astr[80] );
  1602.  
  1603.     astr := Global_str('@AUTOSAVEPARMS');
  1604.     h1 := parse_int('/H1=', astr );
  1605.     h2 := parse_int('/H2=', astr );
  1606.     m1 := 0;
  1607.     m2 := 0;
  1608.     S1 := parse_int('/S1=', mparm_str );
  1609.     S2 := parse_int('/S2=', mparm_str );
  1610.     IF h1 <> 0 THEN
  1611.         kill_timer_event( h1 );
  1612.         h1 := 0;
  1613.     END;
  1614.     IF h2 <> 0 THEN
  1615.         kill_timer_event( h2 );
  1616.         h2 := 0;
  1617.     END;
  1618.     T1 := parse_int('/T1=', mparm_str ) * 18;
  1619.     T2 := parse_int('/T2=', mparm_str ) * 18;
  1620.     IF T1 > 0 THEN
  1621.         M1 := parse_int('/M1=', mparm_str );
  1622.         IF M1 = 0 THEN
  1623.             h1 := set_timer_event('AUTOSAVETIMER /T=' + str( T1 ) + '/S=' + Str(S1), 28, EDIT);
  1624.         ELSIF M1 = 1 THEN
  1625.             h1 := set_timer_event('AUTOSAVETIMER /NOW=1/S=' + Str(S1), T1, edit);
  1626.         END;
  1627.     END;
  1628.     IF T2 > 0 THEN
  1629.         M2 := parse_int('/M2=', mparm_str );
  1630.         IF M2 = 0 THEN
  1631.             h2 := set_timer_event('AUTOSAVETIMER /T=' + str( T2 ) + '/S=' + Str(S2), 28, EDIT);
  1632.         ELSIF M2 = 1 THEN
  1633.             h2 := set_timer_event('AUTOSAVETIMER /NOW=1/S=' + Str(S2), T2, edit);
  1634.         END;
  1635.     END;
  1636.  
  1637.     Set_Global_STR( '@AUTOSAVEPARMS', '/H1=' + str(H1) + '/H2=' + str(H2) +
  1638.                                     '/M1=' + str(M1) + '/M2=' + str(M2) +
  1639.                                     '/T1=' + str(T1 / 18) + '/T2=' + str(T2 / 18) +
  1640.                                     '/S1=' + str(S1) + '/S2=' + str(S2)
  1641.                                     );
  1642.  
  1643. END_MACRO;
  1644.  
  1645. $MACRO PARMS1 DUMP;
  1646. {*******************************MULTI-EDIT MACRO******************************
  1647.  
  1648. Name:    PARMS1
  1649.  
  1650. Description:    Called by Multi-Edit internally to process most command line
  1651.         parameters.  Gets called before PARMLOAD, after INIT and before STARTUP.
  1652.  
  1653.                              (C) Copyright 1989 by American Cybernetics, Inc.
  1654. ******************************************************************************}
  1655.  
  1656.     Def_Int(Parm_Number);
  1657.     Def_Int(jx, default_back, kspeed );
  1658.     Def_Str(TStr);
  1659.     Def_CHar(Tchar);
  1660.  
  1661.     kspeed := (Global_Int('NO_KEYSPEED') = 0);
  1662.  
  1663.          {Do we need to set default colors?}
  1664.     if global_int('DEFAULT_COLORS') then
  1665.         intr($11);
  1666.         if (r_ax and $0030) = $0030 then
  1667.             call set_mono;
  1668.         else
  1669.             call set_color;
  1670.         end;
  1671.     end;
  1672.  
  1673.     Parm_Number := 1;
  1674.     WHILE Parm_Number <= PARAM_COUNT DO
  1675.         TStr := Caps(PARAM_STR(Parm_Number));
  1676.         IF XPOS(Copy(TStr,1,1),'/-',1) <> 0 THEN
  1677.             TStr := Copy(TStr,2,80);
  1678.             TChar := Copy(Tstr,1,1);
  1679.             IF (Length(TSTR) > 1) and (XPos(Copy(Tstr,2,1),'0123456789',1) <> 0) then
  1680.                 IF VAL(jx, Copy(Tstr,2,8)) = 0 then
  1681.                 end;
  1682.             ELSE
  1683.                 If (Length(tstr) = 2) and (XPOS(Copy(Tstr,2,1), 'YN', 1) <> 0) then
  1684.                     IF (Copy(Tstr,2,1) = 'Y') then
  1685.                         jx := true;
  1686.                     else
  1687.                         jx := false;
  1688.                     end;
  1689.  
  1690.                     IF TChar = 'K' THEN
  1691.                         Set_Global_Int('NO_KEYSPEED', jx = 0 );
  1692.                         kspeed := jx;
  1693.                     end;
  1694.                     If TChar = 'N' then
  1695.                         Name_Line := jx;
  1696.                     end;
  1697.                     If TChar = 'L' then
  1698.                         Logo_Screen := jx;
  1699.                     end;
  1700.                 ELSE
  1701.                     If (Length(TStr) = 1) THEN
  1702. {This is a list of command line options that occurs if a /? is used on the
  1703. command line.}
  1704.                         IF (Tchar = '?') THEN
  1705.                             Write_Sod('The following command line options are available:|13|10');
  1706.                             Write_Sod('  /LN = Disable logo,  /LY = Enable logo|13|10');
  1707.                             Write_Sod('  /MN = Mouse disable, /MY = Mouse enable|13|10');
  1708.                             Write_Sod('  /KN = Don''t change keyspeed, /KY = Change keyspeed|13|10');
  1709.                             Write_Sod('  /NR = No restore;  Does not change the setup|13|10');
  1710.                             Write_Sod('  /B  = Use black and white colors, /C = Use default colors|13|10');
  1711.                             Write_Sod('  /Xn = Sets screen width to n.|13|10');
  1712.                             Write_Sod('  /Yn = Sets screen height to n.|13|10');
  1713.                             Write_Sod('  /An = Sets memory for DOS to n.|13|10');
  1714.                             Write_Sod('  /O  = OS/2 switch on.|13|10');
  1715.                             Write_Sod('  /EN = Don''t try to use enhanced keyboard|13|10');
  1716.                             Write_Sod('  /D  = Use direct video.  Bypass Desq-View/Windows|13|10');
  1717.                             Write_Sod('  /V  = Don''t wait for retrace on CGA video I/O.|13|10');
  1718.                             Write_Sod('  /R macro_name = Run the macro: macro_name.|13|10');
  1719.                             Write_Sod('  /#  = Use MONROE style video adapter.|13|10');
  1720.                             Write_Sod('  /EMSOFF = Do NOT use expanded memory.|13|10');
  1721.                             Write_Sod('  /EMSX = Use EMS for macros and spell checker.');
  1722.                             quit(0);
  1723.                         END;
  1724.                         If TChar = 'B' THEN
  1725.                             {/B force monochrome defaults}
  1726.                             Set_Global_Int('COM_DEFAULT_COLORS',1);
  1727.                             call set_mono;
  1728.                         END;
  1729.                         If TChar = 'C' then
  1730.                             Set_Global_Int('COM_DEFAULT_COLORS',1);
  1731.                             call set_color;
  1732.                         END;
  1733.                     END;
  1734.                 END;
  1735.             END;
  1736.         Next_While:
  1737.         END;
  1738.         Parm_Number := Parm_Number + 1;
  1739.     END;
  1740.  
  1741.     IF kspeed THEN
  1742.         R_BX := (Global_Int('KEYDELAY') shl 8) or GLOBAL_INT('KEYSPEED');
  1743.         R_AX := $0305;
  1744.         INTR( $16 );
  1745.         Set_Global_Int('NO_KEYSPEED', 0 );
  1746.     END;
  1747.     goto exit;
  1748.  
  1749. color_defaults:
  1750.     stat1_color := lightgray or default_back;
  1751.     stat2_color := white or default_back;
  1752.     message_color := lightgray or default_back;
  1753.     fnum_color := lightgray or default_back;
  1754.     fkey_color := 112;
  1755.     w_t_color := LightGray or default_back;
  1756.     w_s_color := yellow or default_back;
  1757.     w_b_color := lightgray or default_back;
  1758.     w_h_color := 112;
  1759.     w_eof_color := white or default_back;
  1760.     w_c_color := white or default_back;
  1761.     m_t_color := LightGray or default_back;
  1762.     m_s_color := white or default_back;
  1763.     m_b_color := white or default_back;
  1764.     m_h_color := 112;
  1765.     d_t_color := m_t_color;
  1766.     d_s_color := m_s_color;
  1767.     d_b_color := m_b_color;
  1768.     d_h_color := m_h_color;
  1769.     h_t_color := lightgray or default_back;
  1770.     h_s_color := white or default_back;
  1771.     h_r_color := yellow or default_back;
  1772.     h_b_color := lightgray or default_back;
  1773.     h_h_color := 112;
  1774.     h_f_color := 112;
  1775.     h_t1_color := 33;
  1776.     h_t2_color := 41;
  1777.     h_t3_color := 240;
  1778.     working_color := 240;
  1779.   background_color := default_back or white;
  1780.     Error_color := white or default_back;
  1781.     Shadow_Color := LightGray or default_back;
  1782.     Shadow_Char := Char(177);
  1783.     ret;
  1784.  
  1785. set_color:
  1786.     default_back := $10;
  1787.     Call Color_Defaults;
  1788.     working_color := (red shl 4) or $80;
  1789.   error_color := (red shl 4) or white;
  1790.     w_eof_color := default_back or red;
  1791.   w_b_color := default_back or lightcyan;
  1792.   w_s_color := default_back or yellow;
  1793.     m_t_color := lightgray shl 4;
  1794.     m_s_color := (lightgray shl 4) + blue;
  1795.     m_b_color := lightgray shl 4;
  1796.   m_h_color := magenta shl 4;
  1797.     h_s_color := default_back or $F;
  1798.     h_t1_color := default_back or $B;
  1799.     h_t2_color := default_back or $C;
  1800.     h_t3_color := 127;
  1801.     d_t_color := m_t_color;
  1802.     d_s_color := m_s_color;
  1803.     d_b_color := m_b_color;
  1804.     d_h_color := m_h_color;
  1805.     shadow_color := $08;
  1806.     shadow_char := '|0';
  1807.   background_color := default_back;
  1808.     ret;
  1809.  
  1810. set_mono:
  1811.     default_back := 0;
  1812.     Call Color_Defaults;
  1813.     ret;
  1814.  
  1815. exit:
  1816. END_MACRO;
  1817.  
  1818. $MACRO PARMLOAD DUMP;
  1819. {*******************************MULTI-EDIT MACRO******************************
  1820.  
  1821. Name:    PARMLOAD
  1822.  
  1823. Description:    This macro is called by Multi-Edit directly after STARTUP.  It
  1824.                             takes care of loading in files and executing macros from the
  1825.                             command line.
  1826.  
  1827.                              (C) Copyright 1989 by American Cybernetics, Inc.
  1828. ******************************************************************************}
  1829.  
  1830.     Def_Int(Load_Count,Parm_Number);
  1831.     Def_Int(jx, tw, tr );
  1832.     Def_Int(restore_enable);
  1833.     Def_Str(TStr, TStr2 );
  1834.  
  1835.     make_message('Welcome to Multi-Edit V' + Version + '.  Press <F1> for help.');
  1836.  
  1837.     RM('.STARTUP^STARTUP');
  1838.  
  1839.         {Setup mouse sensitivity}
  1840.     jx := parse_int('/S=',global_str('@MOUSEPARMS'));
  1841.     IF mou_installed and (jx <> 0) THEN
  1842.         r_bx := jx;
  1843.         r_cx := jx;
  1844.         r_dx := jx;
  1845.         r_ax := 26;
  1846.         intr($33);
  1847.     END;
  1848.  
  1849.  
  1850.         {Check and see if MECONFIG is read_only.  If so then prompt the
  1851.          user, to see if he/she wants them unlocked}
  1852.     tw := window_id;
  1853.     IF user_id = '' THEN
  1854.         tstr := me_path + 'MECONFIG.DB';
  1855.     ELSE
  1856.         tstr := me_path + user_id + '.USR\MECONFIG.DB';
  1857.     END;
  1858.     IF switch_file( tstr ) THEN
  1859.         IF read_only THEN
  1860.             RM('MEERROR^MessageBox /NW=1/T=WARNING!!/M=Your configuration files are locked.  Before unlocking them, insure that there are NOT multiple copies of Multi-Edit running with your user id.');
  1861.             RM('USERIN^XMENU /B=1/X=25/Y=8/T=1/L=ACTION:/M=Unlock configuration files()Ignore and leave files locked()');
  1862.             kill_box;
  1863.             IF return_int = 1 THEN
  1864.                 tr := refresh;
  1865.                 refresh := false;
  1866.                 make_message('Unlocking configuration files...');
  1867.                 working;
  1868.                 delete_window;
  1869.                 IF user_id = '' THEN
  1870.                     tstr := me_path + '*.DB';
  1871.                     call unlock_files;
  1872.                     tstr := me_path + '*.ME';
  1873.                     call unlock_files;
  1874.                 ELSE
  1875.                     tstr := me_path + user_id + '.USR\*.*';
  1876.                     call unlock_files;
  1877.                 END;
  1878.                 tstr := user_id + 'MEERR.TMP';
  1879.                 call unlock_files;
  1880.                 tstr := me_path + user_id + '*.TMP';
  1881.                 call unlock_files;
  1882.                 goto config_unlocked;
  1883.  
  1884.                 unlock_files:
  1885.                     jx := FIRST_FILE(TSTR);
  1886.                     WHILE jx = 0 DO
  1887.                         Set_File_Attr( get_path( tstr ) + last_file_name,
  1888.                                                      last_file_attr AND $FE );
  1889.                         jx := next_file;
  1890.                     END;
  1891.                     ret;
  1892.  
  1893.     config_unlocked:
  1894.                 make_message('Configuration files unlocked.');
  1895.                 refresh := tr;
  1896.             END;
  1897.         END;
  1898.     END;
  1899.     switch_win_id( tw );
  1900.  
  1901.  
  1902.     restore_enable := TRUE;
  1903.     error_level := 0;
  1904.  
  1905.     Error_Level := 0;
  1906.  
  1907.     load_count := 0;
  1908.  
  1909.     Parm_Number := 1;
  1910.  
  1911.     refresh := true;
  1912.     WHILE Parm_Number <= PARAM_COUNT DO
  1913.         TStr := PARAM_STR(Parm_Number);
  1914.         TStr := Caps(Remove_Space(TStr));
  1915.  
  1916.         IF Xpos(Copy(Tstr,1,1),'/-',1) THEN
  1917.             Tstr := Copy(Tstr,2,80);
  1918.             If TStr = 'NR' then
  1919.                 restore_enable := False;
  1920.             END;
  1921.             If (TStr = 'R') then
  1922.                 Parm_Number := Parm_Number +1;
  1923.                 restore_enable := False;
  1924.                 Refresh := True;
  1925.                 IF PARAM_Str(Parm_Number) <> '' THEN
  1926.                     RM(PARAM_Str(Parm_Number));
  1927.                 END;
  1928.             END;
  1929.         else
  1930.             IF (Load_Count < 20000) and (Pos(copy(TStr,1,1),'/-') = 0) and (copy(TStr,1,1) <> ';') THEN
  1931.                 restore_enable := False;
  1932.                 Set_Global_Int('LOAD_COUNT',Load_Count);
  1933.                 return_str := tstr;
  1934.                 RM('LDFILES /LC=' + str(load_count));
  1935.                 Load_Count := return_int;
  1936.             END;
  1937.         END;
  1938.         Parm_Number := Parm_Number+1;
  1939.     END;
  1940.  
  1941.     If (Restore_Enable <> 0) and (Global_Int('RESTORE') <> 0) THEN
  1942.         RM( 'EXIT^RESTORE' );
  1943.         Error_Level := 0;
  1944.     END;
  1945.  
  1946. {Load keystroke macros if present}
  1947.     RM('KEYMAC^KEYMAC_LOAD /NE=1');
  1948.     Error_Level := 0;
  1949.  
  1950. {This is for the "post restore" startup macro which can be used to do stuff
  1951. that you don't want restore to undo like setting globals}
  1952.     RM( 'STARTUP2' );
  1953.     Error_Level := 0;
  1954.  
  1955. EXIT:
  1956.     refresh := true;
  1957.     If load_count > 0 THEN
  1958.         switch_window(1);
  1959.     END;
  1960. exit2:
  1961.     IF window_name = '' THEN
  1962.         RM('WINDOW^SetWindowNames');
  1963.     END;
  1964.     RM('SetAutoSave ' + Global_Str('@AUTOSAVEPARMS'));
  1965. END_MACRO;
  1966.