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

  1. {*******************************MULTI-EDIT MACRO******************************
  2. Name: MEHELP
  3.  
  4. Description:  The Multi-Edit Help system
  5.  
  6. Parameters:
  7.                             /X=n        X coordinate
  8.                             /Y=n        Y coordinate
  9.                             /W=n        Width
  10.                             /L=n        Length
  11.                             /T=str  Title
  12.                             /F=n        Filename
  13.                             /LK=n        Index
  14.                             /CX=1        Enables file/extension context sensitivity.
  15.                             /TO=n        Top offset (number of lines from top of chapter to start
  16.                                                 displaying).
  17.  
  18.                          (C) Copyright 1989-1990 by American Cybernetics, Inc.
  19. ******************************************************************************}
  20. $macro mehelp FROM ALL;
  21.     def_str( tstr[100], tstr2[100], cur_file[80], event_str[20], help_path[80] );
  22.   def_str( extfil[100], extlnk[80], fname[80], hstr[100]);                         { ldh }
  23.   def_int( old_sb, jx, jy, jz, x, y, w, l, tbc, tx, ty, h_v_color,
  24.                      trefresh, done, event_count, cl, need_new_bar, scroll_bar,
  25.                      trepeat, need_event_draw, old_x, old_y, min_y, max_y,
  26.                      tfkey_row, tstatus_row, file_help_mode, need_search_display,
  27.                      hlc_time
  28.                 );
  29.  
  30.     IF help_open THEN
  31.         rm('MEERROR^MessageBox /B=1/T=UNABLE TO ACCESS HELP/M=Help system already in use.');
  32.         goto total_exit;
  33.     end;
  34.   Set_Global_Int('MENU_LEVEL', Global_Int('MENU_LEVEL') + 1);
  35.     trefresh := refresh;
  36.     refresh := false;
  37.     event_count := 0;
  38.  
  39.     file_help_mode := parse_int('/CX=', mparm_str );
  40.     IF file_help_mode <> 0 THEN
  41.  
  42. {<<<Added 03-22-90 ldh *************************************************ldh2*}
  43.     Return_Str := Global_Str('@HELP_WORD@');
  44.     RM('Get_Context');
  45.     hstr := CAPS(Return_Str);
  46. {******************************************************************* Added>>>}
  47.  
  48.       fname := truncate_extension( File_name ) + '.HLP';                  { ldh }
  49.       RM('Find_Ext /EXT=.' + get_extension(file_name));                   { ldh }
  50.       extfil := Parse_Str('HLP=', Global_Str(Return_Str));               { ldh }
  51.       jx := xpos('^', extfil, 1);                                         { ldh }
  52.       if jx <> 0 then                                                     { ldh }
  53.         extlnk := str_del( extfil, 1, jx);                                { ldh }
  54.         extfil := copy( extfil, 1, jx - 1 );                              { ldh }
  55.       end;                                                                { ldh }
  56.     END;
  57.  
  58. {Setup the help path}
  59.     help_path := global_str('@HELP_PATH@');
  60.     IF help_path = '' THEN
  61.         IF (file_attr(me_path + 'HELP') and $10) <> 0 THEN
  62.             help_path := me_path + 'HELP' + ';' + me_path;
  63.         ELSE
  64.             help_path := me_path;
  65.         END;
  66.     END;
  67.     IF xpos('<', help_path, 1) THEN
  68.         return_str := help_path;
  69.         RM('XLATECMDLINE');
  70.         help_path := return_str;
  71.     END;
  72.     set_global_str('@HELP_PATH@', help_path);
  73.     tx := wherex;
  74.     ty := wherey;
  75.     trepeat := mou_repeat;
  76.     tfkey_row := fkey_row;
  77.     tstatus_row := status_row;
  78.     mou_repeat := TRUE;
  79.     need_search_display := FALSE;
  80.  
  81.     x := Parse_Int('/X=', mparm_str);
  82.     y := Parse_Int('/Y=', mparm_str);
  83.     w := Parse_Int('/W=', mparm_str);
  84.     l := Parse_Int('/L=', mparm_str);
  85.  
  86.     event_str :=  '@EV' + Str(Global_Int( 'MENU_LEVEL' )) + '#';
  87.  
  88.     min_y := 1 + (status_row = 1);
  89.     max_y := screen_length - (status_row = screen_length);
  90.     fkey_row := screen_length - (status_row = screen_length);
  91.  
  92.     IF x = 0 THEN
  93.         x := 1;
  94.     END;
  95.     IF y = 0 THEN
  96.         y := min_y;
  97.     END;
  98.     IF w = 0 THEN
  99.         w := Screen_width - x;
  100.     END;
  101.     IF l = 0 THEN
  102.         l := max_y - y - 1;
  103.     END;
  104.     IF (y + l) > (max_y - 2) THEN
  105.         y := max_y - l - 1;
  106.     END;
  107.     IF (x + w) > (screen_width) THEN
  108.         x := screen_width - w - 2;
  109.     END;
  110.  
  111. {Experimental mods to get max lines: very quick and dirty
  112. l := L + 3;
  113. --Y;
  114. FKey_row := 0;
  115. Status_row := 0;
  116. }
  117.     h_v_color := ((h_b_color and $07) shl 4) + (h_b_color shr 4);
  118.     tbc := box_count;
  119.     tstr := parse_str('/T=', mparm_str);
  120.     IF tstr = '' THEN
  121.         tstr := 'HELP';
  122.     END;
  123.  
  124. {Experimental mods to get max lines
  125. put_box( x,y,x + w,y + l, 0, h_b_color, tstr , false );
  126. Write('─', x + 31,y,0, h_b_color);
  127. }
  128.  
  129.     put_box( x,y,x + w + 2,y + l + 1, 0, h_b_color, tstr , true );
  130.  
  131.     push_labels;
  132.     flabel( 'Contns',2, - 1);
  133.     flabel( 'Index',3, - 1);
  134.     flabel( 'Paste',4, -1);
  135.     flabel( 'Search',6, - 1);
  136.   flabel( 'LdFile',7, - 1);                                           { ldh }
  137.  
  138.     IF file_help_mode THEN
  139.       flabel( 'FilHlp',8, - 1);                                           { ldh }
  140.       flabel( 'ExtHlp',9, - 1);                                           { ldh }
  141.     END;
  142.   flabel( 'MEHlp ',10, - 1);                                          { ldh }
  143.     flabel( 'NxtSrc',26, - 1);
  144.     flabel( 'SrcFil',36, - 1);
  145.  
  146.     help_start;
  147.     help_size_window( x, y, x + w, y + l );
  148.  
  149.     tstr := parse_str('/LK=', mparm_str);
  150.   if xpos('^', tstr, 1) = 0 then
  151.     tstr2 := parse_str('/F=', mparm_str);
  152.     if (file_help_mode) and (tstr2 = '') and (tstr = '') then                              { ldh }
  153.       call file_hlp;                                                  { ldh }
  154.       goto Do_Help;                                                   { ldh }
  155.     else                                                              { ldh }
  156.         call open_file2;
  157.         IF error_level <> 0 THEN
  158.           RM( 'MEERROR' );
  159.                 goto exit;
  160.         END;
  161.     end;                                                              { ldh }
  162.   end;
  163.   if tstr = '' then
  164.     tstr := '*';
  165.   end;
  166.   call select_link2;
  167.     help_current_offset := parse_int('/TO=', mparm_str );
  168.  
  169. Do_Help:
  170.  
  171.   done := false;
  172.     Set_Global_Str(event_str + '1',
  173.             '/T=Done/KC=<ESC>/W=9/K1=27/K2=1/R=0');
  174.     Set_Global_Str(event_str + '2',
  175.             '/T=Back-track/KC=<BackSpace>/W=21/K1=08/K2=14/R=1');
  176.     event_count := 2;
  177.     RM('CheckEvents /M=4/G=' + event_str + '/#=' + str(event_count) +
  178.                 '/X=' + str( x ) + '/Y=' + str( y + l ) + '/W=' + str( w ));
  179.  
  180.     Need_Event_Draw := TRUE;
  181.  
  182. loop:
  183.     Set_Virtual_Display;
  184.     IF need_search_display THEN
  185.         need_search_display := FALSE;
  186.         help_display_search;
  187.     ELSE
  188.         help_update;
  189.         help_hi_link;
  190.     END;
  191.     if need_event_draw THEN
  192.         call draw_events;
  193.     end;
  194.     call vertical_scroll_bar;
  195.     Update_Virtual_Display;
  196.     Reset_Virtual_Display;
  197.     IF error_level <> 0 THEN
  198.         jx := error_level;
  199.         run_macro('MEERROR');
  200.         error_level := 0;
  201.         if jx = 8001 then
  202.             call help_pop_pos;
  203.             IF error_level <> 0 THEN
  204.                 RM('MEERROR');
  205.                 done := TRUE;
  206.                 goto exit;
  207.             END;
  208.             help_update;
  209.             help_hi_link;
  210.         end;
  211.     END;
  212.     update_status_line;
  213.     while check_key = 0 DO
  214.         old_x := mou_last_x;
  215.         old_y := mou_last_y;
  216.         Mou_Check_Status;
  217.         IF ((old_x <> mou_last_x) or (old_y <> mou_last_y)) THEN
  218.             call check_links;
  219.         END;
  220.     end;
  221.  
  222.     help_lo_link;
  223.     IF key1 = 0 THEN
  224.         IF key2 = 72 THEN
  225.             help_up;
  226.         ELSIF key2 = 80 THEN
  227.             help_down;
  228.         ELSIF key2 = 77 THEN
  229.             help_right;
  230.         ELSIF key2 = 75 THEN
  231.             help_left;
  232.         ELSIF key2 = 71 THEN
  233.             help_home;
  234.         ELSIF key2 = 79 THEN
  235.             help_end;
  236.         ELSIF key2 = 116 THEN
  237.             help_scroll_right;
  238.         ELSIF key2 = 115 THEN
  239.             help_scroll_left;
  240.         ELSIF key2 = 141 THEN
  241.             help_scroll_up;
  242.         ELSIF key2 = 145 THEN
  243.             help_scroll_down;
  244.         ELSIF key2 = 81 THEN
  245.             help_pgdn;
  246.         ELSIF key2 = 73 THEN
  247.             help_pgup;
  248.         ELSIF key2 = 73 THEN
  249.             help_pgup;
  250.         ELSIF key2 = 59 THEN
  251.       call help_push_pos;                                             { ldh }
  252.       tstr := 'ACI_HYPE^*';
  253.             call select_link2;
  254.         ELSIF key2 = 60 THEN
  255.       call help_push_pos;                                             { ldh }
  256.             tstr := '*';
  257.             call select_link2;
  258.             help_update;
  259.             if error_level <> 0 THEN
  260.                 call help_pop_pos;
  261.                 tstr := 'ME^*';
  262.                 call select_link2;
  263.             END;
  264.         ELSIF key2 = 61 THEN
  265.       call help_push_pos;                                             { ldh }
  266.             tstr := 'INDEX';
  267.             call select_link2;
  268.             help_update;
  269.             if error_level <> 0 THEN
  270.                 call help_pop_pos;
  271.                 tstr := 'ME^INDEX';
  272.                 call select_link2;
  273.             END;
  274.         ELSIF key2 = 62 THEN {paste}
  275.             write( ' MARKING ', working_col, status_row, 0, working_color );
  276.             RM('ScreenMrk');
  277.             update_status_line;
  278.         ELSIF key2 = 64 THEN
  279.             jx := 0;
  280.             call prompt_and_search;
  281.     ELSIF key2 = 65 THEN                                              { ldh }
  282.       tstr := parse_str('/#=', global_str('FILE_HISTORY'));           { ldh }
  283.       if tstr = '' then                                               { ldh }
  284.         tstr := cur_file;                                             { ldh }
  285.       else                                                            { ldh }
  286.         tstr := global_str('FILE_HISTORY' + tstr);                    { ldh }
  287.       end;                                                            { ldh }
  288. QAgain:                                                               { ldh }
  289.       return_str := tstr;                                             { ldh }
  290.       Run_Macro('userin^QUERYBOX /HISTORY=FILE_HISTORY/C=3/W=60' +    { ldh }
  291.                 '/ML=80/T=HELP FILENAME TO LOAD/F2=Dir   /L=2');      { ldh }
  292.       if Return_Int = -1 then                                         { ldh }
  293.         if (caps(return_str) = '?NO-FILE?') or                        { ldh }
  294.                 (return_str = tstr) then                              { ldh }
  295.           return_str := '*.hl?';                                      { ldh }
  296.         elsif copy(return_str,length(return_str),1) <> '*' then       { ldh }
  297.           return_str := return_str + '*';                             { ldh }
  298.         end;                                                          { ldh }
  299.         Run_Macro('DIRSHELL /S=2/X=3/Y=' + str(2) +                   { ldh }
  300.           '/W=62/L=100/D=' + return_str);                             { ldh }
  301.         If Return_Str <> '' THEN                                      { ldh }
  302.             Tstr := Return_Str;                                       { ldh }
  303.         end;                                                          { ldh }
  304.         Goto QAgain;                                                  { ldh }
  305.       end;                                                            { ldh }
  306.       if return_int then                                              { ldh }
  307.         tstr := Caps(Return_Str);                                     { ldh }
  308.         if get_extension(tstr) = '' then                              { ldh }
  309.           tstr := tstr + '.HLP^*';                                    { ldh }
  310.         else                                                          { ldh }
  311.           tstr := tstr + '^*';                                        { ldh }
  312.         end;                                                          { ldh }
  313.         call help_push_pos;                                           { ldh }
  314.         call select_link2;                                            { ldh }
  315.       end;                                                            { ldh }
  316.     ELSIF key2 = 66 THEN                                              { ldh }
  317.             IF file_help_mode THEN
  318.           call help_push_pos;                                             { ldh }
  319.           call file_hlp;                                                  { ldh }
  320.             END;
  321.         ELSIF key2 = 67 THEN                                              { ldh }
  322.             IF file_help_mode THEN
  323.           call help_push_pos;                                             { ldh }
  324.           call file_ext_help;                                             { ldh }
  325.             END;
  326.     ELSIF key2 = 68 THEN                                              { ldh }
  327.       call help_push_pos;                                             { ldh }
  328.       tstr := 'ME^*';                                             { ldh }
  329.       call select_link2;                                              { ldh }
  330.         ELSIF key2 = 99 THEN
  331.             help_repeat_search;
  332.             need_new_bar := TRUE;
  333.             IF error_level = 0 THEN
  334.                 need_search_display := TRUE;
  335.             ELSE
  336.                 RM('MEERROR^MessageBox /M=No more occurrences found.');
  337.                 error_level := 0;
  338.             END;
  339.         ELSIF key2 = 109 THEN
  340.             jx := 1;
  341.             call prompt_and_search;
  342.         ELSIF key2 = 250 THEN
  343.             call check_mouse_pos;
  344.         END;
  345.     ELSIF key1 = 08 THEN
  346.         call help_pop_pos;
  347.     ELSIF key1 = 27 THEN
  348.         done := TRUE;
  349.     ELSIF key1 = 13 THEN
  350.         call select_link;
  351.     ELSE
  352.         jx := help_current_link;
  353.         help_find_index( caps(char(key1)) );
  354.         IF error_level = 8012 THEN
  355.             error_level := 0;
  356.         ELSE
  357.             if help_current_link = jx THEN
  358.                 call select_link;
  359.             end;
  360.         END;
  361.     END;
  362.     IF done THEN
  363.         goto exit;
  364.     END;
  365.  
  366.     IF error_level <> 0 THEN
  367.         run_macro('MEERROR');
  368.         error_level := 0;
  369.     END;
  370.  
  371.     goto loop;
  372.  
  373. file_hlp:                                                             { ldh }
  374.   tstr2 := fname;                                                     { ldh }
  375.   call open_file2;                                                    { ldh }
  376.   if error_level <> 0 then                                            { ldh }
  377.     error_level := 0;                                                 { ldh }
  378.     call file_ext_help;                                               { ldh }
  379.   else                                                                { ldh }
  380.     tstr := hstr;                                                     { ldh }
  381.     call select_link2;                                                { ldh }
  382.     help_update;                                                      { ldh }
  383.     if error_level <> 0 then                                          { ldh }
  384.       error_level := 0;                                               { ldh }
  385.       tstr := '*';                                                    { ldh }
  386.       call select_link2;                                              { ldh }
  387.       help_update;                                                    { ldh }
  388.       if error_level <> 0 then                                        { ldh }
  389.         error_level := 0;                                             { ldh }
  390.         call file_ext_help;                                           { ldh }
  391.       end;                                                            { ldh }
  392.     end;                                                              { ldh }
  393.   end;                                                                { ldh }
  394.   ret;                                                                { ldh }
  395.  
  396. file_ext_help:                                                        { ldh }
  397.   if extfil = '' then                                                 { ldh }
  398.     tstr := 'ME^*';                                               { ldh }
  399.   else                                                                { ldh }
  400.     tstr2 := extfil;                                                  { ldh }
  401.     call open_file2;                                                  { ldh }
  402.     if error_level <> 0 then                                          { ldh }
  403.       error_level := 0;                                               { ldh }
  404.       tstr := 'ME^*';                                             { ldh }
  405.     else                                                              { ldh }
  406.       tstr := extlnk + hstr;                                          { ldh }
  407.     end;                                                              { ldh }
  408.   end;                                                                { ldh }
  409.   call select_link2;                                                  { ldh }
  410.   help_update;                                                        { ldh }
  411.   if error_level <> 0 then                                            { ldh }
  412.     error_level := 0;                                                 { ldh }
  413.     tstr := '*';                                                      { ldh }
  414.     call select_link2;                                                { ldh }
  415.     help_update;                                                      { ldh }
  416.     if error_level <> 0 then                                          { ldh }
  417.       error_level := 0;                                               { ldh }
  418.       call help_pop_pos;                                              { ldh }
  419.       tstr := 'ME^*';                                             { ldh }
  420.       call select_link2;                                              { ldh }
  421.     end;                                                              { ldh }
  422.   end;                                                                { ldh }
  423.   ret;                                                                { ldh }
  424.  
  425. prompt_and_search:
  426.     return_str := '';
  427.     RM('USERIN^USERSTR /W=60/BL=INPUT SEARCH STR/B=1');
  428.     IF return_int THEN
  429.     jy := help_current_link;
  430.         working;
  431.         help_search(return_str, jx);
  432.         need_new_bar := TRUE;
  433.         IF error_level = 0 THEN
  434.             need_search_display := TRUE;
  435.         ELSE
  436.             RM('MEERROR^MessageBox /M=Search string"' + return_str + '" not found.');
  437.       help_current_link := jy;
  438.             error_level := 0;
  439.         END;
  440.     END;
  441.     RET;
  442.  
  443. select_link:
  444.     IF help_link_count > 0 THEN
  445.         working;
  446.         call help_push_pos;
  447.         tstr := help_link( help_current_link );
  448. select_link2:
  449.         jx := xpos('^', tstr, 1);
  450.         IF jx <> 0 THEN
  451.             tstr2 := copy( tstr, 1, jx - 1 );
  452.             tstr := str_del( tstr, 1, jx );
  453.             call open_file2;
  454.             IF error_level <> 0 THEN
  455.                 run_macro('MEERROR');
  456.                 error_level := 0;
  457.                 call help_pop_pos;
  458.                 ret;
  459.             END;
  460.         END;
  461.         IF str_char(tstr,1) = '<' THEN
  462.             tstr := str_del( tstr, 1, 1 );
  463.             save_box( 1, 1, screen_width, screen_length );
  464.             shell_to_dos( tstr, true );
  465.             restore_box;
  466.     ELSIF str_char( tstr, 1 ) = '>' THEN
  467.             tstr := str_del( tstr, 1, 1 );
  468.       RM( tstr );
  469.     ELSE
  470.             jx := xpos( '%', tstr, 1 );
  471.             IF jx <> 0 THEN
  472.                 if JX > 1 THEN
  473.                     help_select( copy(tstr,1,jx - 1) );
  474.                 END;
  475.                 IF error_level = 0 THEN
  476.                     help_search( copy(tstr,jx + 1, 255 ), 0);
  477.                     IF error_level = 0 THEN
  478.                         need_search_display := TRUE;
  479.                     ELSE
  480.                         RM('MEERROR^MessageBox /B=1/M=Search string "' + copy(tstr,jx + 1, 255 ) + '" not found.');
  481.                         error_level := 0;
  482.                     END;
  483.                 END;
  484.             ELSE
  485.                 help_select( tstr );
  486.             END;
  487.         END;
  488.         need_new_bar := TRUE;
  489.     end;
  490.     ret;
  491.  
  492. help_pop_pos:
  493.     jx := global_int('@HSTACK' );
  494.     IF jx > 0 THEN
  495.         working;
  496.         tstr2 := parse_str('/F=',global_str('@HSTACK' + str(jx) ));
  497.         if tstr2 <> cur_file THEN
  498.             call open_file2;
  499.         END;
  500.         tstr := global_str('@HSTACK' + str(jx) );
  501.         help_select( parse_str('/C=', tstr ));
  502.         help_current_offset := parse_int('/O=', tstr );
  503.         help_current_link := parse_int('/L=', tstr );
  504.  
  505.         set_global_str('@HSTACK' + str(jx), '' );
  506.         --jx;
  507.         set_global_int('@HSTACK', jx );
  508.         need_new_bar := TRUE;
  509.     else                                                                { ldh1 }
  510.     tstr2 := 'ME.HLP';                                                { ldh2 }
  511.     call open_file2;                                                  { ldh2 }
  512.     IF error_level <> 0 THEN                                          { ldh2 }
  513.       RM( 'MEERROR' );                                                { ldh2 }
  514.       goto exit;                                                      { ldh2 }
  515.     END;                                                              { ldh2 }
  516.     tstr := '*';                                                      { ldh2 }
  517.     call select_link2;                                                { ldh1 }
  518.     END;
  519.     ret;
  520.  
  521. set_pos:
  522.     return_str := help_current_chapter;
  523.     call double_slash;
  524.     return_str :=     '/F=' + cur_file +
  525.                                     '/O=' + str(help_current_offset) +
  526.                                     '/C=' + return_str  +
  527.                                     '/L=' + str(help_current_link);
  528.     ret;
  529.  
  530. help_push_pos:
  531.     jx := global_int('@HSTACK' );
  532.     call set_pos;
  533.  
  534.     IF return_str <> Global_Str( '@HSTACK' + str(jx))THEN
  535.         IF jx > 20 THEN
  536.             return_int := 1;
  537.             RM('USERIN^DELETEITEM /G=@HSTACK/#=' + str( jx ));
  538.         ELSE
  539.             ++jx;
  540.         END;
  541.         Set_Global_Str('@HSTACK' + str(jx), return_str);
  542.         set_global_int('@HSTACK', jx );
  543.     END;
  544.     ret;
  545.  
  546. open_file:
  547.     call help_push_pos;
  548. open_file2:
  549.     working;
  550.     need_new_bar := TRUE;
  551.     cur_file := tstr2;
  552.     if cur_file = '' THEN
  553.         cur_file := 'ME.HLP';
  554.     END;
  555.  
  556.     {Check for compressed file}
  557.     tstr2 := get_extension( cur_file );
  558.     cur_file := truncate_extension( cur_file );
  559.  
  560.  
  561.     IF (tstr2 = 'HLP') OR (tstr2 = '') THEN
  562.         Return_Str := Get_Path(cur_file);                                 { ldh1 }
  563.         if Return_Str = '' then                                           { ldh1 }
  564.             return_str := help_path;
  565. {     end;                                                            { ldh3} }
  566.       RM('PATHSEARCH /F=' +  Truncate_Path(cur_file) + '.HL?');       { ldh1 }
  567.     elsif file_exists(cur_file + '.HL?') then                         { ldh3 }
  568.       Return_Int := TRUE;                                             { ldh3 }
  569.       Return_Str := fexpand(cur_file + '.HL?');                       { ldh3 }
  570.     else;                                                             { ldh3 }
  571.       Return_Int := FALSE;                                            { ldh3 }
  572.     end;                                                              { ldh3 }
  573.         IF return_int THEN
  574.             cur_file := truncate_extension( return_str );
  575.    {   IF (first_file( cur_file + '.HLC' ) = 0) THEN
  576.                 hlc_time := Last_File_Time;
  577.                 tstr2 := 'HLC';
  578.                 IF (first_file( cur_file + '.HLP' ) = 0) THEN
  579.                     IF last_file_time > hlc_time THEN
  580.                         tstr2 := 'HLP';
  581.                     END;
  582.                 END;
  583.                 cur_file := fexpand( cur_file + '.' + tstr2 );
  584.         goto hlc_found;  }
  585.       IF (first_file( cur_file + '.HLX' ) = 0) THEN
  586.                 hlc_time := Last_File_Time;
  587.         tstr2 := 'HLX';
  588.                 IF (first_file( cur_file + '.HLP' ) = 0) THEN
  589.                     IF last_file_time > hlc_time THEN
  590.                         tstr2 := 'HLP';
  591.                     END;
  592.                 END;
  593.                 cur_file := fexpand( cur_file + '.' + tstr2 );
  594.                 goto hlc_found;
  595.             ELSE
  596.                 IF file_exists( cur_file + '.HLP' ) THEN
  597.                     cur_file := cur_file + '.HLP';
  598.                     goto hlc_found;
  599.                 END;
  600.             END;
  601.         END;
  602.         error_level := 8002;                                              { ldh1 }
  603.         ret;
  604.     END;
  605.  
  606.     cur_file := truncate_extension( cur_file ) + '.' + tstr2;
  607.     Return_Str := Get_Path(cur_file);                                     { ldh1 }
  608.     if Return_Str = '' then                                               { ldh1 }
  609.         return_str := help_path;
  610.     end;                                                                  { ldh1 }
  611.     RM('PATHSEARCH /F=' +  Truncate_Path(cur_file));                    { ldh1 }
  612.     IF return_int THEN
  613.         cur_file := return_str;
  614.         goto do_open;
  615.     END;
  616.     error_level := 8002;                                                  { ldh1 }
  617.     ret;
  618.  
  619. hlc_found:
  620.  
  621. do_open:
  622.     help_open_file( cur_file );
  623.     call draw_top_name;
  624.     ret;
  625.  
  626. check_mouse_pos:
  627.     IF (Mou_Last_Y = Fkey_Row) THEN
  628.         RM( 'MOUSE^MouseFkey' );
  629.     ELSE
  630.         IF (Mou_Last_X < x) OR (Mou_Last_Y < y) OR (Mou_Last_X > (x + w)) OR
  631.                 (Mou_Last_Y > (y + l)) THEN
  632.             ret;
  633.         END;
  634.         IF (Mou_Last_X = (x + w)) THEN
  635.             IF (scroll_bar) THEN
  636.                 IF (Mou_Last_Y = (y + 1)) THEN
  637.                     help_scroll_up;
  638.                 ELSIF (Mou_Last_Y = (y + l - 1)) THEN
  639.                     help_scroll_down;
  640.             {    ELSIF (Mou_Last_Y > (y + 1 )) AND (Mou_Last_Y < (y + l - 1)) THEN
  641.                     IF (Mou_Last_Y = (y + l - 2)) THEN
  642.                             jx := help_chapter_length - (l - 1);
  643.                     ELSE
  644.                         jx := ((((help_chapter_length - (l - 1)) * 1000) / (l - 3)) * (Mou_Last_Y - Y - 2)) / 1000;
  645.                     END;
  646.                     IF (help_current_offset + (l - 1)) > help_chapter_length THEN
  647.                         jx := help_chapter_length - (l - 1);
  648.                     END;
  649.                     help_select( help_current_chapter );
  650.                     help_current_offset := jx;
  651.                 END;
  652.             }
  653.                 ELSIF    (Mou_Last_Y > ( y + 2 + old_sb)) THEN
  654.                     help_pgdn;
  655.                 ELSIF    (Mou_Last_Y < ( y + 2 + old_sb)) THEN
  656.                     help_pgup;
  657.                 ELSIF    (Mou_Last_Y = ( y + 2 + old_sb)) THEN
  658.                     Mou_Set_Limits(x + w,y + 2,x + w, y + l - 2);
  659.                     old_y := mou_last_y;
  660.                     du3:
  661.                         Mou_Check_Status;
  662.                         IF ((Mou_Last_Status AND 1) <> 0) THEN
  663.                             IF old_y <> mou_last_y THEN
  664.                                 old_y := mou_last_y;
  665.                                 IF (y + 2 + old_sb) <> mou_last_y THEN
  666.                                     IF (Mou_Last_Y = (y + l - 2)) THEN
  667.                                             jx := help_chapter_length - (l - 1);
  668.                                     ELSE
  669.                                         jx := ((((help_chapter_length - (l - 1)) * 1000) / (l - 3)) * (Mou_Last_Y - Y - 2)) / 1000;
  670.                                     END;
  671.                                     IF (help_current_offset + (l - 1)) > help_chapter_length THEN
  672.                                         jx := help_chapter_length - (l - 1);
  673.                                     END;
  674.                                     help_select( help_current_chapter );
  675.                                     help_current_offset := jx;
  676.                                     help_update;
  677.                                     call vertical_scroll_bar;
  678.                                 END;
  679.                             END;
  680.                             goto du3;
  681.                         END;
  682.                     Mou_Set_Limits(1,1,screen_width, screen_length);
  683.  
  684.                 END;
  685.             END;
  686.         ELSE
  687.             call check_links;
  688.             if return_int then
  689.                 call select_link;
  690.             end;
  691.             RM('CheckEvents /M=1/G=' + event_str + '/#=' + str(event_count));
  692.             IF return_int <> 0 THEN
  693.                 return_int := parse_int('/R=', return_str );
  694.                 IF return_int = 0 THEN
  695.                     done := TRUE;
  696.                 ELSIF return_int = 1 THEN
  697.                     call help_pop_pos;
  698.                 END;
  699.                 need_event_draw := TRUE;
  700.             END;
  701.         END;
  702.     END;
  703.     ret;
  704.  
  705.     {see if the mouse cursor is on a link}
  706. check_links:
  707.     return_int := 0;
  708.     jx := 0;
  709.     while jx < help_link_count do
  710.         ++jx;
  711.         jy := help_link_x(jx);
  712.         IF (Mou_Last_Y = help_link_y(jx)) AND
  713.             (Mou_Last_X >= jy) AND
  714.             (Mou_Last_X < (jy + help_link_w(jx))) THEN
  715.             IF jx <> help_current_link THEN
  716.                 help_lo_link;
  717.                 help_current_link := jx;
  718.             end;
  719.             help_hi_link;
  720.             return_int := 1;
  721.             jx := help_link_count;
  722.         END;
  723.     end;
  724.     ret;
  725.  
  726.     def_int( dt1 );
  727. draw_top_name:
  728.     tstr2 := cur_file;
  729.     dt1 := (( w / 2 ) - (svl(tstr2) / 2));
  730.     IF dt1 < 0 THEN
  731.         tstr2 := truncate_path(tstr2);
  732.         dt1 := (( w / 2 ) - (svl(tstr2) / 2));
  733.     END;
  734.     IF dt1 > 0 THEN
  735.         draw_char( 196, x + 1, y, h_b_color, dt1 );
  736.     END;
  737.     write( tstr2, x + dt1 + 1, y, 0, h_b_color );
  738.     IF dt1 > 1 THEN
  739.         draw_char( 196, x + dt1 + svl(tstr2) + 1, y, h_b_color, dt1 - 1 );
  740.     END;
  741.     ret;
  742.  
  743. draw_events:
  744.     RM('WMENU^CheckEvents /M=2/G=' + event_str + '/#=' + str(event_count));
  745.     need_event_draw := FALSE;
  746.     ret;
  747.  
  748.  
  749. Vertical_Scroll_Bar:
  750.     IF need_new_bar then
  751.         call set_scroll_bar;
  752.     END;
  753.     IF scroll_bar THEN
  754.          jz := l - 3;
  755.  
  756.         jx := ((help_current_offset + 1) / jy);
  757.  
  758.       jy := help_chapter_length - (l - 1);
  759.         IF jy < 1 THEN
  760.             jy := 1;
  761.         END;
  762.         cl := help_current_offset;
  763.  
  764.     jx := ((((jz * 1000) / jy) * (cl + 1)) / 1000);
  765.  
  766.     IF (cl = 0) THEN
  767.       jx := 0;
  768.     END;
  769.     IF (jx = 0) AND (cl > 0) THEN
  770.       ++jx;
  771.     END;
  772.         IF jx > (jz - 1) THEN
  773.             jx := jz - 1;
  774.         END;
  775.         IF (jx = (jz - 1)) AND (cl < jy) THEN
  776.          --jx;
  777.         END;
  778.         IF jx <> old_sb THEN
  779.             IF (old_sb >= 0) THEN
  780.           draw_char( 176, x + w, y + 2 + old_sb, h_b_color, 1 );
  781.             END;
  782.         draw_char( 178, x + w, y + 2 + jx, h_b_color, 1 );
  783.             old_sb := jx;
  784.         END;
  785.     END;
  786.     ret;
  787.  
  788. set_scroll_bar:
  789.     jy := 0;
  790.     need_new_bar := 0;
  791.     IF help_chapter_length < l THEN
  792.         scroll_bar := false;
  793.         While jy < (l - 1) DO
  794.             ++jy;
  795.         draw_char( 186, x + w, y + jy, h_b_color, 1 );
  796.         END;
  797.     ELSE
  798.         scroll_bar := true;
  799.         WHILE jy < (l - 2) DO
  800.             ++jy;
  801.         draw_char( 176, x + w, y + 1 + jy, h_b_color, 1 );
  802.       END;
  803.       draw_char( 24, x + w, y + 1, h_v_color, 1 );
  804.       draw_char( 25, x + w, (y + l) - 1, h_v_color, 1 );
  805.         old_sb := -1;
  806.     END;
  807.     ret;
  808.  
  809.     def_int( djx );
  810. double_slash:
  811.     djx := 1;
  812.     while djx > 0 DO
  813.         djx := xpos( '/', return_str, djx );
  814.         IF djx <> 0 THEN
  815.             return_str := str_ins( '/', return_str, djx );
  816.             ++djx;
  817.             ++djx;
  818.         END;
  819.     END;
  820.     ret;
  821.  
  822.  
  823. exit:
  824.     call help_push_pos;
  825.     IF help_open THEN
  826.         help_done;
  827.     END;
  828.  
  829.  
  830.     WHILE box_count > tbc DO
  831.         kill_box;
  832.     END;
  833.     pop_labels;
  834.     gotoxy( tx, ty );
  835.     mou_repeat := trepeat;
  836.     fkey_row := tfkey_row;
  837.     status_row := tstatus_row;
  838.     refresh := trefresh;
  839.     Set_Global_Int('MENU_LEVEL', Global_Int('MENU_LEVEL') - 1);
  840.     RM('CheckEvents /M=3/G=' + event_str + '/#=' + str(event_count));
  841. total_exit:
  842. END_MACRO;
  843.  
  844.  
  845. {*******************************MULTI-EDIT MACRO******************************
  846.  
  847. Name:  ScreenMrk
  848.  
  849. Description:    Allows any part of the screen to be marked, and have
  850.     that section of the screen copied to a buffer.
  851.  
  852.                (C) Copyright 1989 by American Cybernetics, Inc.
  853. ******************************************************************************}
  854. $MACRO ScreenMrk;
  855.     def_int( need_hi, oldx,oldy,x1, y1, xi, yi, xl, jx, yl, mouse_down, tmou_repeat );
  856.     def_int( temp_fkey_row, temp_status_row, tr );
  857.     oldx := wherex;
  858.     oldy := wherey;
  859.     tr := refresh;
  860.     refresh := false;
  861.     temp_fkey_row := fkey_row;
  862.     fkey_row := 0;
  863.     push_labels;
  864.     temp_status_row := status_row;
  865.     status_row := 0;
  866.     need_hi := false;
  867.     mouse_down := FALSE;
  868.     tmou_repeat := mou_repeat;
  869.     mou_repeat := FALSE;
  870. loop1:
  871.     read_key;
  872.     IF key1 = 0 THEN
  873.         IF key2 = 250 THEN
  874.             mouse_down := TRUE;
  875.             gotoxy( mou_last_x, mou_last_y );
  876.             goto start2;
  877.         ELSE
  878.             call arrow_keys;
  879.         END;
  880.     ELSIF key1 = 13 THEN
  881.         goto start2;
  882.     ELSIF key1 = 27 THEN
  883.         goto exit;
  884.     END;
  885.     goto loop1;
  886.  
  887. start2:
  888.     x1 := wherex;
  889.     y1 := wherey;
  890.     save_box( 1, 1, screen_width, screen_length );
  891.     call draw_highlight;
  892. loop2:
  893.     IF check_key THEN
  894.         IF key1 = 0 THEN
  895.             IF key2 = 250 THEN
  896.                 gotoxy( mou_last_x, mou_last_y );
  897.                 call draw_highlight;
  898.                 goto accept;
  899.             ELSE
  900.                 CALL arrow_keys;
  901.             END;
  902.         ELSIF key1 = 13 THEN
  903.             goto accept;
  904.         ELSIF key1 = 27 THEN
  905.             goto exit2;
  906.         END;
  907.     ELSIF mouse_down THEN
  908.         Mou_Check_Status;
  909.         IF (Mou_Last_Status and 1) THEN
  910.             IF (mou_last_x <> wherex) OR (mou_last_y <> wherey) THEN
  911.                 gotoxy( mou_last_x, mou_last_y);
  912.                 need_hi := TRUE;
  913.             ELSE
  914.             END;
  915.         ELSE
  916.             goto accept;
  917.         END;
  918.     END;
  919.     if need_hi THEN
  920.         call DRAW_HIGHLIGHT;
  921.     END;
  922.     goto loop2;
  923.  
  924. accept:
  925.     call DRAW_HIGHLIGHT;
  926.     RM('USERIN^XMENU /L=Screen Paste/T=1/B=1/X' + str(xi) +
  927.                         '/Y=' + str(yi) +
  928.             '/M=Copy text to buffer, erasing old contents()Append text to end of buffer()');
  929.     IF (return_int < 1) THEN
  930.         goto exit2;
  931.     ELSE
  932.         RM('ScreenCut /X1=' + str( xi ) + '/X2=' + str( xi + xl - 1) +
  933.                         '/Y1=' + str(yi) + '/Y2=' + str(yl) + '/M=' + str( return_int = 2 ) );
  934.     END;
  935.  
  936. EXIT2:
  937.     kill_box;
  938.     GOTO EXIT;
  939.  
  940. ARROW_KEYS:
  941.     IF key2 = 72 THEN {up}
  942.         IF wherey > 1 THEN
  943.             gotoxy(wherex, wherey - 1);
  944.             need_hi := TRUE;
  945.         END;
  946.     ELSIF key2 = 80 THEN {down}
  947.         IF wherey < screen_length THEN
  948.             gotoxy(wherex, wherey + 1);
  949.             need_hi := TRUE;
  950.         END;
  951.     ELSIF key2 = 77 THEN {right}
  952.         IF wherex < screen_width THEN
  953.             gotoxy(wherex + 1, wherey);
  954.             need_hi := TRUE;
  955.         END;
  956.     ELSIF key2 = 75 THEN {left}
  957.         IF wherex > 1 THEN
  958.             gotoxy(wherex - 1, wherey);
  959.             need_hi := TRUE;
  960.         END;
  961.     END;
  962.     RET;
  963.  
  964. DRAW_HIGHLIGHT:
  965.     need_hi := false;
  966.     RESTORE_BOX;
  967.     IF x1 > wherex THEN
  968.         xi := wherex;
  969.         xl := x1 - wherex + 1;
  970.     ELSE
  971.         xi := x1;
  972.         xl := wherex - x1 + 1;
  973.     END;
  974.     IF y1 > wherey THEN
  975.         yi := wherey;
  976.         yl := y1;
  977.     ELSE
  978.         yi := y1;
  979.         yl := wherey;
  980.     END;
  981.     jx := yi;
  982.     WHILE jx <= yl DO
  983.         draw_attr( xi, jx, m_h_color, xl );
  984.         ++jx;
  985.     END;
  986.     RET;
  987.  
  988.  
  989. EXIT:
  990.     status_row := temp_status_row;
  991.     fkey_row := temp_fkey_row;
  992.     pop_labels;
  993.     gotoxy(oldx, oldy);
  994.     mou_repeat := tmou_repeat;
  995.     refresh := tr;
  996. END_MACRO;
  997.  
  998. $MACRO ScreenCut;
  999. {*******************************MULTI-EDIT MACRO*******************************
  1000.  
  1001. Name:    ScreenCut
  1002.  
  1003. Description:
  1004.  
  1005. Parameters:
  1006.                             /X1= the upper left hand column
  1007.                             /Y1= the upper left hand row
  1008.                             /X2= the lower right hand column
  1009.                             /Y2= the lower right hand row
  1010.                             /M=nn  mode
  1011.                                         0 = Copy block to buffer, overwriting old contents
  1012.                                         1 = Append block to buffer
  1013.  
  1014.                              (C) Copyright 1989 by American Cybernetics, Inc.
  1015. ******************************************************************************}
  1016.     Def_Int(tr, Active_Page, ox,x1,y1,x2,y2, old_win, tu);
  1017.     Def_Str(TStr, buf_name);
  1018.  
  1019.     tr := refresh;
  1020.     refresh := FALSE;
  1021.     tu := undo_stat;
  1022.     undo_stat := FALSE;
  1023.     old_win := window_id;
  1024.     buf_name := me_path + '!BUF' + User_Id + '.' + Str(0);
  1025.     if switch_file(buf_name) = 0 then
  1026.         switch_window(window_count);
  1027.         create_window;
  1028.         if error_level <> 0 then
  1029.             goto exit;
  1030.         end;
  1031.         window_attr := $81;
  1032.         file_name := buf_name;
  1033.     else
  1034.         window_attr := $81;
  1035.         IF parse_int('/M=', mparm_str) = 0 THEN
  1036.             Erase_Window;
  1037.         END;
  1038.         file_name := buf_name;
  1039.         eof;
  1040.         Goto_Col(1);
  1041.         IF NOT(at_Eof) THEN
  1042.             down;
  1043.         END;
  1044.     end;
  1045.  
  1046.     x1 := parse_int('/X1=', mparm_str);
  1047.     y1 := parse_int('/Y1=', mparm_str);
  1048.     x2 := parse_int('/X2=', mparm_str);
  1049.     y2 := parse_int('/Y2=', mparm_str);
  1050.  
  1051.     R_AX := $0F00;
  1052.     Intr($10);
  1053.     Active_Page := R_BX;
  1054.     ox := x1;
  1055.     WHILE (y1 <= y2) DO
  1056.         tstr := '';
  1057. {Get the screen a line at a time}
  1058.         x1 := ox;
  1059.         WHILE (x1 <= x2) DO
  1060. {Get the character at the cursor}
  1061.             GotoXY(x1,y1);
  1062.             R_AX := $0800;
  1063.             R_BX := Active_Page;
  1064.             Intr($10);
  1065.             TStr := TStr + Char(R_AX and $FF);
  1066.             ++x1;
  1067.         END;
  1068.         ++y1;
  1069.  
  1070.         put_line( tstr );
  1071.         down;
  1072.     END;
  1073.     tof;
  1074.     block_begin;
  1075.     eof;
  1076.     block_end;
  1077. exit:
  1078.     switch_win_id( old_win );
  1079.     undo_stat := TU;
  1080.     refresh := TR;
  1081. END_MACRO;
  1082.  
  1083. $Macro Get_Context;
  1084. {******************************************************************************
  1085.                                Multi-Edit Macro
  1086.                                03-05-90 10:11am
  1087.  
  1088.   Macro   : Get_Context
  1089.   Function: Return the word under the cursor defined by the passed Regular
  1090.             Expresson or the word marked by a column or stream block.  The
  1091.             marked word will only be used if the cursor is on the same line
  1092.             as the marked word.
  1093.   Syntax  : RM('Get_Context');
  1094.   Entry   : Return_Str = Regular Expression defining context word.
  1095.               Default Regular Expression = '[A-Za-z0-9._]'.
  1096.   Exit    : Return_Str = Context word under the cursor or marked block.
  1097.  
  1098.                (C) Copyright 1990 by American Cybernetics, Inc.
  1099. ***********************************************************************(ldh)**}
  1100.  
  1101.   Def_Str(tstr[100], tstr2[100]);
  1102.   Def_Int(org_refresh, org_reg, col);
  1103.  
  1104.   {Set up our context}
  1105.   org_refresh := REFRESH;
  1106.   REFRESH := FALSE;                       {No flashing of windows}
  1107.   org_reg := Reg_Exp_Stat;
  1108.   Reg_Exp_Stat := TRUE;                   {Regular expression search}
  1109.  
  1110.   Mark_Pos;                               {Save current column position}
  1111.  
  1112.   tstr := Return_Str;                     {Get Word Definition}
  1113.   if tstr = '' then
  1114.     tstr := '[A-Za-z0-9._]';
  1115.   end;
  1116.   tstr2 := Str_Ins('~', tstr, 2);
  1117.  
  1118.   if Marking then
  1119.     Block_End;
  1120.   end;
  1121.   if (Block_Stat > 1) And (Block_Line1 = C_Line) And (Block_Line2 = C_Line) Then
  1122.     Goto_Col(Block_Col1);
  1123.     col := Block_Col2 + 1;
  1124.   else
  1125.     Search_Bwd(tstr, 1);
  1126.     if Search_Bwd(tstr2, 1) = 0 then
  1127.       Goto_Col(1);
  1128.     end;
  1129.     Search_Fwd(tstr, 1);
  1130.     Mark_Pos;
  1131.     if Search_Fwd(tstr2, 1) = 0 then
  1132.       EOL;
  1133.     end;
  1134.     col := C_Col;
  1135.     Goto_Mark;
  1136.   end;
  1137.  
  1138.   {Grab the characters that make up this word}
  1139.   Return_Str := '';
  1140.   while (C_Col < col) do
  1141.     Return_Str := Return_Str + Cur_Char;
  1142.     right;
  1143.   end;
  1144.  
  1145.   {Restore original cursor position}
  1146.   Goto_Mark;
  1147.  
  1148.   REFRESH := org_refresh;
  1149.   Reg_Exp_Stat := org_reg;
  1150.  
  1151. End_Macro;  {Get_Context}