home *** CD-ROM | disk | FTP | other *** search
/ Piper's Pit BBS/FTP: ibm 0010 - 0019 / ibm0010-0019 / ibm0010.tar / ibm0010 / ME494-5.ZIP / SPELL.SRC < prev    next >
Encoding:
Text File  |  1990-04-18  |  25.3 KB  |  988 lines

  1. $MACRO_FILE SPELL;
  2. {*****************************MULTI-EDIT MACRO FILE****************************
  3.  
  4. Name: SPELL
  5.  
  6. Description:    This is the spell checker macros.
  7.  
  8. SPELL - The main spell checker menu
  9. SPELLCHK - The spell checker main interface
  10. SPLSETF - Retrieves spell checker setup data from file
  11. SPLSETUP - The spell checker setup interface
  12.  
  13.                              (C) Copyright 1989 by American Cybernetics, Inc.
  14. ******************************************************************************}
  15.  
  16.  
  17. {*******************************MULTI-EDIT MACRO******************************
  18.  
  19. Name: SPELL
  20.  
  21. Description:    This is the spell checker main menu.
  22.  
  23. Parameters:
  24.                             /X=        X coordinate for menu box
  25.                             /Y=        Y coordinate for menu box
  26.                             /BC=    Amount of boxes the menu system currently has
  27.  
  28.                              (C) Copyright 1989 by American Cybernetics, Inc.
  29. ******************************************************************************}
  30.  
  31. $MACRO SPELL;
  32.     def_str( gstr[20] );
  33.     refresh := false;
  34.     gstr := '!SPELL!_';
  35.     Set_Global_Str(gstr+'1','/H=SPELL^*/S=2/N=Check from cursor position/M=SPELLCHK /T=0');
  36.     Set_Global_Str(gstr+'2','/S=2/N=Look up word under cursor/M=SPELLCHK /T=1');
  37.     Set_Global_Str(gstr+'3','/S=2/N=check marked Block/M=SPELLCHK /T=2');
  38.     Set_Global_Str(gstr+'4','/S=2/N=check current Page/M=SPELLCHK /T=3');
  39.     Set_Global_Str(gstr+'5','/N=Setup spell check/M=SPLSETUP');
  40.     Set_Global_Str(gstr+'6','/S=2/N=spell check text in Quotes/M=SpellCheckSource');
  41.     RM('USERIN^SUBMENU /#=6/S=' + global_str(gstr+'0') + '/L=SPELL CHECK/G=' + gstr +
  42.         '/X=' + parse_str('/X=', mparm_str) +
  43.         '/Y=' + parse_str('/Y=', mparm_str) +
  44.         '/BC=' + parse_str('/BC=', mparm_str)
  45.         );
  46.  
  47. END_MACRO;
  48.  
  49.  
  50. {*******************************MULTI-EDIT MACRO******************************
  51.  
  52. Name:  SPELLCHK
  53.  
  54. Description: Performs an actual spellcheck.
  55.  
  56. Parameters:        /T=nn        Spell check type.
  57.                                             0 = Check document from cursor position
  58.                                             1 = Lookup word under cursor
  59.                                             2 = Check block
  60.                                             3 = Check page
  61.                             /NCD=1  Do NOT CLOSE DICTIONARIES when upon completion.
  62.                             /CD=1        Just close the dictionaries and exit.
  63.  
  64.                              (C) Copyright 1989 by American Cybernetics, Inc.
  65. ******************************************************************************}
  66.  
  67. $MACRO SPELLCHK;
  68.     def_str( orig_word[80], tstr[80], tstr2[80], lstr, prev_word[80],
  69.                      forced_match[2], lchar[1], word_chars[128] );
  70.     def_str( ignore_word[40], ignore_char[40] );
  71.     def_int( tbc, need_l,need_w,x,y,ee, jy, jz, jx, tc,tc2, box_offset, menu_start,
  72.             aux_window, aux1_window, aux2_window, work_window, cur_dic, list_window,
  73.             ignore_window, t_word_wrap ,T_Insert_Mode);
  74.     def_int( min_word_size, op_type, word_count, word_result, screen_stat, tr );
  75.     def_int( common_result );
  76.     def_char( tchar, pchar );
  77.  
  78.     t_word_wrap := wrap_stat;
  79.     T_Insert_Mode := Insert_Mode;
  80.     Insert_Mode := true;
  81.     work_window := window_id;
  82.     aux_window := 0;
  83.     aux1_window := GLOBAL_INT('SPELL_AUX1_WINDOW');
  84.     aux2_window := GLOBAL_INT('SPELL_AUX2_WINDOW');
  85.     ignore_window := GLOBAL_INT('SPELL_IGNORE_WINDOW');
  86.     list_window := GLOBAL_INT('SPELL_LIST_WINDOW');
  87.  
  88.     IF parse_int('/CD=', mparm_str) = 1 THEN
  89.         goto close_dictionaries;
  90.     END;
  91.  
  92.     if global_str('SPELL_MAIN_DIC') = '' THEN
  93.         RM('splsetf');
  94.     end;
  95.  
  96.     op_type := parse_int('/T=', mparm_str);
  97.     if op_type = 1 then
  98.         mark_pos;
  99.     end;
  100.     if op_type = 2 then
  101.         if block_stat = 0 then
  102.             make_message('No block marked.');
  103.             goto exit;
  104.         end;
  105.         block_end;
  106.         goto_line( block_line1 );
  107.         goto_col( block_col1 );
  108.         redraw;
  109.     end;
  110.     if op_type = 3 then
  111.         reg_exp_stat := false;
  112.         if search_bwd( page_str, 0 )  = 0 then
  113.             tof;
  114.         end;
  115.         reg_exp_stat := true;
  116.         pchar := copy(page_str, 1, 1 );
  117.     end;
  118.     tstr := global_str('SPELL_PARMS');
  119.     min_word_size := parse_int('/WS=',tstr) - 1;
  120.     screen_stat := parse_int('/SCRN=',tstr);
  121.     wrap_stat := (parse_int('/WW=',tstr) and wrap_stat);
  122.  
  123.     tbc := box_count;
  124.  
  125.  
  126.     word_chars := global_str('SPELL_CHARS');
  127.     ignore_word := global_str('SPELL_IGNORE_W');
  128.     ignore_char := global_str('SPELL_IGNORE_C');
  129.  
  130.     orig_word := global_str('SPELL_COMMON_DIC');
  131.     if get_path(orig_word) = '' then
  132.         orig_word := me_path + orig_word;
  133.     end;
  134.  
  135.     if spell_open_dic(orig_word, 4, 1, 0 ) = false then
  136.     end;
  137.  
  138.     orig_word := global_str('SPELL_MAIN_DIC');
  139.     if get_path(orig_word) = '' then
  140.         orig_word := me_path + orig_word;
  141.     end;
  142.  
  143.  
  144.     if spell_open_dic(orig_word, 1, 1, 500 ) = false then
  145.         make_message('Cannot open main dictionary "' + global_str('SPELL_MAIN_DIC') + '".');
  146.         word_result := -1;
  147.         goto exit;
  148.     end;
  149.  
  150.     orig_word := global_str('SPELL_AUX1_DIC');
  151.     if get_path(orig_word) = '' then
  152.         orig_word := me_path + orig_word;
  153.     end;
  154.     if spell_open_dic( orig_word, 2, 0, 500 ) = false then
  155.     end;
  156.  
  157.     orig_word := global_str('SPELL_AUX2_DIC');
  158.     if get_path(orig_word) = '' then
  159.         orig_word := me_path + orig_word;
  160.     end;
  161.     if spell_open_dic( orig_word, 3, 0, 500 ) = false then
  162.     end;
  163.  
  164.     refresh := false;
  165.         {go to start of first word}
  166.  
  167.     while (xpos(cur_char,'|255 |9',1) <> 0) and (c_col > 1) do
  168.         left;
  169.     end;
  170.  
  171.     while (xpos(cur_char, '|255() ''"|9[]{}+\-||=*&^%$#@!~`><,.:;?/', 1) = 0) do
  172.         if (c_col = 1) then
  173.             goto loop_start;
  174.         end;
  175.         left;
  176.     end;
  177.     right;
  178.  
  179. loop_start:
  180.     tstr := '';
  181.     call spell_message;
  182.     word_count := 0;
  183. loop:
  184.     if op_type > 0 then
  185.         if op_type = 1 then
  186.             if word_count > 0 then
  187.                 goto exit;
  188.             end;
  189.         else
  190.                 {restrict to block}
  191.             if op_type = 2 then
  192.                 if c_line >= block_line2 then
  193.                     if c_line > block_line2 then
  194.                         goto check_complete;
  195.                     end;
  196.                     if block_stat = 3 then
  197.                         if c_col > block_col2 then
  198.                             goto check_complete;
  199.                         end;
  200.                     end;
  201.                 end;
  202.                 if block_stat = 2 then
  203.                     if c_col > block_col2 then
  204.                         down;
  205.                         goto_col( block_col1 );
  206.                         goto loop;
  207.                     end;
  208.                 end;
  209.             end;
  210.         end;
  211.     end;
  212.     prev_word := tstr;
  213.  
  214.  
  215.     if check_key then
  216.         if key1 = 27 then
  217.             goto abort_check;
  218.         end;
  219.     end;
  220.  
  221.     tc := c_col;
  222.     tchar := lower(cur_char);
  223.     jx := ascii(tchar);
  224.     if (jx > 96) and (jx < 123) then
  225.         ++word_count;
  226.         refresh := screen_stat;
  227.         orig_word := get_word_in( word_chars );
  228.     try_again:
  229.  
  230.             {Ignore any word with an underscore in it.}
  231.         jz := xpos('_', orig_word, 2);
  232.         if jz <> 0 then
  233.             tstr := orig_word;
  234.             goto do_loop2;
  235.         end;
  236.  
  237.             {deal with apostrophes}
  238.         jz := xpos('''', orig_word, 2);
  239.         if jz <> 0 then
  240.             if (svl(orig_word) = (jz + 1)) then
  241.                 if lower(str_char(orig_word, jz + 1)) = 's' then
  242.                     orig_word := str_del( orig_word, jz, 2 );
  243.                 end;
  244.             else
  245.                 if svl( orig_word ) = jz then
  246.                     orig_word := str_del( orig_word, jz, 1 );
  247.                 end;
  248.             end;
  249.         end;
  250.         tc2 := c_col;
  251.         tstr := lower(orig_word);
  252.         word_result := true;
  253.         jx := svl(tstr);
  254.         if jx > min_word_size then
  255.                 {If the wordlength is less than 9 then check the common words
  256.                     dictionary}
  257.             if jx < 9 then
  258.                 common_result := spell_lookup_word( tstr,4 );
  259.             else
  260.                 common_result := 0;
  261.             end;
  262.             if common_result = 0 then
  263.                 if spell_lookup_word( tstr, 1 ) = 0 then
  264.                     if spell_lookup_word( tstr, 2 ) = 0 then
  265.                         if spell_lookup_word( tstr, 3 ) = 0 then
  266.                             if switch_win_id( ignore_window ) then
  267.                                 tof;
  268.                                 if search_fwd('%' + tstr + '@||',0) then
  269.                                     goto_col( svl(tstr) + 2);
  270.                                     return_str := get_word(' ');
  271.                                     if switch_win_id( work_window ) then end;
  272.                                     if return_str <> '' then
  273.                                         goto_col(tc);
  274.                                         call replace_word;
  275.                                     end;
  276.                                     goto do_loop;
  277.                                 end;
  278.                                 if switch_win_id( work_window ) then end;
  279.                             end;
  280.                             refresh := true;
  281.                             goto_col(c_col);
  282.                             word_result := false;
  283.                             jx := 0;
  284.                             goto_col(tc);
  285.                             goto_v_col( v_col );
  286.                             box_offset := 0;
  287.                             menu_start := 1;
  288.                             draw_attr(wherex, wherey, h_color or $80, svl(tstr));
  289.                             need_l := 11;
  290.                             need_w := svl(tstr) + 17;
  291.                             if need_w < 25 then
  292.                                 need_w := 25;
  293.                             end;
  294.                             call calc_xy;
  295.  
  296.                             refresh := false;
  297.                     menu_again:
  298.                             set_global_str('SPELL1', '/H=SPELL^MSPLDUNKWN/N=Ignore');
  299.                             set_global_str('SPELL2', '/N=Edit word');
  300.                             set_global_str('SPELL3', '/N=Suggest spellings');
  301.                             set_global_str('SPELL4', '/N=Add to aux. dictionary 1');
  302.                             set_global_str('SPELL5', '/N=add to aux. dictionary 2');
  303.                             set_global_str('SPELL6', '/N=iGnore for rest of check');
  304.                             set_global_str('SPELL7', '/N=Quit spell check(<ESC>)');
  305.                             RM('USERIN^SUBMENU /GCLR=1/G=SPELL/#=7/X=' + str(x + box_offset) +
  306.                                                     '/Y=' + str(y + box_offset) + '/S=' + str(menu_start) +
  307.                                                     '/B=' + str( box_offset ) +
  308.                                                     '/L="' + tstr + '" NOT FOUND');
  309.                             menu_start := return_int;
  310.                             box_offset := 1;
  311.                             if (return_int < 1) or (return_int = 7) then
  312.                                 while box_count > tbc do
  313.                                     kill_box;
  314.                                 end;
  315.                                 goto abort_check;
  316.                             end;
  317.                             if return_int = 1 then
  318.                                 goto_col(tc2);
  319.                                 kill_box;
  320.                                 goto do_loop;
  321.                             end;
  322.                             if return_int = 2 then {edit the word}
  323.                                 return_str := orig_word;
  324.                                 make_message('Press <ENTER> to replace word with edited word, <ESC> to abort edit.');
  325.                                 RM('USERIN^USERSTR /X=' + str(x + 1) + '/Y=' + str(y + 6) +
  326.                                         '/L=80/B=1/BL=EDIT WORD/W=40/BL=40/H=SPELL^MSPLDUNKWN');
  327.                                 make_message('');
  328.                                 if return_int < 1 then
  329.                                     goto menu_again;
  330.                                 end;
  331.                                 call check_replace;
  332.                                 if tr < 1 then
  333.                                     goto menu_again;
  334.                                 end;
  335.                                 kill_box;
  336.                                 word_result := 2;
  337.                                 call replace_word2;
  338.                                 if tr = 2 then
  339.                                     tstr := lower(orig_word) + '||' + lower(return_str);
  340.                                     call add_word_to_ignore;
  341.                                 end;
  342.                                 goto do_loop;
  343.                             end;
  344.                             if return_int = 3 then
  345.                                 goto possible_spellings;
  346.                             end;
  347.                             if return_int = 4 then
  348.                                 goto_col(tc2);
  349.                                 kill_box;
  350.                                 aux_window := aux1_window;
  351.                                 cur_dic := 2;
  352.                                 lstr := global_str('SPELL_AUX1_DIC');
  353.                                 call add_word_to_aux;
  354.                                 aux1_window := aux_window;
  355.                                 SET_GLOBAL_INT('SPELL_AUX1_WINDOW', aux1_window);
  356.                                 goto do_loop;
  357.                             end;
  358.                             if return_int = 5 then
  359.                                 goto_col(tc2);
  360.                                 kill_box;
  361.                                 aux_window := aux2_window;
  362.                                 lstr := global_str('SPELL_AUX2_DIC');
  363.                                 cur_dic := 3;
  364.                                 call add_word_to_aux;
  365.                                 aux2_window := aux_window;
  366.                                 SET_GLOBAL_INT('SPELL_AUX2_WINDOW', aux2_window);
  367.                                 goto do_loop;
  368.                             end;
  369.                             if return_int = 6 then
  370.                                 goto_col(tc2);
  371.                                 kill_box;
  372.                                 tstr := tstr + '||';
  373.                                 call add_word_to_ignore;
  374.                                 goto do_loop;
  375.                             end;
  376.                 do_loop:
  377.                             refresh := true;
  378.                             redraw;
  379.                             call spell_message;
  380.                             refresh := false;
  381.                         end;
  382.                     end;
  383.                 end;
  384.             end;
  385.         end;
  386.  no_check:
  387.         refresh := false;
  388.  
  389.             {process double word}
  390.         if prev_word = tstr then
  391.             refresh := true;
  392.             goto_col(c_col);
  393.             goto_col(tc);
  394.             draw_attr(wherex, wherey, h_color or $80, svl(tstr));
  395.             need_l := 7;
  396.             need_w := svl(tstr) + 18;
  397.             if need_w < 25 then
  398.                 need_w := 25;
  399.             end;
  400.             call calc_xy;
  401.             RM('USERIN^XMENU /T=1/B=1/X=' + str(x) + '/Y=' + str(y) +
  402.                     '/L="' + tstr + '" - DOUBLE WORDS"/M=Ignore(SPELL^DBLWDS)Delete()Quit spell check((<ESC>)()');
  403.             if (return_int < 1) or (return_int = 5) then
  404.                 goto abort_check;
  405.             end;
  406.             if (return_int = 2) then
  407.                 if c_col > 1 then
  408.                     left;
  409.                     if cur_char = ' ' then
  410.                         del_char;
  411.                     else
  412.                         right;
  413.                     end;
  414.                 end;
  415.                 del_chars( svl(tstr) );
  416.             else
  417.                 goto_col(tc2);
  418.             end;
  419.             refresh := true;
  420.             redraw;
  421.             refresh := false;
  422.             call spell_message;
  423.         end;
  424.     else
  425.         if op_type = 3 then
  426.             if tchar = pchar then
  427.                 if word_count > 0 then
  428.                     if copy(get_line, c_col, length(page_str)) = page_str then
  429.                         goto check_complete;
  430.                     end;
  431.                 end;
  432.             end;
  433.         end;
  434.  
  435.         tstr := tchar;
  436.         right;
  437.         if xpos(tchar, ignore_word, 1) then
  438.             tstr := lower(get_word_in(word_chars ));
  439.             tstr := '';
  440.         else
  441.             if xpos(tchar, ignore_char, 1) then
  442.                 right;
  443.             end;
  444.         end;
  445.     end;
  446.  
  447. do_loop2:
  448.     forward_till_not(' |9|255');
  449. eolagain:
  450.     if at_eol then
  451.         refresh := screen_stat;
  452.         down;
  453.         first_word;
  454.         if at_eof then
  455.             goto check_complete;
  456.         end;
  457.         if (at_eol) then
  458.             tstr := '';
  459.             goto eolagain;
  460.         end;
  461.         if screen_stat = 0 then
  462.             put_line_num(c_line);
  463.         end;
  464.         refresh := false;
  465.     end;
  466.     goto loop;
  467.  
  468.  
  469. spell_message:
  470.     make_message('Checking...  Press <ESC> to abort.');
  471.     ret;
  472.  
  473. calc_xy:
  474.     x := (wherex + (svl(tstr) /2)) - (need_w / 2);
  475.     if (x + need_w + 2) > screen_width then
  476.         x := screen_width - ( need_w + 2 );
  477.     end;
  478.     if x < 1 then
  479.         x := 1;
  480.     end;
  481.     y := wherey - need_l;
  482.     if y < 3 then
  483.         y := wherey + 2;
  484.         if y > (screen_length - need_l) then
  485.             y := 3;
  486.         end;
  487.     end;
  488.     ret;
  489.  
  490. add_word_to_ignore:
  491.         aux_window := ignore_window;
  492.         lstr := '';
  493.         cur_dic := 100;
  494.         call add_word_to_aux;
  495.         ignore_window := aux_window;
  496.         SET_GLOBAL_INT('SPELL_IGNORE_WINDOW', ignore_window);
  497.         ret;
  498.  
  499. possible_spellings:
  500.     make_message('Scanning...');
  501.     lstr := '';
  502.     jx := 0;
  503.     refresh := false;
  504.     if not( switch_win_id( list_window ) ) then
  505.         switch_window( window_count );
  506.         create_window;
  507.         list_window := window_id;
  508.         SET_GLOBAL_INT('SPELL_LIST_WINDOW',list_window);
  509.     else
  510.         erase_window;
  511.     end;
  512.  
  513.     jz := 1;
  514.     jy := 1;
  515.     call lookup_loop;
  516.  
  517.     jz := 0;
  518.     jy := 2;
  519.     call lookup_loop;
  520.  
  521.  
  522.     tchar := copy(tstr,1,1);
  523.   lstr := global_str('SPELL_PHONIC_CHARS');
  524.     jz := xpos(tchar + '=', lstr,1 );
  525.     IF jz <> 0 THEN
  526.         set_global_str('@@@TSTR@@@', tstr );
  527.         jy := xpos(',',lstr,jz);
  528.         IF jy = 0 THEN
  529.             jy := svl(lstr);
  530.         END;
  531.         forced_match := copy(lstr, jz + 2, jy - jz - 2);
  532.         tstr := forced_match + str_del(tstr,1,1);
  533.         jz := 1;
  534.         jy := 1;
  535.         call lookup_loop2;
  536.         tstr := global_str('@@@TSTR@@@' );
  537.         set_global_str('@@@TSTR@@@', '' );
  538.     END;
  539.  
  540.  
  541.     if jx = 0 then
  542.         make_message('No choices found.');
  543.         if switch_win_id( work_window ) then end;
  544.         goto menu_again;
  545.     end;
  546.  
  547.     tof;
  548.     make_message('Select word and press <ENTER> to replace, or <ESC> to return to menu.');
  549.     return_str := '';
  550.     RM('USERIN^DVMENU /WIN=' + str( cur_window ) + '/X=' + str(x + 1) + '/Y=' + str(y+1) +
  551.             '/T=POSSIBLE SPELLINGS/H=SPELL^MSPLDUNKWN%Suggest/B=1/K=1/I=%/#=' + str(jx));
  552.     if switch_win_id( work_window ) then end;
  553.     if return_int = 0 then
  554.         goto menu_again;
  555.     end;
  556.     if return_int = 1 then
  557.         call check_replace;
  558.         if tr < 1 then
  559.             goto menu_again;
  560.         end;
  561.         kill_box;
  562.         call replace_word;
  563.         word_result := 2;
  564.         if tr = 2 then
  565.             tstr := lower(orig_word) + '||' + lower(return_str);
  566.             call add_word_to_ignore;
  567.         end;
  568.         goto do_loop;
  569.     end;
  570.     kill_box;
  571.     goto do_loop;
  572.  
  573.  
  574.     {jz = 1, start at first char of word}
  575.     {jz = 0, start at top of dictionary}
  576.     {tstr = word to find}
  577.     {jy = dictionary to search}
  578. lookup_loop:
  579.     IF jz THEN
  580.         lchar := copy(tstr,1,1);
  581.     ELSE
  582.         lchar := '';
  583.     END;
  584.     if spell_lookup_word( lchar, jy ) then
  585.         loop2:
  586.             tstr2 := spell_next_match( tstr, jy );
  587.             if svl(tstr2) <> 0 then
  588.                 call add_word_to_file;
  589.                 ++jx;
  590.                 goto loop2;
  591.             end;
  592.     end;
  593.     RET;
  594.  
  595.     {jz = 1, start at first char of word}
  596.     {jz = 0, start at top of dictionary}
  597.     {tstr = word to find}
  598.     {jy = dictionary to search}
  599. lookup_loop2:
  600.     IF jz THEN
  601.         lchar := copy(tstr,1,1);
  602.     ELSE
  603.         lchar := '';
  604.     END;
  605.     if spell_lookup_word( lchar, jy ) then
  606.         loop2xx:
  607.             tstr2 := spell_next_match( tstr, jy );
  608.             if (svl(tstr2) <> 0) then
  609.  
  610.             if (copy(tstr2,1,svl(forced_match)) = forced_match) then
  611.                 call add_word_to_file;
  612.                 ++jx;
  613.             end;
  614.                 goto loop2xx;
  615.             end;
  616.     end;
  617.     RET;
  618.  
  619.  
  620. check_replace:
  621.         IF op_type = 1 THEN
  622.             tr := 1;
  623.             RET;
  624.         END;
  625.         RM('USERIN^XMENU /X=' + str(x+1) + '/Y=' + str(y + 3) +
  626.             '/B=1/L=REPLACE WORD (<ESC> to abort)/M=Just this occurrence(SPELL^MSPLDUNKWN)All occurrences()');
  627.         tr := return_int;
  628.         ret;
  629.  
  630. replace_word:
  631.     def_int( rx );
  632.  
  633.     rx := 0;
  634. caps_loop:
  635.     if rx < svl(orig_word) then
  636.         if (str_char(orig_word,rx + 1) >= 'A') and (str_char(orig_word,rx + 1) <= 'Z') then
  637.             ++rx;
  638.             goto caps_loop;
  639.         end;
  640.     end;
  641.  
  642.     if rx = svl(orig_word) then
  643.         return_str := caps(return_str);
  644.     else
  645.         if (str_char(orig_word,1) >= 'A') and (str_char(orig_word,1) <= 'Z') then
  646.             return_str := caps(copy(return_str,1,1)) + str_del(return_str,1,1);
  647.         end;
  648.     end;
  649. replace_word2:
  650.     push_undo;
  651.     del_chars( svl(tstr) );
  652.     Insert_Mode := True;
  653.     text(return_str);
  654.     if wrap_stat then
  655.         word_wrap_line( FALSE, TRUE );
  656.     end;
  657.     pop_undo;
  658.     tstr := return_str;
  659.     ret;
  660.  
  661.  
  662. {aux_window = window_number}
  663. {lstr = file_name}
  664. add_word_to_aux:
  665.     refresh := false;
  666.     undo_stat := false;
  667.     working;
  668.     if cur_dic < 100 then
  669.         ee := spell_close_dic( cur_dic );
  670.     end;
  671.     if switch_win_id( aux_window ) = 0 then
  672.         switch_window(window_count);
  673.         create_window;
  674.         window_attr := 1;
  675.         if lstr <> '' then
  676.             if get_path(lstr) = '' then
  677.                 lstr := me_path + lstr;
  678.             end;
  679.             load_file( lstr );
  680.             if error_level <> 0 then
  681.                 error_level := 0;
  682.                 file_name := lstr;
  683.             end;
  684.         end;
  685.         aux_window := window_id;
  686.     end;
  687.     tstr2 := tstr;
  688.     call add_word_to_file;
  689.     if cur_dic < 100 then
  690.         save_file;
  691.     end;
  692.     if switch_win_id( work_window ) then
  693.     end;
  694.     if cur_dic < 100 then
  695.         ee := spell_open_dic( lstr, cur_dic, 1, 2000 );
  696.     end;
  697.     undo_stat := true;
  698.     ret;
  699.  
  700.  
  701. {assumes current file}
  702. {tstr2 is the word to insert}
  703. {puts word in file in alphebetical order}
  704. {eliminates duplicates}
  705. add_word_to_file:
  706.     tof;
  707.     reg_exp_stat := true;
  708.     if search_fwd('%' + copy(tstr2,1,1), 0) then
  709.     end;
  710.     while not(at_eof) and (get_line < tstr2) do
  711.         down;
  712.     end;
  713.     goto_col(1);
  714.     if get_line <> tstr2 then
  715.         if not(at_eof) then
  716.             cr;
  717.             up;
  718.         end;
  719.         put_line(tstr2);
  720.     end;
  721.     ret;
  722.  
  723.  
  724. abort_check:
  725.     make_message('Spell check aborted, ' + str(word_count) + '  words checked.');
  726.     delay(200);
  727.     if check_key then
  728.         if key1 <> 27 then
  729.             push_key(key1,key2);
  730.         end;
  731.     end;
  732.     goto exit;
  733.  
  734.  
  735. check_complete:
  736.         make_message('Spell check complete, ' + str(word_count) + ' words checked.');
  737.  
  738. exit:
  739.     if op_type = 1 then
  740.         if word_result = 1 then
  741.             make_message('Word spelled correctly.');
  742.         elsif word_result = 2 then
  743.             make_message('Word replaced');
  744.         elsif word_result = -1 then
  745.         else
  746.             make_message('');
  747.         end;
  748.         jx := messages;
  749.         messages := false;
  750.         goto_mark;
  751.         messages := jx;
  752.     end;
  753.  
  754.     refresh := false;
  755.  
  756.         {close all dictionaries}
  757.     IF parse_int('/NCD=',mparm_str) = 1 THEN
  758.         goto no_close_dicts;
  759.     END;
  760. Close_Dictionaries:
  761.     if switch_win_id( list_window ) then
  762.         delete_window;
  763.         SET_GLOBAL_INT('SPELL_LIST_WINDOW', 0);
  764.     end;
  765.     if switch_win_id( aux1_window ) then
  766.         delete_window;
  767.         SET_GLOBAL_INT('SPELL_AUX2_WINDOW', 0);
  768.     end;
  769.     if switch_win_id( aux2_window ) then
  770.         delete_window;
  771.         SET_GLOBAL_INT('SPELL_AUX2_WINDOW', 0);
  772.     end;
  773.     if switch_win_id( ignore_window ) then
  774.         delete_window;
  775.         SET_GLOBAL_INT('SPELL_IGNORE_WINDOW',0);
  776.     end;
  777.     ee := spell_close_dic( 1 );
  778.     ee := spell_close_dic( 2 );
  779.     ee := spell_close_dic( 3 );
  780.     ee := spell_close_dic( 4 );
  781. No_Close_Dicts:
  782.     if switch_win_id( work_window ) then
  783.     end;
  784.     wrap_stat := t_word_wrap;
  785.     return_int := 100;
  786.     Insert_Mode := T_Insert_Mode;
  787.     redraw;
  788. END_MACRO;
  789.  
  790.  
  791. {*******************************MULTI-EDIT MACRO******************************
  792.  
  793. Name:  SPLSETF
  794.  
  795. Description: Retrieves spell check setup parameters from disk.
  796.  
  797.                              (C) Copyright 1989 by American Cybernetics, Inc.
  798. ******************************************************************************}
  799. $MACRO SPLSETF;
  800.         def_int( t2 );
  801.         refresh := false;
  802.         error_level := 0;
  803.         t2 := window_id;
  804.         create_window;
  805.         if error_level = 0 then
  806.             return_str := 'SPELLSET.ME';
  807.             RM('MakeUserPath /DF=1');
  808.             load_file( return_str );
  809.             update_status_line;
  810.             set_global_str('SPELL_CHARS', 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_''');
  811.             if error_level = 0 then
  812.                 set_global_str( 'SPELL_COMMON_DIC', get_line );
  813.                 down;
  814.                 set_global_str( 'SPELL_MAIN_DIC', get_line );
  815.                 down;
  816.                 set_global_str( 'SPELL_AUX1_DIC', get_line );
  817.                 down;
  818.                 set_global_str( 'SPELL_AUX2_DIC', get_line );
  819.                 down;
  820.                 set_global_str( 'SPELL_IGNORE_W', get_line );
  821.                 down;
  822.                 set_global_str( 'SPELL_IGNORE_C', get_line );
  823.                 down;
  824.                 set_global_str( 'SPELL_PARMS', get_line );
  825.                 down;
  826.                 if NOT(at_eof) THEN
  827.                     set_global_str( 'SPELL_CHARS', get_line );
  828.                 END;
  829.             else
  830.                 error_level := 0;
  831.                 set_global_str( 'SPELL_COMMON_DIC', 'COMMON.DIC' );
  832.                 set_global_str( 'SPELL_MAIN_DIC', 'ME.DIC' );
  833.                 set_global_str( 'SPELL_AUX1_DIC', 'AUXDIC.TXT' );
  834.                 set_global_str( 'SPELL_AUX2_DIC', 'AUXDIC2.TXT' );
  835.                 set_global_str( 'SPELL_IGNORE_W', '.@<' );
  836.                 set_global_str( 'SPELL_IGNORE_C', '^' );
  837.                 set_global_str( 'SPELL_PARMS', '/WS=1/SCRN=1/WW=0' );
  838.             end;
  839.             delete_window;
  840.         else
  841.             RM('MEERROR');
  842.         end;
  843.         if switch_win_id(t2) then
  844.         end;
  845.         update_status_line;
  846. END_MACRO;
  847.  
  848.  
  849. {*******************************MULTI-EDIT MACRO******************************
  850.  
  851. Name: SpellCheckSource
  852.  
  853. Description: Goes through a source file, from the current cursor position
  854.     and spell checks all text that is in between single, or double quotes.
  855.  
  856.                (C) Copyright 1989 by American Cybernetics, Inc.
  857. ******************************************************************************}
  858. $MACRO SpellCheckSource;
  859.     reg_exp_stat := TRUE;
  860.     key1 := 0;
  861.     WHILE Search_Fwd('[''"]',0) DO
  862.         if key1 = 27 THEN
  863.             goto done;
  864.         END;
  865.         RIGHT;
  866.         Str_Block_Begin;
  867.         IF NOT(search_fwd(found_str,0)) THEN
  868.             goto done;
  869.         END;
  870.         block_End;
  871.         Goto_Line( block_line1 );
  872.         goto_col( block_col1 );
  873.         refresh := TRUE;
  874.         redraw;
  875.          RM('SPELLCHK /T=2/NCD=1');
  876.         goto_line(block_line2);
  877.         goto_col(block_col2 + 2);
  878.         reg_exp_stat := TRUE;
  879.     END;
  880. DONE:
  881.     RM('SPELLCHK /CD=1');
  882. exit:
  883. END_MACRO;
  884.  
  885.  
  886. {*******************************MULTI-EDIT MACRO******************************
  887.  
  888. Name:  SPLSETUP
  889.  
  890. Description: A setup interface for the spell checker.
  891.  
  892. Parameters:
  893.                          /X= The upper left corner column coordinate
  894.                          /Y= The upper left corner row coordinate
  895.  
  896.                              (C) Copyright 1989 by American Cybernetics, Inc.
  897. ******************************************************************************}
  898. $MACRO SPLSETUP;
  899.         def_int( x,y, tw );
  900.  
  901.         refresh := false;
  902.         tw := window_id;
  903.         y := parse_int('/Y=', mparm_str);
  904.         if y = 0 then
  905.             y := 2;
  906.         end;
  907.         x := parse_int('/X=', mparm_str);
  908.         if x = 0 then
  909.             x := 2;
  910.         end;
  911.         if global_str( 'SPELL_MAIN_DIC' ) = '' then
  912.             RM('splsetf');
  913.         end;
  914.  
  915.         Set_Global_Str('ISTR_1', global_str( 'SPELL_COMMON_DIC' ) );
  916.         Set_Global_Str('IPARM_1','/T=Common words dictionary............./C=1/W=24/ML=80');
  917.         Set_Global_Str('ISTR_2', global_str( 'SPELL_MAIN_DIC' ) );
  918.         Set_Global_Str('IPARM_2','/T=Main dictionary...................../C=1/W=24/ML=80');
  919.         Set_Global_Str('ISTR_3',global_str( 'SPELL_AUX1_DIC' ));
  920.         Set_Global_Str('IPARM_3','/T=Auxilary dictionary 1.............../C=1/W=24/ML=80');
  921.         Set_Global_Str('ISTR_4',global_str( 'SPELL_AUX2_DIC' ));
  922.         Set_Global_Str('IPARM_4','/T=Auxilary dictionary 2.............../C=1/W=24/ML=80');
  923.         Set_Global_Str('ISTR_5',global_str( 'SPELL_IGNORE_W' ));
  924.         Set_Global_Str('IPARM_5','/T=Ignore word after these chars......./C=1/W=20');
  925.         Set_Global_Str('ISTR_6',global_str( 'SPELL_IGNORE_C' ));
  926.         Set_Global_Str('IPARM_6','/T=Ignore character after these chars../C=1/W=20');
  927.  
  928.         Set_Global_Int('IINT_7',parse_int('/WS=', global_str( 'SPELL_PARMS' )));
  929.         Set_Global_Str('IPARM_7','/T=Minimum word size.................../C=1/W=2/TP=1');
  930.         Set_Global_Int('IINT_8',parse_int('/SCRN=', global_str( 'SPELL_PARMS' )));
  931.         Set_Global_Str('ISTR_8','/T=YES/F=NO');
  932.         Set_Global_Str('IPARM_8','/T=Screen updating...................../C=1/W=3/TP=5');
  933.         Set_Global_Int('IINT_9',parse_int('/WW=', global_str( 'SPELL_PARMS' )));
  934.         Set_Global_Str('ISTR_9','/T=YES/F=NO');
  935.         Set_Global_Str('IPARM_9','/T=Reformat if Word Wrap is on........./C=1/W=3/TP=5');
  936.         Set_Global_Str('ISTR_10',global_str( 'SPELL_CHARS' ));
  937.         Set_Global_Str('IPARM_10','/T=Valid word characters/C=1/W=40/ML=128');
  938.  
  939.         RM('UserIn^Data_In /H=SPELL^SETUPSPL/S=1/A=2/#=10/X=' + str(x) + '/T=SPELL CHECK SETUP/Y=' + str(y));
  940.  
  941.         Set_Global_Str('SPELL_COMMON_DIC', global_str('ISTR_1'));
  942.         Set_Global_Str('SPELL_MAIN_DIC', global_str('ISTR_2'));
  943.         Set_Global_Str('SPELL_AUX1_DIC', global_str('ISTR_3'));
  944.         Set_Global_Str('SPELL_AUX2_DIC', global_str('ISTR_4'));
  945.         Set_Global_Str('SPELL_IGNORE_W', global_str('ISTR_5'));
  946.         Set_Global_Str('SPELL_IGNORE_C', global_str('ISTR_6'));
  947.         Set_Global_Str('SPELL_CHARS', global_str('ISTR_10'));
  948.         Set_Global_Str('SPELL_PARMS', '/WS=' + str(global_int('IINT_7')) + '/SCRN=' + str(global_int('IINT_8'))
  949.                     + '/WW=' + str(global_int('IINT_9'))
  950.                 );
  951.  
  952.             {now save the configuration}
  953.         error_level := 0;
  954.         create_window;
  955.         if error_level = 0 then
  956.             return_str := 'SPELLSET.ME';
  957.             RM('MakeUserPath');
  958.             file_name := return_str;
  959.             put_line( global_str('SPELL_COMMON_DIC') );
  960.             down;
  961.             put_line( global_str('SPELL_MAIN_DIC') );
  962.             down;
  963.             put_line( global_str('SPELL_AUX1_DIC') );
  964.             down;
  965.             put_line( global_str('SPELL_AUX2_DIC') );
  966.             down;
  967.             put_line( global_str('SPELL_IGNORE_W') );
  968.             down;
  969.             put_line( global_str('SPELL_IGNORE_C') );
  970.             down;
  971.             put_line( global_str('SPELL_PARMS') );
  972.             down;
  973.             put_line( global_str('SPELL_CHARS') );
  974.             down;
  975.             save_file;
  976.             delete_window;
  977.         else
  978.             RM('MEERROR');
  979.         end;
  980.         if switch_win_id(tw) then
  981.         end;
  982.         update_status_line;
  983.  
  984.         return_int := 0;
  985. END_MACRO;
  986.  
  987.  
  988.