home *** CD-ROM | disk | FTP | other *** search
/ The Developer Connection…ice Driver Kit for OS/2 3 / DEV3-D1.ISO / devtools / dataflex / dfhelp_a.src < prev    next >
Encoding:
Text File  |  1993-05-19  |  66.0 KB  |  1,834 lines

  1. // dfhelp_a.src (secondary help maintenance program [A])
  2. // July 25, 1991
  3. // LS
  4.  
  5. use dfhelp_a  // secondary help maintenance program [A] header package
  6.  
  7. function is_critical for (class(error_info_object.obj)) integer error_number returns integer
  8.     function_return 0
  9. end_function
  10.  
  11. //////////////////////////////////
  12. ////////////////////////////////// global variables
  13. //////////////////////////////////
  14.  
  15. string cmd_option  // option passed on cmd line (via chain wait)
  16. move EMPTY_STRING to cmd_option
  17.  
  18. string current_grp current_sbj current_xrf current_ctx current_pth
  19. move EMPTY_STRING to current_grp   // names of currently open help data files
  20. move EMPTY_STRING to current_sbj   // passed on cmd line (via chain wait)
  21. move EMPTY_STRING to current_xrf
  22. move EMPTY_STRING to current_ctx
  23. move EMPTY_STRING to current_pth
  24.  
  25. //////////////////////////////////
  26. ////////////////////////////////// global procedures
  27. //////////////////////////////////
  28.  
  29. procedure deactivate_area for desktop
  30.     send deactivate AREA_TYPE
  31. end_procedure
  32.  
  33. procedure insert_cb for desktop string val integer itm
  34.     local integer flag
  35.  
  36.     get insert_mode of clipboard to flag
  37.     set insert_mode of clipboard to true
  38.  
  39.     send goto_line to clipboard itm
  40.     set right_margin of clipboard to 56
  41.     send key to clipboard kenter
  42.     set value of clipboard item itm to val
  43.  
  44.     set insert_mode of clipboard to flag
  45. end_procedure
  46.  
  47. function next_cmd_arg for desktop returns string
  48.     local string arg
  49.  
  50.     cmdline arg
  51.     if arg le EMPTY_STRING begin
  52.         error 57 ("Command line argument not specified")
  53.         send insert_cb FAIL_REPLY 0
  54.         abort
  55.     end
  56.     if arg eq EMPTY_REPL_STRING function_return EMPTY_STRING
  57.     else function_return arg
  58. end_function
  59.  
  60. procedure init_program for desktop // retrieve option passed on command line to determine which objects to use
  61.     cmdline cmd_option
  62.  
  63.     if cmd_option le EMPTY_STRING begin
  64.         error 57 ("Option not specified for program")
  65.         send insert_cb FAIL_REPLY 0
  66.         abort
  67.     end
  68.  
  69.     left cmd_option to cmd_option 1
  70.     uppercase cmd_option
  71.  
  72.     if not cmd_option in VALID_OPTIONS begin
  73.         error 57 ("Invalid option passed to program: " + cmd_option)
  74.         send insert_cb FAIL_REPLY 0
  75.         abort
  76.     end
  77.  
  78.     if cmd_option ne PATH_OPTION begin
  79.         get next_cmd_arg to current_grp
  80.         get next_cmd_arg to current_sbj
  81.         get next_cmd_arg to current_xrf
  82.         get next_cmd_arg to current_ctx
  83.         get next_cmd_arg to current_pth
  84.     end
  85. end_procedure
  86.  
  87. procedure exit_program for desktop
  88.     send insert_cb ABORT_REPLY 0
  89.     send exit_application
  90. end_procedure
  91.  
  92. send init_program
  93.  
  94. //////////////////////////////////
  95. ////////////////////////////////// augmentation to help_object class to
  96. ////////////////////////////////// override default help access
  97. //////////////////////////////////
  98.  
  99. procedure request_help for (class(help_object.obj)) integer msg_id integer arg
  100.     local integer orig_grp orig_sbj orig_xrf orig_ctx
  101.     local string old_grp_filename old_sbj_filename old_xrf_filename old_ctx_filename
  102.     local string cur_grp_filename cur_sbj_filename cur_xrf_filename cur_ctx_filename
  103.  
  104.     move current_pth to cur_grp_filename
  105.     append cur_grp_filename current_grp
  106.     move current_pth to cur_sbj_filename
  107.     append cur_sbj_filename current_sbj
  108.     move current_pth to cur_xrf_filename
  109.     append cur_xrf_filename current_xrf
  110.     move current_pth to cur_ctx_filename
  111.     append cur_ctx_filename current_ctx
  112.  
  113.     if cur_grp_filename gt EMPTY_STRING begin
  114.         move grp.recnum to orig_grp
  115.         close grp
  116.     end
  117.     if cur_sbj_filename gt EMPTY_STRING begin
  118.         move sbj.recnum to orig_sbj
  119.         close sbj
  120.     end
  121.     if cur_xrf_filename gt EMPTY_STRING begin
  122.         move xrf.recnum to orig_xrf
  123.         close xrf
  124.     end
  125.     if cur_ctx_filename gt EMPTY_STRING begin
  126.         move ctx.recnum to orig_ctx
  127.         close ctx
  128.     end
  129.  
  130.     if num_arguments gt 1 send msg_id arg
  131.     else send msg_id
  132.  
  133.     if cur_grp_filename gt EMPTY_STRING begin
  134.         open cur_grp_filename as grp
  135.         clear grp
  136.         if orig_grp ne 0 begin
  137.             move orig_grp to grp.recnum
  138.             find eq grp.recnum
  139.         end
  140.     end
  141.     if cur_sbj_filename gt EMPTY_STRING begin
  142.         open cur_sbj_filename as sbj
  143.         clear sbj
  144.         if orig_sbj ne 0 begin
  145.             move orig_sbj to sbj.recnum
  146.             find eq sbj.recnum
  147.         end
  148.     end
  149.     if cur_xrf_filename gt EMPTY_STRING begin
  150.         open cur_xrf_filename as xrf
  151.         clear xrf
  152.         if orig_xrf ne 0 begin
  153.             move orig_xrf to xrf.recnum
  154.             find eq xrf.recnum
  155.         end
  156.     end
  157.     if cur_ctx_filename gt EMPTY_STRING begin
  158.         open cur_ctx_filename as ctx
  159.         clear ctx
  160.         if orig_ctx ne 0 begin
  161.             move orig_ctx to ctx.recnum
  162.             find eq ctx.recnum
  163.         end
  164.     end
  165. end_procedure
  166.  
  167. //////////////////////////////////
  168. //////////////////////////////////  classes
  169. //////////////////////////////////
  170.  
  171. class data_file_client is a client
  172.     procedure construct_object integer img
  173.         forward send construct_object img
  174.  
  175.         property string  grp_file           public HELP_GRP_FILENAME
  176.         property string  sbj_file           public HELP_SBJ_FILENAME
  177.         property string  xrf_file           public HELP_XRF_FILENAME
  178.         property string  ctx_file           public HELP_CTX_FILENAME
  179.         property string  file_path          public EMPTY_STRING
  180.  
  181.         property string  original_grp_name  public EMPTY_STRING
  182.         property string  original_sbj_name  public EMPTY_STRING
  183.         property string  original_xrf_name  public EMPTY_STRING
  184.         property string  original_ctx_name  public EMPTY_STRING
  185.         property string  original_path_name public EMPTY_STRING
  186.  
  187.         property integer new_state          public 0
  188.         property integer open_state         public 0
  189.         property integer erase_state        public 0
  190.         property integer import_state       public 0
  191.     end_procedure
  192.  
  193.     function help_name returns string
  194.         local string help_str
  195.  
  196.         forward get help_name to help_str
  197.         if (new_state(current_object)) function_return (help_str + ".NEW")
  198.         if (open_state(current_object)) function_return (help_str + ".OPEN")
  199.         if (erase_state(current_object)) function_return (help_str + ".ERASE")
  200.         if (import_state(current_object)) function_return (help_str + ".IMPORT")
  201.     end_function
  202. end_class
  203.  
  204. //////////////////////////////////
  205. //////////////////////////////////  main object definitions
  206. //////////////////////////////////
  207.  
  208. if cmd_option eq IMP_MAINT_OPTION begin
  209.     class display_window is an edit
  210.         register_function initial_highlight_color returns integer
  211.  
  212.         procedure construct_object
  213.             forward send construct_object
  214.  
  215.             property integer highlight_color public (initial_highlight_color(current_object))
  216.             property integer normal_colors   public (object_color(current_object))
  217.         end_procedure
  218.  
  219.         function initial_highlight_color returns integer
  220.             local integer obj chk_obj pal ret_val
  221.  
  222.             move current_object to obj
  223.  
  224.             repeat
  225.             move obj to chk_obj
  226.             get class_palette (class(chk_obj)) to pal
  227.             if pal eq 0 get parent of chk_obj to obj
  228.             until (pal <> 0 or chk_obj = desktop)
  229.  
  230.             get palette_color pal POINTED_CURSOR_TYPE to ret_val
  231.             function_return ret_val
  232.         end_function
  233.  
  234.         procedure entering returns integer
  235.             local integer ret_val
  236.  
  237.             forward get msg_entering to ret_val
  238.  
  239.             if not ret_val set object_color to ;
  240.                 (highlight_color(current_object)) (low(normal_colors(current_object)))
  241.         end_procedure
  242.  
  243.         procedure exiting integer obj returns integer
  244.             local integer ret_val clrs
  245.  
  246.             forward get msg_exiting obj to ret_val
  247.  
  248.             if not ret_val begin
  249.                 get normal_colors to clrs
  250.                 set object_color to (hi(clrs)) (low(clrs))
  251.             end
  252.         end_procedure
  253.  
  254.         procedure release_focus
  255.             local integer ret_val clrs
  256.  
  257.             forward send release_focus
  258.  
  259.             get normal_colors to clrs
  260.             set object_color to (hi(clrs)) (low(clrs))
  261.         end_procedure
  262.  
  263.         set class_colors to u_!$ 0 0 // set colors for current class to inherit
  264.     end_class
  265.     
  266.     class auto_reset_checkbox is a checkbox
  267.         procedure select_toggling integer itm integer flag
  268.             forward send select_toggling itm flag
  269.             delegate send reset_mode
  270.         end_procedure
  271.     end_class
  272.  
  273. /import_data_img
  274. ╔════════════════════════════════════════════════════════════════╗
  275. ║________________________________________________________________║
  276. ║                                                                ║
  277. ║     ___________________     ______________________________     ║
  278. ║     ___________________     ______________________________     ║
  279. ║                                                                ║
  280. ║ ┌─ Import data matching: ────────────────────────────────────┐ ║
  281. ║ │                                                            │ ║
  282. ║ │       Group name: _________________________________        │ ║
  283. ║ │                                                            │ ║
  284. ║ │     Subject name: _________________________________        │ ║
  285. ║ │                                                            │ ║
  286. ║ │ Application name: ________________________________________ │ ║
  287. ║ │      Module name: _______________                          │ ║
  288. ║ │        Help name: _______________                          │ ║
  289. ║ │                                                            │ ║
  290. ║ └────────────────────────────────────────────────────────────┘ ║
  291. ║    __________     _____________________     _______________    ║
  292. ║         __________        ___________        _________         ║
  293. ╚════════════════════════════════════════════════════════════════╝
  294. /*
  295. //    ( ) Import matching      ( ) Import topics and contexts
  296. //    ( ) Import all           ( ) Import topics only
  297. //
  298. //   <F2=Begin>     <Alt+F2=Display only>     <F4=Import One>
  299. //        <F5=Clear>        <Esc=Close>        <F1=Help>
  300. //
  301. sub_page import_data_match_img     from import_data_img 2 4
  302. sub_page import_data_xrf_ctx_img   from import_data_img 3 5
  303. sub_page import_data_xrf_match_img from import_data_img 6 7
  304. sub_page import_data_ctx_match_img from import_data_img 8 9 10
  305. sub_page import_data_btns_img      from import_data_img 11 12 13 14 15 16
  306.  
  307.     object import_data is a client import_data_img
  308.         set location    to 2 7 relative
  309.         set popup_state to true
  310.  
  311.         integer last_xrf
  312.         move 0 to last_xrf
  313.  
  314.         object sbj_list is an array
  315.         end_object
  316.         object alt_sbj_list is a set
  317.         end_object
  318.  
  319.         set center_state item 0 to true
  320.         set value item 0 to "Import data"
  321.  
  322.         object match_type is an auto_reset_checkbox import_data_match_img
  323.             set select_mode to auto_select
  324.  
  325.             item_list
  326.                 on_item "Import matching" send next
  327.                     set select_state to true
  328.                 on_item "Import all"      send next
  329.             end_item_list
  330.  
  331.             on_key kcancel        send request_cancel  private
  332.             on_key kclear         send request_clear   private
  333.             on_key key_alt+key_f2 send display_only    private
  334.             on_key kprompt        send import_one      private
  335.             on_key ksave_record   send request_begin   private
  336.         end_object
  337.  
  338.         object xrfs_and_ctxs is an auto_reset_checkbox import_data_xrf_ctx_img
  339.             set select_mode to auto_select
  340.  
  341.             item_list
  342.                 on_item "Import topics and contexts" send next
  343.                     set select_state to true
  344.                 on_item "Import topics only"         send next
  345.             end_item_list
  346.  
  347.             on_key kcancel        send request_cancel  private
  348.             on_key kprompt        send import_one      private
  349.             on_key key_alt+key_f2 send display_only    private
  350.             on_key kclear         send request_clear   private
  351.             on_key ksave_record   send request_begin   private
  352.         end_object
  353.  
  354.         object xrf_match is a form import_data_xrf_match_img
  355.             item_list
  356.                 on_item EMPTY_STRING send next
  357.                 on_item EMPTY_STRING send next
  358.             end_item_list
  359.  
  360.             on_key kenter         send next            private
  361.             on_key kcancel        send request_cancel  private
  362.             on_key kprompt        send import_one      private
  363.             on_key key_alt+key_f2 send display_only    private
  364.             on_key kclear         send request_clear   private
  365.             on_key ksave_record   send request_begin   private
  366.         end_object
  367.  
  368.         object ctx_match is a form import_data_ctx_match_img
  369.             item_list
  370.                 on_item EMPTY_STRING send next // app_name
  371.                 on_item EMPTY_STRING send next // mod_name
  372.                 on_item EMPTY_STRING send next // hlp_name
  373.             end_item_list
  374.  
  375.             on_key kenter         send next            private
  376.             on_key kcancel        send request_cancel  private
  377.             on_key kprompt        send import_one      private
  378.             on_key key_alt+key_f2 send display_only    private
  379.             on_key kclear         send request_clear   private
  380.             on_key ksave_record   send request_begin   private
  381.         end_object
  382.  
  383.         object buttons is a button import_data_btns_img
  384.             item_list
  385.                 on_item "<F2=Begin>"            send request_begin
  386.                 on_item "<Alt+F2=Display only>" send display_only
  387.                 on_item "<F4=Import one>"       send import_one
  388.                 on_item "<F5=Clear>"            send request_clear
  389.                 on_item "<Esc=Close>"           send request_cancel
  390.                 on_item F1_HELP_TEXT            send help
  391.             end_item_list
  392.  
  393.             on_key kcancel        send request_cancel  private
  394.             on_key kprompt        send import_one      private
  395.             on_key key_alt+key_f2 send display_only    private
  396.             on_key kclear         send request_clear   private
  397.             on_key ksave_record   send request_begin   private
  398.         end_object
  399.  
  400. /import_process_img
  401. ╔══════════════════════════════════════════════════╗
  402. ║                                                  ║
  403. ║  ┌ Scanning: ───────┐      ┌─ Importing: ─────┐  ║
  404. ║  │                  │      │                  │  ║
  405. ║  │   Groups: ______ │      │                  │  ║
  406. ║  │ Subjects: ______ │      │   Topics: ______ │  ║
  407. ║  │    Links: ______ │      │ Contexts: ______ │  ║
  408. ║  │ Contexts: ______ │      │                  │  ║
  409. ║  │                  │      │                  │  ║
  410. ║  └──────────────────┘      └──────────────────┘  ║
  411. ║                                                  ║
  412. ║                   ____________                   ║
  413. ║                                                  ║
  414. ╚══════════════════════════════════════════════════╝
  415. /*
  416. //                  <Esc=Cancel>
  417.  
  418. sub_page import_process_cancel_btn_img from import_process_img 7
  419.  
  420.         object process is a client import_process_img
  421.             set popup_state to true
  422.             set location    to 5 7 relative
  423.  
  424.             object button is a button import_process_cancel_btn_img
  425.                 item_list
  426.                     on_item ESC_CANCEL_TEXT send none
  427.                 end_item_list
  428.  
  429. /import_interrupt_img
  430. ╔═══════════════════════════════════════════════════════╗
  431. ║                  Import interrupted.                  ║
  432. ║                                                       ║
  433. ║             _____________     ___________             ║
  434. ╚═══════════════════════════════════════════════════════╝
  435. /*
  436.  
  437.                 object interrupt is a button import_interrupt_img
  438.                     set block_mouse_state to true
  439.                     set location          to 9 -2 relative
  440.                     set popup_state       to true
  441.                     set scope_state       to true
  442.  
  443.                     item_list
  444.                         on_item "<F2=Continue>" send ok
  445.                         on_item "<Esc=Abort>"   send cancel
  446.                     end_item_list
  447.  
  448.                     on_key ksave_record send ok
  449.                     on_key kcancel      send cancel
  450.                 end_object
  451.  
  452.                 function check_interrupt returns integer
  453.                     local string trash
  454.                     local integer wloc mloc ret_val
  455.  
  456.                     inkey trash
  457.  
  458.                     if (termchar eq kexit_application or ;
  459.                         termchar eq kcancel or ;
  460.                         termchar eq kmouse) begin
  461.  
  462.                         if (termchar eq kmouse) begin
  463.                             get window_location item 1 to wloc
  464.                             move (wloc + location(current_object)) to wloc
  465.                             get absolute_mouse_location to mloc
  466.                             if not (mloc >= wloc and mloc < (wloc + length(value(current_object,0)))) ;
  467.                                 function_return 0
  468.                         end
  469.  
  470.                         set kbd_input_mode to 1
  471.                         set highlight_state to false
  472.                         ui_accept (interrupt(current_object)) to ret_val
  473.                         if ret_val ne msg_ok function_return 1
  474.                         set highlight_state to true
  475.                         set kbd_input_mode to 2
  476.                     end
  477.  
  478.                     function_return 0
  479.                 end_function
  480.             end_object
  481.  
  482.             function scan integer itm returns integer
  483.                 local integer ret_val
  484.  
  485.                 set value item itm to (value(current_object,itm) + 1)
  486.                 get check_interrupt of (button(current_object)) to ret_val
  487.                 function_return ret_val
  488.             end_function
  489.         end_object
  490.  
  491. /import_display_list_img
  492. ╔═══════════════════════════════════════════╗
  493. ║___________________________________________║
  494. ║                                           ║
  495. ║                                           ║
  496. ║                                           ║
  497. ║                                           ║
  498. ║                                           ║
  499. ║                                           ║
  500. ║                                           ║
  501. ║                                           ║
  502. ║                                           ║
  503. ║                                           ║
  504. ╚═══════════════════════════════════════════╝
  505. /import_display_list_btn_img
  506.          _______         _________        
  507. /*
  508. //       <F2=OK>         <F1=Help>
  509.  
  510.         object display_list is a client import_display_list_img
  511.             integer last_displayed_xrf
  512.             move 0 to last_displayed_xrf
  513.  
  514.             set block_mouse_state   to true
  515.             set center_state item 0 to true
  516.             set location            to 0 10 relative
  517.             set popup_state         to true
  518.             set scope_state         to true
  519.             set value        item 0 to "Topics and Contexts to be imported"
  520.  
  521.             object button is a button import_display_list_btn_img
  522.                 set location to 11 1 relative
  523.  
  524.                 item_list
  525.                     on_item F2_OK_TEXT   send request_ok
  526.                     on_item F1_HELP_TEXT send help
  527.                 end_item_list
  528.  
  529.                 on_key ksave_record send request_ok private
  530.             end_object
  531.  
  532. // button before list places focus on button during default activate of client
  533.  
  534.             object list is a display_window
  535.                 set size            to 8 42
  536.                 set location        to 3 1 relative
  537.                 set read_only_state to true
  538.  
  539.                 on_key ksave_record send request_ok private
  540.             end_object
  541.  
  542.             procedure request_ok
  543.                 send deactivate_area
  544.                 send delete_data to (list(current_object))
  545.                 delegate send restart
  546.             end_procedure
  547.  
  548.             procedure delete_data
  549.                 send delete_data to (list(current_object))
  550.             end_procedure
  551.  
  552.             procedure insert_line string txt
  553.                 local string newline
  554.                 local integer obj
  555.  
  556.                 move (list(current_object)) to obj
  557.                 set read_only_state of obj to false
  558.                 send insert to obj txt
  559.                 send process_key to obj kenter
  560.                 set read_only_state of obj to true
  561.             end_procedure
  562.  
  563.             procedure show_xrf
  564.                 send insert_line "TOPIC:"
  565.                 send insert_line (trim(grp2.grp_name))
  566.                 send insert_line (trim(sbj2.sbj_name))
  567.             end_procedure
  568.  
  569.             procedure show_ctx
  570.                 send insert_line "CONTEXT:"
  571.                 send insert_line (trim(ctx2.app_name))
  572.                 send insert_line (trim(ctx2.mod_name))
  573.                 send insert_line (trim(ctx2.hlp_name))
  574.             end_procedure
  575.         end_object
  576.  
  577. /import_done_img
  578. ╔═══════════════════════════════════════════════════════╗
  579. ║                    Import complete.                   ║
  580. ║                                                       ║
  581. ║                     ____    ______                    ║
  582. ╚═══════════════════════════════════════════════════════╝
  583. /*
  584.  
  585.         object done is a button import_done_img
  586.             set block_mouse_state to true
  587.             set location          to 13 4 relative
  588.             set popup_state       to true
  589.             set scope_state       to true
  590.  
  591.             item_list
  592.                 on_item "<OK>"   send request_display_ok
  593.                 on_item "<Help>" send help
  594.             end_item_list
  595.         end_object
  596.  
  597. /import_one_img
  598. ╔═══════════════════════════════════════════════════════╗
  599. ║_______________________________________________________║
  600. ║                                                       ║
  601. ║           _________________________________           ║
  602. ║           _________________________________           ║
  603. ║           _________________________________           ║
  604. ║           _________________________________           ║
  605. ║           _________________________________           ║
  606. ║           _________________________________           ║
  607. ║           _________________________________           ║
  608. ║           _________________________________           ║
  609. ║           _________________________________           ║
  610. ║                                                       ║
  611. ║              ____________      _________              ║
  612. ╚═══════════════════════════════════════════════════════╝
  613. /*
  614. //             <Esc=Cancel>      <F1=Help>
  615.  
  616. sub_page import_one_list_img from import_one_img vertical 2 9
  617. sub_page import_one_keys_img from import_one_img 11 12
  618.  
  619.         object import_one is a client import_one_img
  620.             integer import_action_msg
  621.  
  622.             set block_mouse_state   to true
  623.             set location            to 3 4 relative
  624.             set popup_state         to true
  625.             set scope_state         to true
  626.  
  627.             set center_state item 0 to true
  628.  
  629.             object grp_set is a data_set no_image main_file grp2
  630.                 set focus_mode to no_activate
  631.  
  632.                 object xrf_set is a data_set no_image main_file xrf2
  633.                     set focus_mode to no_activate
  634.                 end_object
  635.             end_object
  636.  
  637.             object list is a selection_list import_one_list_img
  638.                 set local_rotate_state to false
  639.                 set ordering           to index.1
  640.  
  641.                 begin_row
  642.                     entry_item grp2.grp_name
  643.                 end_row
  644.  
  645.                 on_key kcancel send request_cancel private
  646.                 on_key kenter  send choose_topic   private
  647.             end_object
  648.  
  649.             object keys is a key_button import_one_keys_img
  650.                 item_list
  651.                     on_item ESC_CANCEL_TEXT send request_cancel
  652.                     on_item F1_HELP_TEXT    send help
  653.                 end_item_list
  654.             end_object
  655.  
  656.             procedure accept_list integer msg
  657.                 move msg to import_action_msg
  658.                 send popup
  659.             end_procedure
  660.  
  661.             procedure choose_topic
  662.                 local integer obj rec_id
  663.  
  664.                 get prior_level to obj
  665.                 get current_record of (list(current_object)) to rec_id
  666.                 send deactivate
  667.                 send import_action_msg to obj rec_id
  668.             end_procedure
  669.  
  670.             procedure delete_data
  671.                 send delete_data to (list(current_object))
  672.             end_procedure
  673.  
  674.             procedure pick_group integer msg
  675.                 local integer itm lst
  676.  
  677.                 clear grp2
  678.                 find ge grp2.grp_name
  679.  
  680.                 [ found ] begin
  681.                     move (list(current_object)) to lst
  682.                     set main_file of lst to grp2.file_number
  683.                     set server of lst to (grp_set(current_object))
  684.                     set data_file of (element(lst)) item 0 to grp2.file_number
  685.                     send prepare_list "Import Topic from Group" grp2.file_number ;
  686.                     (grp_set(current_object)) grp2.file_number
  687.                     send accept_list msg
  688.                 end
  689.             end_procedure
  690.  
  691.             procedure pick_subject integer grp_num string ttl integer msg
  692.                 local integer itm lst
  693.  
  694.                 clear xrf2
  695.                 move grp_num to xrf2.grp_recnum
  696.                 find ge xrf2.grp_recnum
  697.                 [ found ] indicate found as xrf2.grp_recnum eq grp_num
  698.  
  699.                 [ found ] begin
  700.                     send prepare_list ("Subjects for Group " + ttl) xrf2.file_number ;
  701.                     (xrf_set(grp_set(current_object))) sbj2.file_number
  702.                     send accept_list msg
  703.                 end
  704.             end_procedure
  705.  
  706.             procedure prepare_list string ttl integer mfil integer svr integer ffil
  707.                 local integer lst
  708.  
  709.                 set value item 0 to ttl
  710.                 move (list(current_object)) to lst
  711.                 set main_file of lst to mfil
  712.                 set server of lst to svr
  713.                 set data_file of (element(lst)) item 0 to ffil
  714.                 send rebuild_constraints to svr
  715.                 send delete_data
  716.             end_procedure
  717.  
  718.             procedure request_cancel
  719.                 send deactivate_area
  720.             end_procedure
  721.         end_object
  722.  
  723.         object sbj_text is an edit
  724.             set focus_mode to no_activate
  725.             set size to 1 56
  726.         end_object
  727.  
  728.         function match_only returns integer
  729.             local integer ret_val
  730.  
  731.             get select_state of (match_type(current_object)) item 0 to ret_val
  732.             function_return ret_val
  733.         end_function
  734.  
  735.         function include_ctx returns integer
  736.             local integer ret_val
  737.  
  738.             get select_state of (xrfs_and_ctxs(current_object)) item 0 to ret_val
  739.             function_return ret_val
  740.         end_function
  741.  
  742.         procedure reset_mode
  743.             local integer mobj cobj flag1 flag2 itm
  744.  
  745.             move (xrf_match(current_object)) to mobj
  746.             move (ctx_match(current_object)) to cobj
  747.  
  748.             get match_only to flag1
  749.             move (not(flag1)) to flag1
  750.             set shadow_state of mobj item 0 to flag1
  751.             set shadow_state of mobj item 1 to flag1
  752.  
  753.             get include_ctx to flag2
  754.             if flag1 move 0 to flag2 // don't edit ctx names if not match type
  755.             move (not(flag2)) to flag2
  756.             set shadow_state of cobj item 0 to flag2
  757.             set shadow_state of cobj item 1 to flag2
  758.             set shadow_state of cobj item 2 to flag2
  759.         end_procedure
  760.  
  761.         function no_wildcard string val returns string
  762.             local integer ps
  763.  
  764.             pos "?" in val to ps
  765.             if ps eq 0 pos "*" in val to ps
  766.             if ps function_return (left(val,ps-1))
  767.             else function_return val
  768.         end_function
  769.  
  770.         procedure restart
  771.             set kbd_input_mode to 1
  772.             send deactivate to (process(current_object))
  773.             send deactivate to (display_list(current_object))
  774.             send activate to (match_type(current_object))
  775.         end_procedure
  776.  
  777.         procedure request_clear
  778.             set current_item of (match_type(current_object)) to 0
  779.             set current_item of (xrfs_and_ctxs(current_object)) to 0
  780.             send delete_data to (xrf_match(current_object))
  781.             send delete_data to (ctx_match(current_object))
  782.             send activate to (match_type(current_object))
  783.         end_procedure
  784.  
  785.         procedure init_process integer live
  786.             local integer obj
  787.  
  788.             if not live begin
  789.                 move 0 to last_xrf
  790.                 set max_lines of (list(display_list(current_object))) to MAX_LINES_ALLOWED
  791.                 send delete_data to (display_list(current_object))
  792.                 send popup to (display_list(current_object))
  793.             end
  794.  
  795.             move (process(current_object)) to obj
  796.             send delete_data to obj
  797.             send popup to obj
  798.             set highlight_state of (button(obj)) to true
  799.             set kbd_input_mode to 2
  800.         end_procedure
  801.  
  802.         procedure process_complete integer live
  803.             set kbd_input_mode to 1
  804.             set highlight_state of (button(process(current_object))) to false
  805.  
  806.             if live send popup to (done(current_object))
  807.             else begin
  808.                 set max_lines of (list(display_list(current_object))) to (line_count(list(display_list(current_object))) + 1)
  809.                 send deactivate to (process(current_object))
  810.             end
  811.         end_procedure
  812.  
  813.         procedure request_begin
  814.             send request_import true
  815.         end_procedure
  816.  
  817.         procedure display_only
  818.             send request_import false
  819.         end_procedure
  820.  
  821.         procedure request_display_ok
  822.             send deactivate_area to (done(current_object))
  823.             send restart
  824.         end_procedure
  825.  
  826.         procedure request_import integer live
  827.             local integer grp_typ sbj_typ app_typ mod_typ hlp_typ
  828.             local integer incl_ctx obj ret_val
  829.             local string grp_test sbj_test app_test mod_test hlp_test
  830.  
  831.             send init_process live
  832.  
  833.             if not (match_only(current_object)) begin
  834.                 send delete_data to (xrf_match(current_object))
  835.                 send delete_data to (ctx_match(current_object))
  836.             end
  837.  
  838.             move 0 to grp_typ
  839.             move 0 to sbj_typ
  840.             move 0 to app_typ
  841.             move 0 to mod_typ
  842.             move 0 to hlp_typ
  843.  
  844.             move (xrf_match(current_object)) to obj
  845.             get value of obj item 0 to grp_test
  846.             get value of obj item 1 to sbj_test
  847.             if grp_test gt EMPTY_STRING move 1 to grp_typ
  848.             if sbj_test gt EMPTY_STRING move 1 to sbj_typ
  849.  
  850.             get include_ctx to incl_ctx
  851.             if incl_ctx begin
  852.                 move (ctx_match(current_object)) to obj
  853.                 uppercase (value(obj,0)) to app_test
  854.                 uppercase (value(obj,1)) to mod_test
  855.                 uppercase (value(obj,2)) to hlp_test
  856.                 if app_test gt EMPTY_STRING move 1 to app_typ
  857.                 if mod_test gt EMPTY_STRING move 1 to mod_typ
  858.                 if hlp_test gt EMPTY_STRING move 1 to hlp_typ
  859.             end
  860.  
  861. // search files based on match criteria:
  862. // loop through grps that match,
  863. //   loop through xrfs that match (test sbj for match),
  864. //     loop through ctxs that match.
  865.  
  866.             clear grp2
  867.             get no_wildcard grp_test to grp2.grp_name
  868.             find ge grp2.grp_name
  869.             [found] repeat
  870.                 if (scan(current_object,GRP_SCAN_TYPE)) begin
  871.                     send restart
  872.                     procedure_return
  873.                 end
  874.  
  875.                 indicate found as grp_typ
  876.                 [found] indicate found as grp_test match (trim(grp2.grp_name))
  877.                 [not found] indicate found as (not(grp_typ))
  878.  
  879.                 [found] begin
  880.                     clear xrf2
  881.                     move grp2.recnum to xrf2.grp_recnum
  882.                     find ge xrf2.grp_recnum
  883.                     [found] indicate found as xrf2.grp_recnum eq grp2.recnum
  884.                     [found] repeat
  885.                         if (scan(current_object,XRF_SCAN_TYPE)) begin
  886.                             send restart
  887.                             procedure_return
  888.                         end
  889.  
  890.                         clear sbj2
  891.                         move xrf2.sbj_recnum to sbj2.recnum
  892.                         find eq sbj2.recnum
  893.  
  894.                         if (scan(current_object,SBJ_SCAN_TYPE)) begin
  895.                             send restart
  896.                             procedure_return
  897.                         end
  898.  
  899.                         [found] if sbj_typ indicate found as ;
  900.                             sbj_test match (trim(sbj2.sbj_name))
  901.                         [found] begin
  902.                             if incl_ctx begin
  903.                                 clear ctx2
  904.                                 move xrf2.recnum to ctx2.xrf_recnum
  905.                                 find ge ctx2.xrf_recnum
  906.                                 [found] indicate found as ;
  907.                                     ctx2.xrf_recnum eq xrf2.recnum
  908.                                 if [found] begin
  909.                                     [found] repeat
  910.                                         if (scan(current_object,CTX_SCAN_TYPE)) begin
  911.                                             send restart
  912.                                             procedure_return
  913.                                         end
  914.  
  915.                                         if app_typ indicate found as ;
  916.                                             app_test match (trim(uppercase(ctx2.app_name)))
  917.                                         [found] if mod_typ indicate found as ;
  918.                                             mod_test match (trim(uppercase(ctx2.mod_name)))
  919.                                         [found] if hlp_typ indicate found as ;
  920.                                             hlp_test match (trim(uppercase(ctx2.hlp_name)))
  921.  
  922.                                         [found] begin
  923.                                             if live get import_records true to ret_val
  924.                                             else get show_import_ctx to ret_val
  925.                                                 // match!
  926.                                             if ret_val begin
  927.                                                 send restart
  928.                                                 procedure_return
  929.                                             end
  930.                                         end
  931.  
  932.                                         find gt ctx2.xrf_recnum
  933.                                         [found] indicate found as ;
  934.                                             ctx2.xrf_recnum eq xrf2.recnum
  935.                                     [found] loop
  936.                                 end
  937.                                 else begin
  938.                                     if (not(app_typ) and not(mod_typ) and not(hlp_typ)) begin
  939.                                         if live get import_records false to ret_val
  940.                                         else get show_import_xrf to ret_val
  941.                                             // fnd ctx diff xrf
  942.                                         if ret_val begin
  943.                                             send restart
  944.                                             procedure_return
  945.                                         end
  946.                                     end
  947.                                 end
  948.                             end
  949.                             else begin
  950.                                 if live get import_records false to ret_val
  951.                                 else get show_import_xrf to ret_val
  952.                                     // skip ctx's
  953.                                 if ret_val begin
  954.                                     send restart
  955.                                     procedure_return
  956.                                 end
  957.                             end
  958.                         end
  959.                         find gt xrf2.grp_recnum
  960.                         [found] indicate found as xrf2.grp_recnum eq grp2.recnum
  961.                     [found] loop
  962.                 end
  963.  
  964.                 find gt grp2.grp_name
  965.                 [found] if grp_typ indicate found as (no_wildcard(current_object,grp_test) + "*") match grp2.grp_name
  966.             [found] loop
  967.  
  968.             send process_complete live
  969.         end_procedure
  970.  
  971.         function scan integer itm returns integer
  972.             function_return (scan(process(current_object),itm))
  973.         end_function
  974.  
  975.         function show_import_ctx returns integer
  976.             local integer ret_val
  977.  
  978.             if xrf2.recnum ne last_xrf get show_import_xrf to ret_val
  979.             else move 0 to ret_val
  980.  
  981.             if ret_val function_return ret_val
  982.  
  983.             move xrf2.recnum to last_xrf
  984.  
  985.             clear ctx
  986.             move ctx2.app_name to ctx.app_name
  987.             move ctx2.mod_name to ctx.mod_name
  988.             move ctx2.hlp_name to ctx.hlp_name
  989.             find eq ctx.hlp_name
  990.  
  991.             [not found] begin
  992.                 send show_ctx to (display_list(current_object))
  993.                 function_return (scan(current_object,CTX_SAVE_TYPE))
  994.             end
  995.         end_function
  996.  
  997.         function show_import_xrf returns integer
  998.             clear xrf
  999.             move grp.recnum to xrf.grp_recnum
  1000.             move sbj.recnum to xrf.sbj_recnum
  1001.             find eq xrf.grp_recnum
  1002.  
  1003.             [not found] begin
  1004.                 send show_xrf to (display_list(current_object))
  1005.                 function_return (scan(current_object,XRF_SAVE_TYPE))
  1006.             end
  1007.         end_function
  1008.  
  1009.         function import_records integer do_ctx returns integer
  1010.             local integer itm obj alt_obj rec old_xrf_state old_ctx_state
  1011.  
  1012.             LOCK
  1013.  
  1014.                 if grp.grp_name ne grp2.grp_name begin
  1015.                     clear grp
  1016.                     move grp2.grp_name to grp.grp_name
  1017.                     find eq grp.grp_name
  1018.                     [not found] begin
  1019.                         clear grp
  1020.                         move grp2.grp_name to grp.grp_name
  1021.                         saverecord grp
  1022.                     end
  1023.                 end
  1024.  
  1025.                 move (sbj_list(current_object)) to obj
  1026.                 move (alt_sbj_list(current_object)) to alt_obj
  1027.  
  1028.                 get find_element of alt_obj sbj2.recnum to itm
  1029.  
  1030.                 if itm eq -1 begin
  1031.                     clear sbj
  1032.                     move sbj2.sbj_name to sbj.sbj_name
  1033.                     send delete_data to (sbj_text(current_object))
  1034.                     send read_dbms to (sbj_text(current_object)) sbj2.sbj_text
  1035.                     send write_dbms to (sbj_text(current_object)) sbj.sbj_text
  1036.                     saverecord sbj
  1037.  
  1038.                     send add_element to alt_obj sbj2.recnum
  1039.                     get find_element of alt_obj sbj2.recnum to itm
  1040.                     set array_value of obj item itm to sbj.recnum
  1041.                 end
  1042.                 else begin
  1043.                     get value of obj item itm to rec
  1044.                     if sbj.recnum ne rec begin
  1045.                         clear sbj
  1046.                         move rec to sbj.recnum
  1047.                         find eq sbj.recnum
  1048.                     end
  1049.                 end
  1050.  
  1051.                 clear xrf
  1052.                 move grp.recnum to xrf.grp_recnum
  1053.                 move sbj.recnum to xrf.sbj_recnum
  1054.                 find eq xrf.grp_recnum
  1055.  
  1056.                 move 0 to old_xrf_state
  1057.                 [found] move 1 to old_xrf_state
  1058.  
  1059.                 [not found] begin
  1060.                     clear xrf
  1061.                     move grp.recnum to xrf.grp_recnum
  1062.                     move sbj.recnum to xrf.sbj_recnum
  1063.                     saverecord xrf
  1064.                 end
  1065.  
  1066.                 if do_ctx begin
  1067.                     clear ctx
  1068.                     move ctx2.app_name to ctx.app_name
  1069.                     move ctx2.mod_name to ctx.mod_name
  1070.                     move ctx2.hlp_name to ctx.hlp_name
  1071.                     find eq ctx.hlp_name
  1072.  
  1073.                     move 0 to old_ctx_state
  1074.                     [found] move 1 to old_ctx_state
  1075.  
  1076.                     [not found] begin
  1077.                         clear ctx
  1078.                         move ctx2.app_name to ctx.app_name
  1079.                         move ctx2.mod_name to ctx.mod_name
  1080.                         move ctx2.hlp_name to ctx.hlp_name
  1081.                         move xrf.recnum to ctx.xrf_recnum
  1082.                         saverecord ctx
  1083.                     end
  1084.                 end
  1085.  
  1086.             UNLOCK
  1087.  
  1088.             if not old_xrf_state if (scan(current_object,XRF_SAVE_TYPE)) function_return 1
  1089.             if (do_ctx and not(old_ctx_state)) if (scan(current_object,CTX_SAVE_TYPE)) function_return 1
  1090.  
  1091.             function_return 0
  1092.         end_function
  1093.  
  1094.         procedure request_cancel
  1095.             send deactivate_area
  1096.             send insert_cb SUCCESS_REPLY 0
  1097.         end_procedure
  1098.  
  1099.         procedure import_topic integer xrf_num
  1100.             local integer ret_val
  1101.  
  1102.             send init_process true
  1103.  
  1104.             if (scan(current_object,GRP_SCAN_TYPE)) begin
  1105.                 send restart
  1106.                 procedure_return
  1107.             end
  1108.             if (scan(current_object,SBJ_SCAN_TYPE)) begin
  1109.                 send restart
  1110.                 procedure_return
  1111.             end
  1112.             if (scan(current_object,XRF_SCAN_TYPE)) begin
  1113.                 send restart
  1114.                 procedure_return
  1115.             end
  1116.  
  1117.             clear xrf2
  1118.             move xrf_num to xrf2.recnum
  1119.             find eq xrf2.recnum
  1120.  
  1121.             if [found] begin
  1122.                 clear grp2
  1123.                 move xrf2.grp_recnum to grp2.recnum
  1124.                 find eq grp2.recnum
  1125.                 clear sbj2
  1126.                 move xrf2.sbj_recnum to sbj2.recnum
  1127.                 find eq sbj2.recnum
  1128.  
  1129.                 if (include_ctx(current_object)) begin
  1130.                     clear ctx2
  1131.                     move xrf2.recnum to ctx2.xrf_recnum
  1132.                     find ge ctx2.xrf_recnum
  1133.                     [found] indicate found as ;
  1134.                         ctx2.xrf_recnum eq xrf2.recnum
  1135.                     if [found] begin
  1136.                         [found] repeat
  1137.                             if (scan(current_object,CTX_SCAN_TYPE)) begin
  1138.                                 send restart
  1139.                                 procedure_return
  1140.                             end
  1141.  
  1142.                             [found] begin
  1143.                                 get import_records true to ret_val // match!
  1144.  
  1145.                                 if ret_val begin
  1146.                                     send restart
  1147.                                     procedure_return
  1148.                                 end
  1149.                             end
  1150.  
  1151.                             find gt ctx2.xrf_recnum
  1152.                             [found] indicate found as ;
  1153.                                 ctx2.xrf_recnum eq xrf2.recnum
  1154.                         [found] loop
  1155.                     end
  1156.                     else begin
  1157.                         get import_records false to ret_val // fnd ctx diff xrf
  1158.  
  1159.                         if ret_val begin
  1160.                             send restart
  1161.                             procedure_return
  1162.                         end
  1163.                     end
  1164.                 end
  1165.                 else begin
  1166.                     get import_records false to ret_val // skip ctx's
  1167.  
  1168.                     if ret_val begin
  1169.                         send restart
  1170.                         procedure_return
  1171.                     end
  1172.                 end
  1173.             end
  1174.  
  1175.             send process_complete true
  1176.         end_procedure
  1177.  
  1178.         procedure pick_topic_subject integer grp_num
  1179.             clear grp2
  1180.             move grp_num to grp2.recnum
  1181.             find eq grp2.recnum
  1182.             send pick_subject to (import_one(current_object)) grp_num (trim( grp2.grp_name )) ;
  1183.             msg_import_topic
  1184.         end_procedure
  1185.  
  1186.         procedure import_one
  1187.             send pick_group to (import_one(current_object)) msg_pick_topic_subject
  1188.         end_procedure
  1189.     end_object
  1190.  
  1191. end
  1192.  
  1193. if cmd_option in (PATH_OPTION + NEW_FILE_OPTION + OPEN_FILE_OPTION + ;
  1194.                 IMP_MAINT_OPTION + ERS_MAINT_OPTION) begin
  1195.  
  1196. /help_files_img
  1197. ╔════════════════════════════════════════════════╗
  1198. ║________________________________________________║
  1199. ║                                                ║
  1200. ║             Prefix:     _____                  ║
  1201. ║                                                ║
  1202. ║              Group: ___ ________               ║
  1203. ║            Subject: ___ ________               ║
  1204. ║               Link: ___ ________               ║
  1205. ║            Context: ___ ________               ║
  1206. ║                                                ║
  1207. ║     Path: _______________________________      ║
  1208. ║                                                ║
  1209. ║  _______  __________  ____________  _________  ║
  1210. ╚════════════════════════════════════════════════╝
  1211. /*
  1212. sub_page help_files_prefix_img from help_files_img 2
  1213. sub_page help_files_check_img from help_files_img vertical 3 4
  1214. sub_page help_files_file_img  from help_files_img vertical 4 4
  1215. sub_page help_files_path_img  from help_files_img 11
  1216. sub_page help_files_btns_img  from help_files_img 12 13 14 15
  1217.  
  1218.   object help_files is a data_file_client help_files_img
  1219.     set block_mouse_state to true
  1220.     set location          to 6 15 relative
  1221.     set popup_state       to true
  1222.     set scope_state       to true
  1223.  
  1224.     set center_state item 0 to true
  1225.     set value        item 0 to EMPTY_STRING
  1226.  
  1227.     object prefix is a form help_files_prefix_img
  1228.         string original_prefix_name
  1229.  
  1230.         set entry_msg to store_original_prefix
  1231.         set exit_msg to initialize_for_prefix
  1232.         
  1233.         item_list
  1234.             on_item EMPTY_STRING send next
  1235.             set autoclear_state to true
  1236.         end_item_list
  1237.  
  1238.         procedure store_original_prefix
  1239.             get value item 0 to original_prefix_name
  1240.         end_procedure
  1241.  
  1242.         procedure initialize_for_prefix
  1243.             local string prf
  1244.             
  1245.             get value item 0 to prf
  1246.  
  1247.             if (prf > EMPTY_STRING and prf <> original_prefix_name) begin
  1248.                 delegate set grp_name to (prf + "GRP")
  1249.                 delegate set sbj_name to (prf + "SBJ")
  1250.                 delegate set xrf_name to (prf + "XRF")
  1251.                 delegate set ctx_name to (prf + "CTX")
  1252.                 send store_original_prefix
  1253.             end
  1254.         end_procedure
  1255.  
  1256.         procedure shadow_prefix_option integer flag
  1257.             set shadow_state item 0 to flag // prefix item in form
  1258.  
  1259.             if not flag set focus_mode to focusable
  1260.             else set focus_mode to nonfocusable
  1261.         end_procedure
  1262.  
  1263.         function prefix_shadowed returns integer
  1264.             function_return (shadow_state(current_object,0)) // prefix item in form
  1265.         end_function
  1266.     end_object
  1267.  
  1268.     object erase_checks is a checkbox help_files_check_img
  1269.         set local_rotate_state to true
  1270.  
  1271.         item_list
  1272.             on_item EMPTY_STRING send next
  1273.             on_item EMPTY_STRING send next
  1274.             on_item EMPTY_STRING send next
  1275.             on_item EMPTY_STRING send next
  1276.         end_item_list
  1277.     end_object
  1278.  
  1279.     object file is a form help_files_file_img
  1280.         item_list
  1281.             repeat_item 4 times EMPTY_STRING send next
  1282.         end_item_list
  1283.     end_object
  1284.  
  1285.     object path is a form help_files_path_img
  1286.         item_list
  1287.             on_item EMPTY_STRING send next
  1288.             set autoclear_state to true
  1289.         end_item_list
  1290.     end_object
  1291.  
  1292.     object buttons is a button help_files_btns_img
  1293.         item_list
  1294.             on_item F2_OK_TEXT      send request_ok
  1295.             on_item "<F5=Clear>"    send clear
  1296.             on_item ESC_CANCEL_TEXT send request_cancel
  1297.             on_item F1_HELP_TEXT    send help
  1298.         end_item_list
  1299.     end_object
  1300.  
  1301. /creating_img
  1302. ╔════════════════════════════════════════════════╗
  1303. ║                                                ║
  1304. ║   Creating new help data files.  Please wait.  ║
  1305. ║                                                ║
  1306. ╚════════════════════════════════════════════════╝
  1307. /opening_img
  1308. ╔════════════════════════════════════════════════╗
  1309. ║                                                ║
  1310. ║     Opening help data files.  Please wait.     ║
  1311. ║                                                ║
  1312. ╚════════════════════════════════════════════════╝
  1313. /erasing_img
  1314. ╔════════════════════════════════════════════════╗
  1315. ║                                                ║
  1316. ║ Erasing data in help data files.  Please wait. ║
  1317. ║                                                ║
  1318. ╚════════════════════════════════════════════════╝
  1319. /*
  1320.  
  1321.     object creating is a message creating_img
  1322.         set location   to 4 0 relative
  1323.         set focus_mode to no_activate
  1324.     end_object
  1325.  
  1326.     object opening is a message opening_img
  1327.         set location   to 4 0 relative
  1328.         set focus_mode to no_activate
  1329.     end_object
  1330.  
  1331.     object erasing is a message erasing_img
  1332.         set location   to 4 0 relative
  1333.         set focus_mode to no_activate
  1334.     end_object
  1335.  
  1336.     on_key kcancel      send request_cancel
  1337.     on_key kclear       send clear
  1338.     on_key ksave_record send request_ok
  1339.  
  1340.     procedure use_checkboxes integer flag
  1341.         local integer count tot_items obj
  1342.  
  1343.         move (erase_checks(current_object)) to obj
  1344.  
  1345.         if flag set focus_mode of obj to focusable
  1346.         else set focus_mode of obj to nonfocusable
  1347.  
  1348.         move (item_count(obj) - 1) to tot_items
  1349.  
  1350.         for count from 0 to tot_items
  1351.             set checkbox_item_state of obj item count to flag
  1352.             set select_state of obj item count to flag
  1353.         loop
  1354.     end_procedure
  1355.  
  1356.     procedure init_files_and_path
  1357.         local string fname
  1358.  
  1359.         set grp_file to current_grp
  1360.         set sbj_file to current_sbj
  1361.         set xrf_file to current_xrf
  1362.         set ctx_file to current_ctx
  1363.         set file_path to current_pth
  1364.     end_procedure
  1365.  
  1366.     procedure new
  1367.         set value item 0 to "New files"
  1368.         send use_checkboxes false
  1369.         send clear
  1370.         set new_state to true
  1371.         send shadow_prefix_option false
  1372.         send focus_name_objects true
  1373.         send popup
  1374.     end_procedure
  1375.  
  1376.     procedure import
  1377.         set value item 0 to "Import from files"
  1378.         send use_checkboxes false
  1379.         send clear
  1380.         set import_state to true
  1381.         send shadow_prefix_option false
  1382.         send focus_name_objects true
  1383.         send popup
  1384.     end_procedure
  1385.  
  1386.     procedure pre_open
  1387.         set value item 0 to "Open files"
  1388.         send use_checkboxes false
  1389.         send load_file_names
  1390.         send load_path_name
  1391.         set open_state to true
  1392.         send shadow_prefix_option false
  1393.         send focus_name_objects true
  1394.     end_procedure
  1395.  
  1396.     procedure open
  1397.         send init_files_and_path
  1398.         if current_grp le EMPTY_STRING set grp_file to HELP_GRP_FILENAME
  1399.         if current_sbj le EMPTY_STRING set sbj_file to HELP_SBJ_FILENAME
  1400.         if current_xrf le EMPTY_STRING set xrf_file to HELP_XRF_FILENAME
  1401.         if current_ctx le EMPTY_STRING set ctx_file to HELP_CTX_FILENAME
  1402.         send pre_open
  1403.         send popup
  1404.     end_procedure
  1405.  
  1406.     procedure erase
  1407.         send init_files_and_path
  1408.         set value item 0 to "Erase data"
  1409.         send use_checkboxes true
  1410.         send load_file_names
  1411.         send load_path_name
  1412.         set erase_state to true
  1413.         send shadow_prefix_option true
  1414.         send focus_name_objects false
  1415.         send popup
  1416.     end_procedure
  1417.  
  1418.     procedure request_cancel
  1419.         send insert_cb FAIL_REPLY 0
  1420.         send deactivate_area
  1421.         send reset_states
  1422.     end_procedure
  1423.  
  1424.     procedure clear
  1425.         if (erase_state(current_object)) ;
  1426.                 set select_count of (erase_checks(current_object)) to 0
  1427.         else begin
  1428.             send delete_data to (prefix(current_object))
  1429.             send delete_data to (file(current_object))
  1430.             send delete_data to (path(current_object))
  1431.         end
  1432.  
  1433.         send activate // goto first focusable object in client
  1434.     end_procedure
  1435.     
  1436.     procedure shadow_prefix_option integer flag
  1437.         send shadow_prefix_option to (prefix(current_object)) flag
  1438.     end_procedure
  1439.  
  1440.     procedure focus_name_objects integer flag
  1441.         local integer mod itm obj f2
  1442.  
  1443.         if flag move focusable to mod
  1444.         else move nonfocusable to mod
  1445.  
  1446.         move (file(current_object)) to obj
  1447.         set focus_mode of obj mod
  1448.         move (not(flag)) to f2
  1449.  
  1450.         for itm from 0 to 3
  1451.             set shadow_state of obj item itm to f2
  1452.         loop
  1453.  
  1454.         move (path(current_object)) to obj
  1455.         set focus_mode of obj to mod
  1456.         set shadow_state of obj item 0 to f2
  1457.     end_procedure
  1458.  
  1459.     procedure insert_cb_file_specs
  1460.         local string curpth
  1461.  
  1462.         send insert_cb (grp_file(current_object)) 1
  1463.         send insert_cb (sbj_file(current_object)) 2
  1464.         send insert_cb (xrf_file(current_object)) 3
  1465.         send insert_cb (ctx_file(current_object)) 4
  1466.         trim (file_path(current_object)) to curpth
  1467.         if curpth le EMPTY_STRING move EMPTY_REPL_STRING to curpth
  1468.         send insert_cb curpth 5
  1469.     end_procedure
  1470.  
  1471.     procedure request_ok
  1472.         local integer ret_val
  1473.         local string pth
  1474.  
  1475.         if (erase_state(current_object)) begin
  1476.             if (select_count(erase_checks(current_object))) gt 0 begin
  1477.                 send page_object to (erasing(current_object)) true
  1478.                 get zero_files to ret_val
  1479.                 send page_object to (erasing(current_object)) false
  1480.  
  1481.                 if ret_val begin
  1482.                     send insert_cb SUCCESS_REPLY 0
  1483.                     send insert_cb_file_specs
  1484.                 end
  1485.                 else send insert_cb FAIL_REPLY 0
  1486.             end
  1487.             else send insert_cb FAIL_REPLY 0
  1488.  
  1489.             send deactivate_area
  1490.             send reset_states
  1491.             procedure_return
  1492.         end
  1493.  
  1494.         send initialize_for_prefix to (prefix(current_object))
  1495.  
  1496.         get path_name to pth
  1497.         if pth gt EMPTY_STRING if not (right(pth,1)) in ':\/' begin
  1498.             append pth '\'
  1499.             set path_name to pth
  1500.         end
  1501.  
  1502.         if (new_state(current_object)) ;
  1503.             send page_object to (creating(current_object)) true
  1504.         if (open_state(current_object) or import_state(current_object)) ;
  1505.             send page_object to (opening(current_object)) true
  1506.  
  1507.         if (import_state(current_object)) begin
  1508.             send push_original_names
  1509.             send close_alt_files
  1510.         end
  1511.         else send close_files
  1512.  
  1513.         if (new_state(current_object)) begin
  1514.         get check_file_specs pth to ret_val
  1515.             if not ret_val begin
  1516.                 send page_object to (creating(current_object)) false
  1517.                     error 32 "New files cannot be created"
  1518.             end
  1519.         end
  1520.         else move 1 to ret_val
  1521.  
  1522.         if ret_val begin
  1523.             send reset_names
  1524.             move (open_state(current_object) or import_state(current_object)) to ret_val
  1525.  
  1526.             if (new_state(current_object)) begin
  1527.                 get make_files pth to ret_val
  1528.                 if ret_val send delete_defs_and_fds pth
  1529.                 send page_object to (creating(current_object)) false
  1530.                 if ret_val send page_object to (opening(current_object)) true
  1531.             end
  1532.  
  1533.             if ret_val begin
  1534.                 if (import_state(current_object)) get open_alt_files to ret_val
  1535.                 else get open_files to ret_val
  1536.                 send page_object to (opening(current_object)) false
  1537.  
  1538.                 if ret_val begin
  1539.                     if (active_state(current_object)) send deactivate_area
  1540.  
  1541.                     if (import_state(current_object)) send popup to import_data
  1542.                     else begin
  1543.                         send insert_cb SUCCESS_REPLY 0
  1544.                         send insert_cb_file_specs
  1545.                     end
  1546.                 end
  1547.             end
  1548.         end
  1549.  
  1550.         if not ret_val begin
  1551.             if not (active_state(current_object)) send popup
  1552.             send activate to (file(current_object))
  1553.             set current_item of (file(current_object)) to 0
  1554.  
  1555.             if (import_state(current_object)) begin
  1556.                 send close_alt_files
  1557.                 send pop_original_names
  1558.             end
  1559.             else send close_files
  1560.  
  1561.             send reopen_help_files
  1562.         end
  1563.         else send reset_states
  1564.     end_procedure
  1565.  
  1566.     procedure push_original_names
  1567.         set original_grp_name to (grp_file(current_object))
  1568.         set original_sbj_name to (sbj_file(current_object))
  1569.         set original_xrf_name to (xrf_file(current_object))
  1570.         set original_ctx_name to (ctx_file(current_object))
  1571.         set original_path_name to (file_path(current_object))
  1572.     end_procedure
  1573.  
  1574.     procedure pop_original_names
  1575.         set grp_file to (original_grp_name(current_object))
  1576.         set sbj_file to (original_sbj_name(current_object))
  1577.         set xrf_file to (original_xrf_name(current_object))
  1578.         set ctx_file to (original_ctx_name(current_object))
  1579.         set file_path to (original_path_name(current_object))
  1580.     end_procedure
  1581.  
  1582.     function parse_path string path integer typ returns string
  1583.         local integer loc xloc
  1584.         local string pth
  1585.  
  1586.         move path to pth
  1587.         length pth to loc
  1588.         move 0 to xloc
  1589.  
  1590.         while loc gt 0
  1591.             pos (mid(pth,1,loc)) in ":\/" to xloc
  1592.  
  1593.             if xloc gt 0 begin
  1594.               move loc to xloc
  1595.               move 0 to loc
  1596.             end
  1597.             else decrement loc
  1598.         end
  1599.  
  1600.         if xloc ne 0 begin
  1601.             if typ eq 0 function_return (mid(pth,255,xloc+1))
  1602.             else function_return (left(pth,xloc))
  1603.         end
  1604.         else begin
  1605.           if typ eq 0 function_return pth
  1606.           else function_return EMPTY_STRING
  1607.         end
  1608.     end_function
  1609.  
  1610.     procedure init_open
  1611.         local integer ret_val
  1612.         local string prf new_prefix new_path
  1613.  
  1614.         get next_cmd_arg to prf
  1615.         get parse_path prf 0 to new_prefix
  1616.         get parse_path prf 1 to new_path
  1617.  
  1618.         set file_path to new_path
  1619.  
  1620.         set grp_file to (new_prefix + "GRP")
  1621.         set sbj_file to (new_prefix + "SBJ")
  1622.         set xrf_file to (new_prefix + "XRF")
  1623.         set ctx_file to (new_prefix + "CTX")
  1624.  
  1625.         send pre_open
  1626.  
  1627.         send request_ok
  1628.     end_procedure
  1629.  
  1630.     procedure load_file_names
  1631.         local integer obj
  1632.  
  1633.         move (file(current_object)) to obj
  1634.         set value of obj item 0 to (grp_file(current_object))
  1635.         set value of obj item 1 to (sbj_file(current_object))
  1636.         set value of obj item 2 to (xrf_file(current_object))
  1637.         set value of obj item 3 to (ctx_file(current_object))
  1638.     end_procedure
  1639.  
  1640.     procedure load_path_name
  1641.         set value of (path(current_object)) item 0 to (file_path(current_object))
  1642.     end_procedure
  1643.  
  1644.     function grp_name returns string
  1645.         function_return (value(file(current_object), 0))
  1646.     end_function
  1647.     procedure set grp_name string new_val
  1648.         set value of (file(current_object)) item 0 to (uppercase(new_val))
  1649.     end_procedure
  1650.  
  1651.     function sbj_name returns string
  1652.         function_return (value(file(current_object), 1))
  1653.     end_function
  1654.     procedure set sbj_name string new_val
  1655.         set value of (file(current_object)) item 1 to (uppercase(new_val))
  1656.     end_procedure
  1657.  
  1658.     function xrf_name returns string
  1659.         function_return (value(file(current_object), 2))
  1660.     end_function
  1661.     procedure set xrf_name string new_val
  1662.         set value of (file(current_object)) item 2 to (uppercase(new_val))
  1663.     end_procedure
  1664.  
  1665.     function ctx_name returns string
  1666.         function_return (value(file(current_object), 3))
  1667.     end_function
  1668.     procedure set ctx_name string new_val
  1669.         set value of (file(current_object)) item 3 to (uppercase(new_val))
  1670.     end_procedure
  1671.  
  1672.     function path_name returns string
  1673.         function_return (value(path(current_object), 0))
  1674.     end_function
  1675.     procedure set path_name string new_val
  1676.         set value of (path(current_object)) item 0 to new_val
  1677.     end_procedure
  1678.  
  1679.     function make_files string pth returns integer
  1680.         indicate err false
  1681.         move 255 to filenumber
  1682.         make_file (pth + grp_file(current_object) + DEF_EXT_TEXT)
  1683.         [ not err ] make_file (pth + sbj_file(current_object) + DEF_EXT_TEXT)
  1684.         [ not err ] make_file (pth + xrf_file(current_object) + DEF_EXT_TEXT)
  1685.         [ not err ] make_file (pth + ctx_file(current_object) + DEF_EXT_TEXT)
  1686.         [ not err ] function_return 1
  1687.     end_function
  1688.  
  1689.     function open_files returns integer
  1690.         local string pth
  1691.  
  1692.         get file_path to pth
  1693.         indicate err false
  1694.         open (pth + grp_file(current_object)) as grp
  1695.         [not err] open (pth + sbj_file(current_object)) as sbj
  1696.         [not err] open (pth + xrf_file(current_object)) as xrf
  1697.         [not err] open (pth + ctx_file(current_object)) as ctx
  1698.         [not err] function_return 1
  1699.     end_function
  1700.  
  1701.     procedure reopen_help_files
  1702.         indicate err false
  1703.  
  1704.         if current_grp gt EMPTY_STRING open (current_pth + current_grp) as grp
  1705.         [not err] if current_sbj gt EMPTY_STRING ;
  1706.             open (current_pth + current_sbj) as sbj
  1707.         [not err] if current_xrf gt EMPTY_STRING ;
  1708.             open (current_pth + current_xrf) as xrf
  1709.         [not err] if current_ctx gt EMPTY_STRING ;
  1710.             open (current_pth + current_ctx) as ctx
  1711.     end_procedure
  1712.  
  1713.     function open_alt_files returns integer
  1714.         local string pth
  1715.  
  1716.         get file_path to pth
  1717.         indicate err false
  1718.         open (pth + grp_file(current_object)) as grp2
  1719.         [not err] open (pth + sbj_file(current_object)) as sbj2
  1720.         [not err] open (pth + xrf_file(current_object)) as xrf2
  1721.         [not err] open (pth + ctx_file(current_object)) as ctx2
  1722.  
  1723.         [not err] set_relate xrf2.grp_recnum to grp2.recnum
  1724.         [not err] set_relate xrf2.sbj_recnum to sbj2.recnum
  1725.         [not err] set_relate ctx2.xrf_recnum to xrf2.recnum
  1726.         [not err] function_return 1
  1727.     end_function
  1728.  
  1729.     procedure close_files
  1730.         close grp
  1731.         close sbj
  1732.         close xrf
  1733.         close ctx
  1734.     end_procedure
  1735.  
  1736.     procedure close_alt_files
  1737.         close grp2
  1738.         close sbj2
  1739.         close xrf2
  1740.         close ctx2
  1741.     end_procedure
  1742.  
  1743.     function zero_files returns integer
  1744.         indicate err false
  1745.         if (select_state(erase_checks(current_object),0)) zerofile grp
  1746.         [not err] if (select_state(erase_checks(current_object),1)) zerofile sbj
  1747.         [not err] if (select_state(erase_checks(current_object),2)) zerofile xrf
  1748.         [not err] if (select_state(erase_checks(current_object),3)) zerofile ctx
  1749.         function_return 1
  1750.     end_function
  1751.  
  1752.     procedure reset_names
  1753.         set file_path to (path_name(current_object))
  1754.         set grp_file to (grp_name(current_object))
  1755.         set sbj_file to (sbj_name(current_object))
  1756.         set xrf_file to (xrf_name(current_object))
  1757.         set ctx_file to (ctx_name(current_object))
  1758.     end_procedure
  1759.  
  1760.     procedure delete_defs_and_fds string pth
  1761.         erasefile (pth + grp_name(current_object) + DEF_EXT_TEXT)
  1762.         erasefile (pth + sbj_name(current_object) + DEF_EXT_TEXT)
  1763.         erasefile (pth + xrf_name(current_object) + DEF_EXT_TEXT)
  1764.         erasefile (pth + ctx_name(current_object) + DEF_EXT_TEXT)
  1765.     end_procedure
  1766.  
  1767.     function check_file string pth string fil_nam integer img returns integer
  1768.         local integer ret_val cur_img
  1769.  
  1770.         direct_output (pth + fil_nam + DEF_EXT_TEXT)
  1771.         [ seqeof ] move 0 to ret_val
  1772.         [ not seqeof ] move 1 to ret_val
  1773.  
  1774.         if not ret_val close_output
  1775.         else begin
  1776.             move (img - helpgrp_def_top_img.n) to windowindex
  1777.             print (pth + fil_nam) to helpgrp_def_top_img.1&
  1778.             move current_image to cur_img
  1779.             move img to current_image
  1780.             output     // top
  1781.             move (img + 4) to current_image
  1782.             output     // bottom
  1783.             move cur_img to current_image
  1784.             close_output
  1785.  
  1786.             direct_input (pth + fil_nam + DEF_EXT_TEXT)
  1787.             [ seqeof ] move 0 to ret_val
  1788.             [ not seqeof ] move 1 to ret_val
  1789.             close_input
  1790.         end
  1791.  
  1792.         function_return ret_val
  1793.     end_function
  1794.  
  1795.     function check_file_specs string pth returns integer
  1796.         local integer ret_val bad_itm mode
  1797.  
  1798.         get check_file pth (grp_name(current_object)) ;
  1799.             helpgrp_def_top_img.n to ret_val
  1800.         if ret_val get check_file pth (sbj_name(current_object)) ;
  1801.                 helpsbj_def_top_img.n to ret_val
  1802.         if ret_val get check_file pth (xrf_name(current_object)) ;
  1803.                 helpxrf_def_top_img.n to ret_val
  1804.         if ret_val get check_file pth (ctx_name(current_object)) ;
  1805.                 helpctx_def_top_img.n to ret_val
  1806.  
  1807.         function_return ret_val
  1808.     end_function
  1809.  
  1810.     procedure reset_states
  1811.         set new_state to false
  1812.         set open_state to false
  1813.         set erase_state to false
  1814.         set import_state to false
  1815.     end_procedure
  1816.   end_object // help_files
  1817. end
  1818.  
  1819. on_key kexit_application send exit_program
  1820.  
  1821. //////////////////////////////////
  1822. ////////////////////////////////// main logic
  1823. //////////////////////////////////
  1824.  
  1825. if cmd_option eq PATH_OPTION send init_open to help_files
  1826. else if cmd_option eq NEW_FILE_OPTION send new to help_files
  1827. else if cmd_option eq OPEN_FILE_OPTION send open to help_files
  1828. else if cmd_option eq IMP_MAINT_OPTION send import to help_files
  1829. else if cmd_option eq ERS_MAINT_OPTION send erase to help_files
  1830.  
  1831. start_ui
  1832.  
  1833. abort
  1834.