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

  1. // dfhelp_c.src (secondary help maintenance program [C])
  2. // July 17, 1991
  3. // LS
  4.  
  5. use dfhelp_c  // secondary help maintenance program [C] header package
  6.  
  7. //////////////////////////////////
  8. ////////////////////////////////// global variables
  9. //////////////////////////////////
  10.  
  11. string cmd_option  // option passed on cmd line (via chain wait)
  12. move EMPTY_STRING to cmd_option
  13.  
  14. string current_grp current_sbj current_xrf current_ctx current_pth
  15. move EMPTY_STRING to current_grp   // names of currently open help data files
  16. move EMPTY_STRING to current_sbj   // passed on cmd line (via chain wait)
  17. move EMPTY_STRING to current_xrf
  18. move EMPTY_STRING to current_ctx
  19. move EMPTY_STRING to current_pth
  20.  
  21. //////////////////////////////////
  22. ////////////////////////////////// global procedures
  23. //////////////////////////////////
  24.  
  25. procedure deactivate_area for desktop
  26.     send deactivate AREA_TYPE
  27. end_procedure
  28.  
  29. procedure insert_cb for desktop string val integer itm
  30.     local integer flag
  31.  
  32.     get insert_mode of clipboard to flag
  33.     set insert_mode of clipboard to true
  34.  
  35.     send goto_line to clipboard itm
  36.     set right_margin of clipboard to 56
  37.     send key to clipboard kenter
  38.     set value of clipboard item itm to val
  39.  
  40.     set insert_mode of clipboard to flag
  41. end_procedure
  42.  
  43. function next_cmd_arg for desktop returns string
  44.     local string arg
  45.  
  46.     cmdline arg
  47.     if arg le EMPTY_STRING begin
  48.         error 57 ("Command line argument not specified")
  49.         send insert_cb FAIL_REPLY 0
  50.         abort
  51.     end
  52.  
  53.     if arg eq EMPTY_REPL_STRING function_return EMPTY_STRING
  54.     else function_return arg
  55. end_function
  56.  
  57. // retrieve option passed on command line to determine which objects to use
  58.  
  59. procedure init_program for desktop // retrieve option passed on command line to determine which objects to use
  60.     cmdline cmd_option
  61.  
  62.     if cmd_option le EMPTY_STRING begin
  63.         error 57 ("Option not specified for program.")
  64.         send insert_cb FAIL_REPLY 0
  65.         abort
  66.     end
  67.  
  68.     left cmd_option to cmd_option 1
  69.     uppercase cmd_option
  70.  
  71.     if not cmd_option in VALID_OPTIONS begin
  72.         error 57 ("Invalid option passed to program: " + cmd_option)
  73.         send insert_cb FAIL_REPLY 0
  74.         abort
  75.     end
  76.  
  77.     get next_cmd_arg to current_grp
  78.     get next_cmd_arg to current_sbj
  79.     get next_cmd_arg to current_xrf
  80.     get next_cmd_arg to current_ctx
  81.     get next_cmd_arg to current_pth
  82. end_procedure
  83.  
  84. procedure exit_program for desktop
  85.     send insert_cb ABORT_REPLY 0
  86.     send exit_application
  87. end_procedure
  88.  
  89. send init_program
  90.  
  91. //////////////////////////////////
  92. ////////////////////////////////// augmentation to help_object class to
  93. ////////////////////////////////// override default help access
  94. //////////////////////////////////
  95.  
  96. procedure request_help for (class(help_object.obj)) integer msg_id integer arg
  97.     local integer orig_grp orig_sbj orig_xrf orig_ctx
  98.     local string old_grp_filename old_sbj_filename old_xrf_filename old_ctx_filename
  99.     local string cur_grp_filename cur_sbj_filename cur_xrf_filename cur_ctx_filename
  100.  
  101.     move current_pth to cur_grp_filename
  102.     append cur_grp_filename current_grp
  103.     move current_pth to cur_sbj_filename
  104.     append cur_sbj_filename current_sbj
  105.     move current_pth to cur_xrf_filename
  106.     append cur_xrf_filename current_xrf
  107.     move current_pth to cur_ctx_filename
  108.     append cur_ctx_filename current_ctx
  109.  
  110.     if cur_grp_filename gt EMPTY_STRING begin
  111.         move grp.recnum to orig_grp
  112.         close grp
  113.     end
  114.     if cur_sbj_filename gt EMPTY_STRING begin
  115.         move sbj.recnum to orig_sbj
  116.         close sbj
  117.     end
  118.     if cur_xrf_filename gt EMPTY_STRING begin
  119.         move xrf.recnum to orig_xrf
  120.         close xrf
  121.     end
  122.     if cur_ctx_filename gt EMPTY_STRING begin
  123.         move ctx.recnum to orig_ctx
  124.         close ctx
  125.     end
  126.  
  127.     if num_arguments gt 1 send msg_id arg
  128.     else send msg_id
  129.  
  130.     if cur_grp_filename gt EMPTY_STRING begin
  131.         open cur_grp_filename as grp
  132.         clear grp
  133.         if orig_grp ne 0 begin
  134.             move orig_grp to grp.recnum
  135.             find eq grp.recnum
  136.         end
  137.     end
  138.     if cur_sbj_filename gt EMPTY_STRING begin
  139.         open cur_sbj_filename as sbj
  140.         clear sbj
  141.         if orig_sbj ne 0 begin
  142.             move orig_sbj to sbj.recnum
  143.             find eq sbj.recnum
  144.         end
  145.     end
  146.     if cur_xrf_filename gt EMPTY_STRING begin
  147.         open cur_xrf_filename as xrf
  148.         clear xrf
  149.         if orig_xrf ne 0 begin
  150.             move orig_xrf to xrf.recnum
  151.             find eq xrf.recnum
  152.         end
  153.     end
  154.     if cur_ctx_filename gt EMPTY_STRING begin
  155.         open cur_ctx_filename as ctx
  156.         clear ctx
  157.         if orig_ctx ne 0 begin
  158.             move orig_ctx to ctx.recnum
  159.             find eq ctx.recnum
  160.         end
  161.     end
  162. end_procedure
  163.  
  164. //////////////////////////////////
  165. ////////////////////////////////// classes
  166. //////////////////////////////////
  167.  
  168. // class for displaying information in a text window
  169.  
  170. class display_window is an edit
  171.     register_function initial_highlight_color returns integer
  172.  
  173.     procedure construct_object
  174.         forward send construct_object
  175.  
  176.         property integer highlight_color public (initial_highlight_color(current_object))
  177.         property integer normal_colors   public (object_color(current_object))
  178.     end_procedure
  179.  
  180.     function initial_highlight_color returns integer
  181.         local integer obj chk_obj pal ret_val
  182.  
  183.         move current_object to obj
  184.  
  185.         repeat
  186.         move obj to chk_obj
  187.         get class_palette (class(chk_obj)) to pal
  188.         if pal eq 0 get parent of chk_obj to obj
  189.         until (pal <> 0 or chk_obj = desktop)
  190.  
  191.         get palette_color pal POINTED_CURSOR_TYPE to ret_val
  192.         function_return ret_val
  193.     end_function
  194.  
  195.     procedure entering returns integer
  196.         local integer ret_val
  197.  
  198.         forward get msg_entering to ret_val
  199.  
  200.         if not ret_val set object_color to ;
  201.             (highlight_color(current_object)) (low(normal_colors(current_object)))
  202.     end_procedure
  203.  
  204.     procedure exiting integer obj returns integer
  205.         local integer ret_val clrs
  206.  
  207.         forward get msg_exiting obj to ret_val
  208.  
  209.         if not ret_val begin
  210.             get normal_colors to clrs
  211.             set object_color to (hi(clrs)) (low(clrs))
  212.         end
  213.     end_procedure
  214.  
  215.     procedure release_focus
  216.         local integer ret_val clrs
  217.  
  218.         forward send release_focus
  219.  
  220.         get normal_colors to clrs
  221.         set object_color to (hi(clrs)) (low(clrs))
  222.     end_procedure
  223.  
  224.     set class_colors to u_!$ 0 0 // set colors for current class to inherit
  225. end_class
  226.     
  227. //////////////////////////////////
  228. //////////////////////////////////  main object definitions
  229. //////////////////////////////////
  230.  
  231. if cmd_option eq CTX_MAINT_OPTION begin
  232.  
  233. /trans_data_img
  234. ╔════════════════════════════════════════════════════════════════╗
  235. ║________________________________________________________________║
  236. ║                                                                ║
  237. ║                    ┌─ Operation: ──────────┐                   ║
  238. ║                    │     _____________     │                   ║
  239. ║                    │     _____________     │                   ║
  240. ║                    └───────────────────────┘                   ║
  241. ║ ┌─ Original context values: ─────────────────────────────────┐ ║
  242. ║ │ Application name: _______________                          │ ║
  243. ║ │      Module name: _______________                          │ ║
  244. ║ │        Help name: ________________________________________ │ ║
  245. ║ └────────────────────────────────────────────────────────────┘ ║
  246. ║ ┌─ New context values: ──────────────────────────────────────┐ ║
  247. ║ │ Application name: _______________                          │ ║
  248. ║ │      Module name: _______________                          │ ║
  249. ║ │        Help name: ________________________________________ │ ║
  250. ║ └────────────────────────────────────────────────────────────┘ ║
  251. ║             __________        _____________________            ║
  252. ║        __________         ___________          _________       ║
  253. ╚════════════════════════════════════════════════════════════════╝
  254. /*
  255. //                        ( ) Delete
  256. //                        ( ) Translate
  257. //
  258. //            <F2=Begin>        <Alt+F2=Display only>
  259. //       <F5=Clear>         <Esc=Close>          <F1=Help>
  260. sub_page trans_data_oper_img  from trans_data_img 2 3
  261. sub_page trans_data_old_img   from trans_data_img 4 5 6
  262. sub_page trans_data_new_img   from trans_data_img 7 8 9
  263. sub_page trans_data_btns_img  from trans_data_img 10 11 12 13 14
  264.  
  265.     object trans_data is a client trans_data_img
  266.         set location    to 2 7 relative
  267.         set popup_state to true
  268.         set scope_state to true
  269.  
  270.         set center_state item 0 to true
  271.         set value item 0 to "Context Maintenance"
  272.  
  273.         object operation is a checkbox trans_data_oper_img
  274.             set select_mode to auto_select
  275.  
  276.             item_list
  277.                 on_item "Delete"    send next
  278.                     set select_state to true
  279.                 on_item "Translate" send next
  280.             end_item_list
  281.  
  282.             on_key kcancel        send request_cancel  private
  283.             on_key kclear         send request_clear   private
  284.             on_key key_alt+key_f2 send display_only    private
  285.             on_key ksave_record   send request_begin   private
  286.  
  287.             procedure select_toggling integer itm integer flag
  288.                 forward send select_toggling itm flag
  289.                 delegate send reset_mode
  290.             end_procedure
  291.  
  292.             function translate_state returns integer
  293.                 function_return (select_state(current_object,1))
  294.             end_function
  295.         end_object // operation
  296.  
  297.         object old_data is a form trans_data_old_img
  298.             item_list
  299.                 on_item EMPTY_STRING send next
  300.                 on_item EMPTY_STRING send next
  301.                 on_item EMPTY_STRING send next
  302.             end_item_list
  303.  
  304.             on_key kenter         send next            private
  305.             on_key kcancel        send request_cancel  private
  306.             on_key key_alt+key_f2 send display_only    private
  307.             on_key kclear         send request_clear   private
  308.             on_key ksave_record   send request_begin   private
  309.         end_object
  310.  
  311.         object new_data is a form trans_data_new_img
  312.             item_list
  313.                 on_item EMPTY_STRING send next
  314.                 on_item EMPTY_STRING send next
  315.                 on_item EMPTY_STRING send next
  316.             end_item_list
  317.  
  318.             on_key kenter         send next            private
  319.             on_key kcancel        send request_cancel  private
  320.             on_key key_alt+key_f2 send display_only    private
  321.             on_key kclear         send request_clear   private
  322.             on_key ksave_record   send request_begin   private
  323.         end_object // new_data
  324.  
  325.         object buttons is a button trans_data_btns_img
  326.             item_list
  327.                 on_item "<F2=Begin>"            send request_begin
  328.                 on_item "<Alt+F2=Display only>" send display_only
  329.                 on_item "<F5=Clear>"            send request_clear
  330.                 on_item ESC_CLOSE_TEXT          send request_cancel
  331.                 on_item F1_HELP_TEXT            send help
  332.             end_item_list
  333.  
  334.             on_key kcancel        send request_cancel  private
  335.             on_key key_alt+key_f2 send display_only    private
  336.             on_key kclear         send request_clear   private
  337.             on_key ksave_record   send request_begin   private
  338.         end_object
  339.  
  340. /trans_process_img
  341. ╔════════════════════════════════════════════╗
  342. ║                                            ║
  343. ║                                            ║
  344. ║                                            ║
  345. ║                                            ║
  346. ║                                            ║
  347. ╚════════════════════════════════════════════╝
  348. /trans_process_display_img
  349. _________ ______   ____________ ______
  350. /trans_process_cancel_btn_img
  351. ____________
  352. /*
  353.  
  354.         object process is a client trans_process_img
  355.             set popup_state to true
  356.             set location    to 5 10 relative
  357.             
  358.             object display is a message trans_process_display_img
  359.                 set focus_mode   to nonfocusable
  360.                 set location     to 2 4 relative
  361.             end_object
  362.  
  363.             object button is a button trans_process_cancel_btn_img
  364.                 set location to 4 17 relative
  365.  
  366.                 item_list
  367.                     on_item ESC_CANCEL_TEXT send none
  368.                 end_item_list
  369.  
  370. /trans_interrupt_img
  371. ╔═══════════════════════════════════════════════════════╗
  372. ║           Translation/deletion interrupted.           ║
  373. ║                                                       ║
  374. ║             _____________     ___________             ║
  375. ╚═══════════════════════════════════════════════════════╝
  376. /*
  377.  
  378.                 object interrupt is a button trans_interrupt_img
  379.                     set block_mouse_state to true
  380.                     set location          to 0 -23 relative
  381.                     set popup_state       to true
  382.                     set scope_state       to true
  383.  
  384.                     item_list
  385.                         on_item "<F2=Continue>" send ok
  386.                         on_item "<Esc=Abort>"   send cancel
  387.                     end_item_list
  388.  
  389.                     on_key ksave_record send ok
  390.                     on_key kcancel      send cancel
  391.                 end_object
  392.  
  393.                 function check_interrupt returns integer
  394.                     local string trash
  395.                     local integer wloc mloc ret_val
  396.  
  397.                     inkey trash
  398.  
  399.                     if (termchar eq kexit_application or ;
  400.                         termchar eq kcancel or ;
  401.                         termchar eq kmouse) begin
  402.  
  403.                         if (termchar eq kmouse) begin
  404.                             get window_location item 1 to wloc
  405.                             move (wloc + location(current_object)) to wloc
  406.                             get absolute_mouse_location to mloc
  407.                             if not (mloc >= wloc and mloc < (wloc + length(value(current_object,0)))) ;
  408.                                 function_return 0
  409.                         end
  410.  
  411.                         set kbd_input_mode to 1
  412.  
  413.                         set highlight_state to false
  414.                         ui_accept (interrupt(current_object)) to ret_val
  415.                         if ret_val ne msg_ok function_return 1
  416.                         set highlight_state to true
  417.                         set kbd_input_mode to 2
  418.                     end
  419.  
  420.                     function_return 0
  421.                 end_function
  422.             end_object // button
  423.  
  424.             procedure init_display integer flag
  425.                 local integer obj
  426.  
  427.                 move (display(current_object)) to obj
  428.                 send delete_data to obj
  429.                 set value of obj item 0 to "Scanning:"
  430.                 if flag set value of obj item 2 to "Translating:"
  431.                    else set value of obj item 2 to "   Deleting:"
  432.             end_procedure
  433.  
  434.             function scan integer itm returns integer
  435.                 local integer ret_val obj
  436.  
  437.                 move (display(current_object)) to obj
  438.                 set value of obj item ((itm * 2) + 1) to (value(obj,(itm * 2) + 1) + 1)
  439.                 get check_interrupt of (button(current_object)) to ret_val
  440.                 function_return ret_val
  441.             end_function
  442.         end_object // process
  443.  
  444. /trans_display_list_img
  445. ╔═══════════════════════════════════════════╗
  446. ║___________________________________________║
  447. ║                                           ║
  448. ║                                           ║
  449. ║                                           ║
  450. ║                                           ║
  451. ║                                           ║
  452. ║                                           ║
  453. ║                                           ║
  454. ║                                           ║
  455. ║                                           ║
  456. ║                                           ║
  457. ╚═══════════════════════════════════════════╝
  458. /trans_display_list_btn_img
  459.          _______         _________        
  460. /*
  461. //       <F2=OK>         <F1=Help>
  462.  
  463.         object display_list is a client trans_display_list_img
  464.             set block_mouse_state   to true
  465.             set location            to 0 10 relative
  466.             set popup_state         to true
  467.             set scope_state         to true
  468.  
  469.             set center_state item 0 to true
  470.             set value        item 0 to "Contexts to be deleted/translated"
  471.  
  472.             object button is a button trans_display_list_btn_img
  473.                 set location to 11 1 relative
  474.  
  475.                 item_list
  476.                     on_item F2_OK_TEXT   send request_ok
  477.                     on_item F1_HELP_TEXT send help
  478.                 end_item_list
  479.  
  480.                 on_key ksave_record send request_ok private
  481.             end_object
  482.  
  483. // button before list places focus on button during default activate of client
  484.  
  485.             object list is a display_window
  486.                 set size            to 8 42
  487.                 set location        to 3 1 relative
  488.                 set object_color    to (hi(object_color(parent(current_object)))) (low(object_color(parent(current_object))))
  489.                 set read_only_state to true
  490.  
  491.                 on_key ksave_record send request_ok private
  492.  
  493.                 procedure insert_line string txt
  494.                     local string newline
  495.  
  496.                     set read_only_state to false
  497.                     send insert txt
  498.                     send process_key kenter
  499.                     set read_only_state to true
  500.                 end_procedure
  501.             end_object
  502.  
  503.             procedure request_ok
  504.                 send deactivate_area
  505.                 send delete_data
  506.                 delegate send restart
  507.             end_procedure
  508.  
  509.             procedure delete_data
  510.                 send delete_data to (list(current_object))
  511.             end_procedure
  512.  
  513.             procedure release_focus
  514.                 forward send release_focus
  515.                 send delete_data
  516.             end_procedure
  517.  
  518.             procedure show_trans_ctx integer flag string app_name string mod_name string hlp_name
  519.                 local integer obj
  520.  
  521.                 move (list(current_object)) to obj
  522.                 if flag send insert_line to obj "NEW:"
  523.                 else send insert_line to obj "ORIGINAL:"
  524.                 send insert_line to obj (trim(app_name))
  525.                 send insert_line to obj (trim(mod_name))
  526.                 send insert_line to obj (trim(hlp_name))
  527.             end_procedure
  528.  
  529.             procedure show_del_ctx string app_name string mod_name string hlp_name
  530.                 local integer obj
  531.  
  532.                 move (list(current_object)) to obj
  533.                 send insert_line to obj "DELETE:"
  534.                 send insert_line to obj (trim(app_name))
  535.                 send insert_line to obj (trim(mod_name))
  536.                 send insert_line to obj (trim(hlp_name))
  537.             end_procedure
  538.         end_object // display_list
  539.  
  540. /trans_done_img
  541. ╔═══════════════════════════════════════════════════════╗
  542. ║             Translation/deletion complete.            ║
  543. ║                                                       ║
  544. ║                     ____    ______                    ║
  545. ╚═══════════════════════════════════════════════════════╝
  546. /*
  547.  
  548.         object done is a button trans_done_img
  549.             set block_mouse_state to true
  550.             set location          to 9 4 relative
  551.             set popup_state       to true
  552.             set scope_state       to true
  553.  
  554.             item_list
  555.                 on_item "<OK>"   send request_ok
  556.                 on_item "<Help>" send help
  557.             end_item_list
  558.  
  559.             procedure request_ok
  560.                 send deactivate_area
  561.                 delegate send restart
  562.             end_procedure
  563.         end_object
  564.  
  565.         function translate_state returns integer
  566.             function_return (translate_state(operation(current_object)))
  567.         end_function
  568.  
  569.         procedure reset_mode
  570.             local integer flag tot_itms itm obj
  571.  
  572.             get translate_state to flag
  573.             move (not(flag)) to flag
  574.  
  575.             move (new_data(current_object)) to obj
  576.             move (item_count(obj) - 1) to tot_itms
  577.  
  578.             for itm from 0 to tot_itms
  579.                 set shadow_state of obj item itm to flag
  580.             loop
  581.         end_procedure
  582.  
  583.         function mask integer which_mask returns string
  584.             local integer obj itm
  585.  
  586.             if which_mask lt NEW_APP_TYPE begin
  587.                 move (old_data(current_object)) to obj
  588.                 move which_mask to itm
  589.             end
  590.             else begin
  591.                 move (new_data(current_object)) to obj
  592.                 move (which_mask - NEW_APP_TYPE) to itm
  593.             end
  594.  
  595.             function_return (value(obj,itm))
  596.         end_function
  597.  
  598.         procedure set mask integer which_mask string new_val
  599.             local integer obj itm
  600.  
  601.             if which_mask lt NEW_APP_TYPE begin
  602.                 move (old_data(current_object)) to obj
  603.                 move which_mask to itm
  604.             end
  605.             else begin
  606.                 move (new_data(current_object)) to obj
  607.                 move (which_mask - NEW_APP_TYPE) to itm
  608.             end
  609.  
  610.             set value of obj item itm to new_val
  611.         end_procedure
  612.  
  613.         function trim_star string old_val returns string
  614.             local integer cpos
  615.  
  616.             pos "*" in old_val to cpos
  617.             if cpos ne 0 function_return (left(old_val,cpos))
  618.             function_return old_val
  619.         end_function
  620.  
  621.         procedure trim_masks
  622.             local integer cpos
  623.             local string test_val
  624.  
  625.             set mask OLD_APP_TYPE to (trim_star(current_object,mask(current_object,OLD_APP_TYPE)))
  626.             set mask OLD_MOD_TYPE to (trim_star(current_object,mask(current_object,OLD_MOD_TYPE)))
  627.             set mask OLD_HLP_TYPE to (trim_star(current_object,mask(current_object,OLD_HLP_TYPE)))
  628.  
  629.             set mask NEW_APP_TYPE to (trim_star(current_object,mask(current_object,NEW_APP_TYPE)))
  630.             set mask NEW_MOD_TYPE to (trim_star(current_object,mask(current_object,NEW_MOD_TYPE)))
  631.             set mask NEW_HLP_TYPE to (trim_star(current_object,mask(current_object,NEW_HLP_TYPE)))
  632.         end_procedure
  633.  
  634.         function wild_chars string wild_val returns integer
  635.             local integer cpos wcount
  636.  
  637.             move 0 to wcount
  638.             pos "?" in wild_val to cpos
  639.  
  640.             while cpos ne 0
  641.                 replace "?" in wild_val with EMPTY_REPL_STRING
  642.                 increment wcount
  643.                 pos "?" in wild_val to cpos
  644.             end
  645.  
  646.             pos "*" in wild_val to cpos
  647.             if cpos ne 0 move (0 - wcount) to wcount // negative means "*" char
  648.             function_return wcount
  649.         end_function
  650.  
  651.         function compare_wild_count integer old_wc integer new_wc returns integer
  652.             if (abs(old_wc) < abs(new_wc) or ;    // must have fewer ? in old than in new
  653.                 (old_wc >= 0 and new_wc < 0)) function_return 1 // if * not in old, new cannot have *
  654.         end_function
  655.  
  656.         function validate_masks returns integer
  657.             local integer old_wild_count new_wild_count
  658.  
  659.             get wild_chars (mask(current_object,OLD_APP_TYPE)) to old_wild_count
  660.             get wild_chars (mask(current_object,NEW_APP_TYPE)) to new_wild_count
  661.             if (compare_wild_count(current_object, old_wild_count, new_wild_count)) function_return 1
  662.  
  663.             get wild_chars (mask(current_object,OLD_MOD_TYPE)) to old_wild_count
  664.             get wild_chars (mask(current_object,NEW_MOD_TYPE)) to new_wild_count
  665.             if (compare_wild_count(current_object, old_wild_count, new_wild_count)) function_return 2
  666.  
  667.             get wild_chars (mask(current_object,OLD_HLP_TYPE)) to old_wild_count
  668.             get wild_chars (mask(current_object,NEW_HLP_TYPE)) to new_wild_count
  669.             if (compare_wild_count(current_object, old_wild_count, new_wild_count)) function_return 3
  670.         end_function
  671.  
  672.         function translated_value string old_val string pold_mask string new_mask returns string
  673.             local string new_val old_mask
  674.             local integer old_cpos new_cpos
  675.  
  676.             move pold_mask to old_mask
  677.             move new_mask to new_val
  678.  
  679.             pos "?" in old_mask to old_cpos
  680.             while old_cpos ne 0
  681.                 replace "?" in new_val with (mid(old_val,1,old_cpos))
  682.                 replace "?" in old_mask with EMPTY_REPL_STRING
  683.                 pos "?" in old_mask to old_cpos
  684.             end
  685.  
  686.             pos "*" in old_mask to old_cpos
  687.             if old_cpos ne 0 begin
  688.                 pos "*" in new_val to new_cpos
  689.                 if new_cpos ne 0 begin
  690.                     left new_val to new_val (new_cpos - 1)
  691.                     append new_val (right(old_val,length(old_val) - old_cpos + 1))
  692.                 end
  693.             end
  694.  
  695.             function_return new_val
  696.         end_function
  697.  
  698.         procedure restart
  699.             set kbd_input_mode to 1
  700.             send deactivate to (process(current_object))
  701.             send deactivate to (display_list(current_object))
  702.         end_procedure
  703.  
  704.         procedure request_clear
  705.             set current_item of (operation(current_object)) to 0
  706.             send delete_data to (new_data(current_object))
  707.             send delete_data to (old_data(current_object))
  708.             send activate to (operation(current_object))
  709.         end_procedure
  710.  
  711.         procedure init_process integer live
  712.             local integer obj
  713.  
  714.             send init_display to (process(current_object)) (translate_state(current_object))
  715.  
  716.             if not live begin
  717.                 set max_lines of (list(display_list(current_object))) to MAX_LINES_ALLOWED
  718.                 send delete_data to (display_list(current_object))
  719.                 send popup to (display_list(current_object))
  720.             end
  721.  
  722.             move (process(current_object)) to obj
  723.             send delete_data to obj
  724.             send popup to obj
  725.             set highlight_state of (button(obj)) to true
  726.             set kbd_input_mode to 2
  727.         end_procedure
  728.  
  729.         procedure process_complete integer live
  730.             set kbd_input_mode to 1
  731.             set highlight_state of (button(process(current_object))) to false
  732.  
  733.             if live send popup to (done(current_object))
  734.             else begin
  735.                 set max_lines of (list(display_list(current_object))) to (line_count(list(display_list(current_object))) + 1)
  736.                 send deactivate to (process(current_object))
  737.             end
  738.         end_procedure
  739.  
  740.         procedure request_begin
  741.             send request_operation true
  742.         end_procedure
  743.  
  744.         procedure display_only
  745.             send request_operation false
  746.         end_procedure
  747.  
  748.         procedure request_operation integer live
  749.             local integer obj ret_val app_typ mod_typ hlp_typ trans_state
  750.             local string app_test mod_test hlp_test
  751.  
  752.             get translate_state to trans_state
  753.             if not trans_state send delete_data to (new_data(current_object))
  754.             
  755.             send trim_masks
  756.  
  757.             uppercase (mask(current_object,OLD_APP_TYPE)) to app_test
  758.             uppercase (mask(current_object,OLD_MOD_TYPE)) to mod_test
  759.             uppercase (mask(current_object,OLD_HLP_TYPE)) to hlp_test
  760.  
  761.             if app_test gt EMPTY_STRING move 1 to app_typ
  762.             if mod_test gt EMPTY_STRING move 1 to mod_typ
  763.             if hlp_test gt EMPTY_STRING move 1 to hlp_typ
  764.  
  765.             if trans_state begin
  766.                 if (validate_masks(current_object)) begin
  767.                     send activate to (old_data(current_object))
  768.                     set current_item of (old_data(current_object)) to (ret_val - 1)
  769.                     error 15 "Translation formats do not match"
  770.                     procedure_return
  771.                 end
  772.  
  773.                 move (app_typ or mask(current_object,NEW_APP_TYPE) > EMPTY_STRING) to app_typ
  774.                 move (mod_typ or mask(current_object,NEW_MOD_TYPE) > EMPTY_STRING) to mod_typ
  775.                 move (hlp_typ or mask(current_object,NEW_HLP_TYPE) > EMPTY_STRING) to ret_val
  776.             end
  777.  
  778.             if not (app_typ or mod_typ or hlp_typ) begin
  779.                 send activate to (old_data(current_object))
  780.                 set current_item of (old_data(current_object)) to 0
  781.                 error 13 "Criteria for Contexts must be specified"
  782.                 procedure_return
  783.             end
  784.  
  785.             send init_process live
  786.  
  787.             clear ctx
  788.             find ge ctx.recnum
  789.             [found] repeat
  790.                 if (scan(current_object,CTX_MAINT_SCAN_TYPE)) begin
  791.                     send restart
  792.                     procedure_return
  793.                 end
  794.     
  795.                 if app_typ indicate found as ;
  796.                     app_test match (uppercase(trim(ctx.app_name)))
  797.                 [found] if mod_typ indicate found as ;
  798.                     mod_test match (uppercase(trim(ctx.mod_name)))
  799.                 [found] if hlp_typ indicate found as ;
  800.                     hlp_test match (uppercase(trim(ctx.hlp_name)))
  801.     
  802.                 [found] begin
  803.                     indicate err false
  804.  
  805.                     if live get act_on_record trans_state app_typ mod_typ hlp_typ to ret_val
  806.                     else get show_operation trans_state app_typ mod_typ hlp_typ to ret_val
  807.                             // match!
  808.  
  809.                     [err] procedure_return // abort on error
  810.  
  811.                     if ret_val begin
  812.                         send restart
  813.                         procedure_return
  814.                     end
  815.                 end
  816.     
  817.                 find gt ctx.recnum
  818.             [found] loop
  819.  
  820.             send process_complete live
  821.         end_procedure
  822.  
  823.         function scan integer itm returns integer
  824.             function_return (scan(process(current_object),itm))
  825.         end_function
  826.  
  827.         function translated_app_name returns string
  828.             function_return (translated_value(current_object,ctx.app_name, ;
  829.                 (mask(current_object,OLD_APP_TYPE)), ;
  830.                 (mask(current_object,NEW_APP_TYPE))))
  831.         end_function
  832.  
  833.         function translated_mod_name returns string
  834.             function_return (translated_value(current_object,ctx.mod_name, ;
  835.                 (mask(current_object,OLD_MOD_TYPE)), ;
  836.                 (mask(current_object,NEW_MOD_TYPE))))
  837.         end_function
  838.  
  839.         function translated_hlp_name returns string
  840.             function_return (translated_value(current_object,ctx.hlp_name, ;
  841.                 (mask(current_object,OLD_HLP_TYPE)), ;
  842.                 (mask(current_object,NEW_HLP_TYPE))))
  843.         end_function
  844.  
  845.         function show_operation integer trans_state integer app_typ integer mod_typ integer hlp_typ returns integer
  846.             local integer ret_val obj old_rec show_oper_state
  847.             local string app_val mod_val hlp_val
  848.  
  849.             move 1 to show_oper_state
  850.  
  851.             move (display_list(current_object)) to obj
  852.             if trans_state begin
  853.                 move ctx.recnum to old_rec
  854.  
  855.                 if app_typ get translated_app_name to app_val
  856.                 else move ctx.app_name to app_val
  857.                 if mod_typ get translated_mod_name to mod_val
  858.                 else move ctx.mod_name to mod_val
  859.                 if hlp_typ get translated_hlp_name to hlp_val
  860.                 else move ctx.hlp_name to hlp_val
  861.  
  862.                 clear ctx
  863.                 move app_val to ctx.app_name
  864.                 move mod_val to ctx.mod_name
  865.                 move hlp_val to ctx.hlp_name
  866.                 find eq ctx.hlp_name
  867.  
  868.                 [found] move 0 to show_oper_state
  869.  
  870.                 clear ctx
  871.                 move old_rec to ctx.recnum
  872.                 find eq ctx.recnum
  873.  
  874.                 if show_oper_state begin
  875.                     send show_trans_ctx to obj false ctx.app_name ctx.mod_name ctx.hlp_name
  876.                     send show_trans_ctx to obj true app_val mod_val hlp_val
  877.                 end
  878.             end
  879.             else send show_del_ctx to obj ctx.app_name ctx.mod_name ctx.hlp_name
  880.  
  881.             if show_oper_state function_return (scan(current_object,CTX_MAINT_OPER_TYPE))
  882.         end_function
  883.  
  884.         function act_on_record integer trans_state integer app_typ integer mod_typ integer hlp_typ returns integer
  885.             local integer old_rec show_oper_state
  886.             local string app_val mod_val hlp_val
  887.  
  888.             move ctx.recnum to old_rec
  889.             move 1 to show_oper_state
  890.  
  891.             indicate err false
  892.  
  893.             REREAD ctx
  894.  
  895.               [not err] begin
  896.                 if trans_state begin
  897.                     if app_typ get translated_app_name to app_val
  898.                     else move ctx.app_name to app_val
  899.                     if mod_typ get translated_mod_name to mod_val
  900.                     else move ctx.mod_name to mod_val
  901.                     if hlp_typ get translated_hlp_name to hlp_val
  902.                     else move ctx.hlp_name to hlp_val
  903.  
  904.                     clear ctx
  905.                     move app_val to ctx.app_name
  906.                     move mod_val to ctx.mod_name
  907.                     move hlp_val to ctx.hlp_name
  908.                     find eq ctx.hlp_name
  909.  
  910.                     [found] move 0 to show_oper_state
  911.  
  912.                     clear ctx
  913.                     move old_rec to ctx.recnum
  914.                     find eq ctx.recnum
  915.  
  916.                     if show_oper_state begin
  917.                         move app_val to ctx.app_name
  918.                         move mod_val to ctx.mod_name
  919.                         move hlp_val to ctx.hlp_name
  920.                         saverecord ctx
  921.                     end
  922.                 end
  923.                 else begin
  924.                     delete ctx
  925.                     move old_rec to ctx.recnum
  926.                 end
  927.               end
  928.  
  929.             UNLOCK
  930.  
  931.             [not err] if show_oper_state if (scan(current_object,CTX_MAINT_OPER_TYPE)) function_return 1
  932.  
  933.             function_return 0
  934.         end_function
  935.  
  936.         procedure request_cancel
  937.             send deactivate_area
  938.             send insert_cb SUCCESS_REPLY 0
  939.         end_procedure
  940.  
  941.         procedure activating
  942.             send reset_mode
  943.         end_procedure
  944.     end_object // trans_data
  945.  
  946.     send popup to trans_data
  947.  
  948. end
  949. else if cmd_option eq CLN_MAINT_OPTION begin
  950.  
  951. /cleanup_img
  952. ╔══════════════════════════════════════════════════════════════╗
  953. ║______________________________________________________________║
  954. ║                                                              ║
  955. ║          Delete:                                             ║
  956. ║          ________________________________________            ║
  957. ║          ________________________________________            ║
  958. ║          ________________________________________            ║
  959. ║          ________________________________________            ║
  960. ║                                                              ║
  961. ║          ________________________________________            ║
  962. ║                                                              ║
  963. ║  __________  _____________________  ___________  _________   ║
  964. ╚══════════════════════════════════════════════════════════════╝
  965. /*
  966. // <F2=Begin>  <Alt+F2=Display only>  <Esc=Close>  <F1=Help>
  967. sub_page cleanup_options_img   from cleanup_img 2 3 4 5 6
  968. sub_page cleanup_buttons_img   from cleanup_img 7 8 9 10
  969.  
  970.     object cleanup is a client cleanup_img
  971.         set block_mouse_state to true
  972.         set location          to 4 8 relative
  973.         set popup_state       to true
  974.         set scope_state       to true
  975.  
  976.         set center_state item 0 to true
  977.         set value item 0 to "Cleanup"
  978.  
  979.         object options is a checkbox cleanup_options_img
  980.             set select_mode to multi_select
  981.  
  982.             item_list
  983.                 on_item "Links for invalid Groups or Subjects" send next
  984.                 on_item "Contexts for invalid Links"           send next
  985.                 on_item "Groups without Links"                 send next
  986.                 on_item "Subjects without Links"               send next
  987.  
  988.                 on_item "Write to .DEL file" send next
  989.             end_item_list
  990.  
  991.             on_key key_alt+key_f2 send display_only private
  992.             on_key ksave_record   send request_begin private
  993.             on_key kcancel        send request_cancel private
  994.         end_object
  995.  
  996.         object buttons is a button cleanup_buttons_img
  997.             item_list
  998.                 on_item "<F2=Begin>"            send request_begin
  999.                 on_item "<Alt+F2=Display only>" send display_only
  1000.                 on_item ESC_CLOSE_TEXT          send request_cancel
  1001.                 on_item F1_HELP_TEXT            send help
  1002.             end_item_list
  1003.  
  1004.             on_key key_alt+key_f2 send display_only private
  1005.             on_key ksave_record   send request_begin private
  1006.             on_key kcancel        send request_cancel private
  1007.         end_object
  1008.  
  1009. /cleanup_process_img
  1010. ╔═══════════════════════════════════════════════════════════════╗
  1011. ║                                                               ║
  1012. ║   Scanning ________    Validated: _____.    Deleted: _____.   ║
  1013. ║                                                               ║
  1014. ║                                                               ║
  1015. ║                                                               ║
  1016. ╚═══════════════════════════════════════════════════════════════╝
  1017. /cleanup_process_cancel_btn_img
  1018. ____________
  1019. /*
  1020.         object process is a client cleanup_process_img
  1021.             set popup_state to true
  1022.             set location    to 2 -1 relative
  1023.  
  1024.             object button is a button cleanup_process_cancel_btn_img
  1025.                 set location to 4 26 relative
  1026.  
  1027.                 item_list
  1028.                     on_item ESC_CANCEL_TEXT send none
  1029.                 end_item_list
  1030.  
  1031. /cleanup_interrupt_img
  1032. ╔═══════════════════════════════════════════════════════╗
  1033. ║                 Cleanup interrupted.                  ║
  1034. ║                                                       ║
  1035. ║             _____________     ___________             ║
  1036. ╚═══════════════════════════════════════════════════════╝
  1037. /*
  1038.  
  1039.                 object interrupt is a button cleanup_interrupt_img
  1040.                     set block_mouse_state to true
  1041.                     set location          to 0 -23 relative
  1042.                     set popup_state       to true
  1043.                     set scope_state       to true
  1044.  
  1045.                     item_list
  1046.                         on_item "<F2=Continue>" send ok
  1047.                         on_item "<Esc=Abort>"   send cancel
  1048.                     end_item_list
  1049.  
  1050.                     on_key ksave_record send ok
  1051.                     on_key kcancel      send cancel
  1052.                 end_object
  1053.  
  1054.                 function check_interrupt returns integer
  1055.                     local string trash
  1056.                     local integer wloc mloc ret_val
  1057.  
  1058.                     inkey trash
  1059.  
  1060.                     if (termchar eq kexit_application or ;
  1061.                         termchar eq kcancel or ;
  1062.                         termchar eq kmouse) begin
  1063.  
  1064.                         if (termchar eq kmouse) begin
  1065.                             get window_location item 1 to wloc
  1066.                             move (wloc + location(current_object)) to wloc
  1067.                             get absolute_mouse_location to mloc
  1068.                             if not (mloc >= wloc and mloc < (wloc + length(value(current_object,0)))) ;
  1069.                                 function_return 0
  1070.                         end
  1071.  
  1072.                         set kbd_input_mode to 1
  1073.                         set highlight_state to false
  1074.                         ui_accept (interrupt(current_object)) to ret_val
  1075.                         if ret_val ne msg_ok function_return 1
  1076.                         set highlight_state to true
  1077.                         set kbd_input_mode to 2
  1078.                     end
  1079.  
  1080.                     function_return 0
  1081.                 end_function
  1082.             end_object
  1083.  
  1084.             procedure start_process string rec_name
  1085.                 set value item 0 to rec_name
  1086.                 set value item 1 to 0
  1087.                 set value item 2 to 0
  1088.             end_procedure
  1089.  
  1090.             function scan integer itm returns integer
  1091.                 local integer ret_val obj
  1092.  
  1093.                 set value item (itm + 1) to (value(current_object,itm + 1) + 1)
  1094.                 get check_interrupt of (button(current_object)) to ret_val
  1095.                 function_return ret_val
  1096.             end_function
  1097.         end_object
  1098.  
  1099. /cleanup_display_list_img
  1100. ╔═══════════════════════════════════════════╗
  1101. ║___________________________________________║
  1102. ║                                           ║
  1103. ║                                           ║
  1104. ║                                           ║
  1105. ║                                           ║
  1106. ║                                           ║
  1107. ║                                           ║
  1108. ║                                           ║
  1109. ║                                           ║
  1110. ║                                           ║
  1111. ║                                           ║
  1112. ╚═══════════════════════════════════════════╝
  1113. /cleanup_display_list_btn_img
  1114.          _______         _________        
  1115. /*
  1116. //       <F2=OK>         <F1=Help>
  1117.  
  1118.         object display_list is a client cleanup_display_list_img
  1119.             set block_mouse_state   to true
  1120.             set location            to 0 8 relative
  1121.             set popup_state         to true
  1122.             set scope_state         to true
  1123.  
  1124.             set center_state item 0 to true
  1125.             set value        item 0 to "Records to be deleted"
  1126.  
  1127.             object button is a button cleanup_display_list_btn_img
  1128.                 set location to 11 1 relative
  1129.  
  1130.                 item_list
  1131.                     on_item F2_OK_TEXT   send request_ok
  1132.                     on_item F1_HELP_TEXT send help
  1133.                 end_item_list
  1134.  
  1135.                 on_key ksave_record send request_ok private
  1136.             end_object
  1137.  
  1138. // button before list places focus on button during default activate of client
  1139.  
  1140.             object list is a display_window
  1141.                 set size            to 8 42
  1142.                 set location        to 3 1 relative
  1143.                 set read_only_state to true
  1144.  
  1145.                 on_key ksave_record send request_ok private
  1146.  
  1147.                 procedure insert_line string txt
  1148.                     local string newline
  1149.  
  1150.                     set read_only_state to false
  1151.                     send insert txt
  1152.                     send process_key kenter
  1153.                     set read_only_state to true
  1154.                 end_procedure
  1155.             end_object
  1156.  
  1157.             procedure request_ok
  1158.                 send deactivate_area
  1159.                 send delete_data
  1160.                 delegate send restart
  1161.             end_procedure
  1162.  
  1163.             procedure delete_data
  1164.                 send delete_data to (list(current_object))
  1165.             end_procedure
  1166.  
  1167.             procedure release_focus
  1168.                 forward send release_focus
  1169.                 send delete_data
  1170.             end_procedure
  1171.  
  1172.             procedure show_del_grp string grp_name
  1173.                 local integer obj
  1174.  
  1175.                 move (list(current_object)) to obj
  1176.                 send insert_line to obj "DELETE GROUP:"
  1177.                 send insert_line to obj (trim(grp_name))
  1178.             end_procedure
  1179.  
  1180.             procedure show_del_sbj string sbj_name
  1181.                 local integer obj
  1182.  
  1183.                 move (list(current_object)) to obj
  1184.                 send insert_line to obj "DELETE SUBJECT:"
  1185.                 send insert_line to obj (trim(sbj_name))
  1186.             end_procedure
  1187.  
  1188.             procedure show_del_xrf string grp_name string sbj_name
  1189.                 local integer obj
  1190.  
  1191.                 move (list(current_object)) to obj
  1192.                 send insert_line to obj "DELETE LINK FOR:"
  1193.                 send insert_line to obj (trim(grp_name))
  1194.                 send insert_line to obj (trim(sbj_name))
  1195.             end_procedure
  1196.  
  1197.             procedure show_del_ctx string app_name string mod_name string hlp_name
  1198.                 local integer obj
  1199.  
  1200.                 move (list(current_object)) to obj
  1201.                 send insert_line to obj "DELETE CONTEXT:"
  1202.                 send insert_line to obj (trim(app_name))
  1203.                 send insert_line to obj (trim(mod_name))
  1204.                 send insert_line to obj (trim(hlp_name))
  1205.             end_procedure
  1206.         end_object // display_list
  1207.  
  1208. /cleanup_done_img
  1209. ╔═══════════════════════════════════════════════════════╗
  1210. ║                    Cleanup complete.                  ║
  1211. ║                                                       ║
  1212. ║                     ____    ______                    ║
  1213. ╚═══════════════════════════════════════════════════════╝
  1214. /*
  1215.         object done is a button cleanup_done_img
  1216.             set block_mouse_state to true
  1217.             set location          to 6 2 relative
  1218.             set popup_state       to true
  1219.             set scope_state       to true
  1220.  
  1221.             item_list
  1222.                 on_item "<OK>"   send request_cancel
  1223.                 on_item "<Help>" send help
  1224.             end_item_list
  1225.         end_object
  1226.  
  1227.         object sbj_text is an edit
  1228.             set focus_mode to no_activate
  1229.             set size to 1 56
  1230.         end_object
  1231.  
  1232.         procedure activating
  1233.             local integer obj
  1234.  
  1235.             move (options(current_object)) to obj
  1236.             set select_state of obj item 0 to true
  1237.             set select_state of obj item 1 to true
  1238.             set select_state of obj item 2 to false
  1239.             set select_state of obj item 3 to false
  1240.             forward send activating
  1241.         end_procedure
  1242.  
  1243.         procedure restart
  1244.             set kbd_input_mode to 1
  1245.             send deactivate to (process(current_object))
  1246.             send deactivate to (display_list(current_object))
  1247.         end_procedure
  1248.  
  1249.         procedure init_process integer live
  1250.             local integer obj
  1251.  
  1252.             if not live begin
  1253.                 set max_lines of (list(display_list(current_object))) to MAX_LINES_ALLOWED
  1254.                 send delete_data to (display_list(current_object))
  1255.                 send popup to (display_list(current_object))
  1256.             end
  1257.  
  1258.             move (process(current_object)) to obj
  1259.             send delete_data to obj
  1260.             send popup to obj
  1261.             set highlight_state of (button(obj)) to true
  1262.             set kbd_input_mode to 2
  1263.         end_procedure
  1264.  
  1265.         procedure process_complete integer live
  1266.             set kbd_input_mode to 1
  1267.             set highlight_state of (button(process(current_object))) to false
  1268.  
  1269.             if live send popup to (done(current_object))
  1270.             else begin
  1271.                 set max_lines of (list(display_list(current_object))) to (line_count(list(display_list(current_object))) + 1)
  1272.                 send deactivate to (process(current_object))
  1273.             end
  1274.         end_procedure
  1275.  
  1276.         procedure request_begin
  1277.             send request_cleanup true
  1278.         end_procedure
  1279.  
  1280.         procedure display_only
  1281.             send request_cleanup false
  1282.         end_procedure
  1283.  
  1284.         procedure request_cleanup integer live
  1285.             local integer rec opt disp wr_del
  1286.  
  1287.             move (options(current_object)) to opt
  1288.             move (display_list(current_object)) to disp
  1289.  
  1290.             send init_process live
  1291.  
  1292.             get select_state of opt item 4 to wr_del
  1293.  
  1294.             if (select_state(opt, 0)) begin
  1295.                 send start_process to (process(current_object)) "Links"
  1296.                 if (live and wr_del) direct_output (current_pth + current_xrf + DEL_EXT_TEXT)
  1297.  
  1298.                 clear xrf
  1299.                 find ge xrf by recnum
  1300.  
  1301.                 [found] repeat
  1302.                     if (scan(current_object,CLN_SCAN_TYPE)) begin
  1303.                         if (live and wr_del) close_output
  1304.                         send restart
  1305.                         procedure_return
  1306.                     end
  1307.     
  1308.                     clear grp
  1309.                     move xrf.grp_recnum to grp.recnum
  1310.                     find eq grp by recnum
  1311.  
  1312.                     [found] begin
  1313.                         clear sbj
  1314.                         move xrf.sbj_recnum to sbj.recnum
  1315.                         find eq sbj by recnum
  1316.                     end
  1317.  
  1318.                     [not found] begin
  1319.                         if live begin
  1320.                             if wr_del send write_del_xrf
  1321.  
  1322.                             move xrf.recnum to rec
  1323.                             indicate err false
  1324.  
  1325.                             reread xrf
  1326.                             [not err] delete xrf
  1327.                             unlock
  1328.     
  1329.                             clear xrf
  1330.                             move rec to xrf.recnum
  1331.                         end
  1332.                         else send show_del_xrf to disp xrf.grp_recnum xrf.sbj_recnum
  1333.  
  1334.                         if (scan(current_object,CLN_DEL_TYPE)) begin
  1335.                             if (live and wr_del) close_output
  1336.                             send restart
  1337.                             procedure_return
  1338.                         end
  1339.                     end
  1340.  
  1341.                     find gt xrf by recnum
  1342.                 [found] loop
  1343.             end
  1344.  
  1345.             if (select_state(opt, 1)) begin
  1346.                 send start_process to (process(current_object)) "Contexts"
  1347.                 if (live and wr_del) direct_output (current_pth + current_ctx + DEL_EXT_TEXT)
  1348.  
  1349.                 clear ctx
  1350.                 find ge ctx by recnum
  1351.  
  1352.                 [found] repeat
  1353.                     if (scan(current_object,CLN_SCAN_TYPE)) begin
  1354.                         if (live and wr_del) close_output
  1355.                         send restart
  1356.                         procedure_return
  1357.                     end
  1358.     
  1359.                     clear xrf
  1360.                     move ctx.xrf_recnum to xrf.recnum
  1361.                     find eq xrf by recnum
  1362.  
  1363.                     [not found] begin
  1364.                         if live begin
  1365.                             if wr_del send write_del_ctx
  1366.  
  1367.                             move ctx.recnum to rec
  1368.                             indicate err false
  1369.  
  1370.                             reread ctx
  1371.                             [not err] delete ctx
  1372.                             unlock
  1373.  
  1374.                             clear ctx
  1375.                             move rec to ctx.recnum
  1376.                         end
  1377.                         else send show_del_ctx to disp ctx.app_name ctx.mod_name ctx.hlp_name
  1378.  
  1379.                         if (scan(current_object,CLN_DEL_TYPE)) begin
  1380.                             if (live and wr_del) close_output
  1381.                             send restart
  1382.                             procedure_return
  1383.                         end
  1384.                     end
  1385.  
  1386.                     find gt ctx by recnum
  1387.                 [found] loop
  1388.             end
  1389.  
  1390.             if (select_state(opt, 2)) begin
  1391.                 send start_process to (process(current_object)) "Groups"
  1392.                 if (live and wr_del) direct_output (current_pth + current_grp + DEL_EXT_TEXT)
  1393.  
  1394.                 clear grp
  1395.                 find ge grp by recnum
  1396.  
  1397.                 [found] repeat
  1398.                     if (scan(current_object,CLN_SCAN_TYPE)) begin
  1399.                         if (live and wr_del) close_output
  1400.                         send restart
  1401.                         procedure_return
  1402.                     end
  1403.     
  1404.                     clear xrf
  1405.                     move grp.recnum to xrf.grp_recnum
  1406.                     find ge xrf.grp_recnum
  1407.                     [found] indicate found as xrf.grp_recnum eq grp.recnum
  1408.  
  1409.                     [not found] begin
  1410.                         if live begin
  1411.                             if wr_del send write_del_grp
  1412.                             move grp.recnum to rec
  1413.                             indicate err false
  1414.  
  1415.                             reread grp
  1416.                             [not err] delete grp
  1417.                             unlock
  1418.  
  1419.                             clear grp
  1420.                             move rec to grp.recnum
  1421.                         end
  1422.                         else send show_del_grp to disp grp.grp_name
  1423.  
  1424.                         if (scan(current_object,CLN_DEL_TYPE)) begin
  1425.                             if (live and wr_del) close_output
  1426.                             send restart
  1427.                             procedure_return
  1428.                         end
  1429.                     end
  1430.  
  1431.                     find gt grp by recnum
  1432.                 [found] loop
  1433.             end
  1434.  
  1435.             if (select_state(opt, 3)) begin
  1436.                 send start_process to (process(current_object)) "Subjects"
  1437.                 if (live and wr_del) direct_output (current_pth + current_sbj + DEL_EXT_TEXT)
  1438.  
  1439.                 clear sbj
  1440.                 find ge sbj by recnum
  1441.  
  1442.                 [found] repeat
  1443.                     if (scan(current_object,CLN_SCAN_TYPE)) begin
  1444.                         if (live and wr_del) close_output
  1445.                         send restart
  1446.                         procedure_return
  1447.                     end
  1448.     
  1449.                     clear xrf
  1450.                     move sbj.recnum to xrf.sbj_recnum
  1451.                     find ge xrf.sbj_recnum
  1452.                     [found] indicate found as xrf.sbj_recnum eq sbj.recnum
  1453.  
  1454.                     [not found] begin
  1455.                         if live begin
  1456.                             if wr_del send write_del_sbj
  1457.  
  1458.                             move sbj.recnum to rec
  1459.                             indicate err false
  1460.  
  1461.                             reread sbj
  1462.                             [not err] delete sbj
  1463.                             unlock
  1464.  
  1465.                             clear sbj
  1466.                             move rec to sbj.recnum
  1467.                         end
  1468.                         else send show_del_sbj to disp sbj.sbj_name
  1469.  
  1470.                         if (scan(current_object,CLN_DEL_TYPE)) begin
  1471.                             if (live and wr_del) close_output
  1472.                             send restart
  1473.                             procedure_return
  1474.                         end
  1475.                     end
  1476.  
  1477.                     find gt sbj by recnum
  1478.                 [found] loop
  1479.             end
  1480.  
  1481.             if (live and wr_del) close_output
  1482.             send process_complete live
  1483.         end_procedure
  1484.  
  1485.         procedure write_del_grp
  1486.             writeln grp.recnum
  1487.             writeln grp.grp_name
  1488.         end_procedure
  1489.  
  1490.         procedure write_del_sbj
  1491.             writeln sbj.recnum
  1492.             writeln sbj.sbj_name
  1493.             close_output
  1494.             send read_dbms to (sbj_text(current_object)) sbj.sbj_text
  1495.             send write to (sbj_text(current_object)) ;
  1496.                     (current_pth + current_ctx + DEL_EXT_TEXT) true // true=append
  1497.             append_output (current_pth + current_ctx + DEL_EXT_TEXT)
  1498.             writeln (character(255))
  1499.         end_procedure
  1500.  
  1501.         procedure write_del_xrf
  1502.             writeln xrf.recnum
  1503.             writeln xrf.grp_recnum
  1504.             writeln xrf.sbj_recnum
  1505.         end_procedure
  1506.  
  1507.         procedure write_del_ctx
  1508.             writeln ctx.recnum
  1509.             writeln ctx.app_name
  1510.             writeln ctx.mod_name
  1511.             writeln ctx.hlp_name
  1512.             writeln ctx.xrf_recnum
  1513.         end_procedure
  1514.  
  1515.         function scan integer itm returns integer
  1516.             function_return (scan(process(current_object),itm))
  1517.         end_function
  1518.  
  1519.         procedure request_cancel
  1520.             send deactivate_area
  1521.             send insert_cb SUCCESS_REPLY 0
  1522.         end_procedure
  1523.     end_object // cleanup
  1524.  
  1525.     send popup to cleanup
  1526.  
  1527. end
  1528.  
  1529. if cmd_option eq REORD_MAINT_OPTION begin
  1530.  
  1531. /reorder_img
  1532. ╔═════════════════════════════════════════════════════════════════════════╗
  1533. ║_________________________________________________________________________║
  1534. ║                                                                         ║
  1535. ║    This option will re-order all records in the Group and Subject       ║
  1536. ║    files, adjusting the related Link records.                           ║
  1537. ║                                                                         ║
  1538. ║                _______          ________           ______               ║
  1539. ║                                                                         ║
  1540. ╚═════════════════════════════════════════════════════════════════════════╝
  1541. /*
  1542. //               <Begin>          <Cancel>           <Help>
  1543. sub_page reorder_btns_img  from reorder_img 2 3 4
  1544.  
  1545.         object reorder is a client reorder_img
  1546.             set block_mouse_state to true
  1547.             set location          to 6 3 relative
  1548.             set popup_state       to true
  1549.             set scope_state       to true
  1550.  
  1551.             set center_state item 0 to true
  1552.             set value        item 0 to "Re-order Data"
  1553.  
  1554.             object buttons is a button reorder_btns_img
  1555.                 item_list
  1556.                         on_item "<Begin>"  send request_begin
  1557.                         on_item "<Cancel>" send request_cancel
  1558.                         on_item "<Help>"   send help
  1559.                 end_item_list
  1560.  
  1561.                 on_key kcancel send request_cancel
  1562.             end_object
  1563.  
  1564.             procedure request_begin
  1565.                 send deactivate_area
  1566.                 send reorder to reorder_process
  1567.             end_procedure
  1568.  
  1569.             procedure request_cancel
  1570.                 send deactivate_area
  1571.                 send insert_cb FAIL_REPLY 0
  1572.             end_procedure
  1573.         end_object
  1574.  
  1575. /reorder_process_img
  1576. ╔═══════════════════════════════════════════════════╗
  1577. ║                                                   ║
  1578. ║                   Re-ordering                     ║
  1579. ║                                                   ║
  1580. ║                                                   ║
  1581. ║                                                   ║
  1582. ║                                                   ║
  1583. ║                                                   ║
  1584. ╚═══════════════════════════════════════════════════╝
  1585. /reorder_process_display_img
  1586.        Groups:  _____       Subjects:  _____       
  1587. /reorder_process_cancel_btn_img
  1588. ____________
  1589. /*
  1590.  
  1591.         object reorder_process is a client reorder_process_img
  1592.             set popup_state to true
  1593.             set location    to 7 14 relative
  1594.             
  1595.             object display is a message reorder_process_display_img
  1596.                 set focus_mode   to nonfocusable
  1597.                 set location     to 4 1 relative
  1598.             end_object
  1599.  
  1600.             object button is a button reorder_process_cancel_btn_img
  1601.                 set location to 6 20 relative
  1602.  
  1603.                 item_list
  1604.                     on_item ESC_CANCEL_TEXT send none
  1605.                 end_item_list
  1606.  
  1607. /reorder_interrupt_img
  1608. ╔═══════════════════════════════════════════════════════╗
  1609. ║                Re-ordering interrupted.               ║
  1610. ║                                                       ║
  1611. ║             _____________     ___________             ║
  1612. ╚═══════════════════════════════════════════════════════╝
  1613. /*
  1614.  
  1615.                 object interrupt is a button reorder_interrupt_img
  1616.                     set block_mouse_state to true
  1617.                     set location          to 0 -23 relative
  1618.                     set popup_state       to true
  1619.                     set scope_state       to true
  1620.  
  1621.                     item_list
  1622.                         on_item "<F2=Continue>" send ok
  1623.                         on_item "<Esc=Abort>"   send cancel
  1624.                     end_item_list
  1625.  
  1626.                     on_key ksave_record send ok
  1627.                     on_key kcancel      send cancel
  1628.                 end_object
  1629.  
  1630.                 function check_interrupt returns integer
  1631.                     local string trash
  1632.                     local integer wloc mloc ret_val
  1633.  
  1634.                     inkey trash
  1635.  
  1636.                     if (termchar eq kexit_application or ;
  1637.                         termchar eq kcancel or ;
  1638.                         termchar eq kmouse) begin
  1639.  
  1640.                         if (termchar eq kmouse) begin
  1641.                             get window_location item 1 to wloc
  1642.                             move (wloc + location(current_object)) to wloc
  1643.                             get absolute_mouse_location to mloc
  1644.                             if not (mloc >= wloc and mloc < (wloc + length(value(current_object,0)))) ;
  1645.                                 function_return 0
  1646.                         end
  1647.  
  1648.                         set kbd_input_mode to 1
  1649.                         set highlight_state to false
  1650.                         ui_accept (interrupt(current_object)) to ret_val
  1651.                         if ret_val ne msg_ok function_return 1
  1652.                         set highlight_state to true
  1653.                         set kbd_input_mode to 2
  1654.                     end
  1655.  
  1656.                     function_return 0
  1657.                 end_function
  1658.             end_object // button
  1659.  
  1660. /reorder_done_img
  1661. ╔═══════════════════════════════════════════════════════╗
  1662. ║                 Re-ordering complete.                 ║
  1663. ║                                                       ║
  1664. ║                     ____    ______                    ║
  1665. ╚═══════════════════════════════════════════════════════╝
  1666. /*
  1667.  
  1668.             object done is a button reorder_done_img
  1669.                 set block_mouse_state to true
  1670.                 set location          to 5 -2 relative
  1671.                 set popup_state       to true
  1672.                 set scope_state       to true
  1673.  
  1674.                 item_list
  1675.                     on_item "<OK>"   send request_ok
  1676.                     on_item "<Help>" send help
  1677.                 end_item_list
  1678.  
  1679.                 procedure request_ok
  1680.                     send deactivate_area
  1681.                     delegate send deactivate_area
  1682.                 end_procedure
  1683.             end_object
  1684.  
  1685.             object sbj_text_a is an edit
  1686.                 set focus_mode to no_activate
  1687.                 set size       to 1 56
  1688.             end_object
  1689.  
  1690.             object sbj_text_b is an edit
  1691.                 set focus_mode to no_activate
  1692.                 set size       to 1 56
  1693.             end_object
  1694.  
  1695.             function scan integer itm returns integer
  1696.                 local integer ret_val obj
  1697.  
  1698.                 move (display(current_object)) to obj
  1699.                 set value of obj item itm to (value(obj,itm) + 1)
  1700.                 get check_interrupt of (button(current_object)) to ret_val
  1701.                 function_return ret_val
  1702.             end_function
  1703.  
  1704.             procedure reorder
  1705.                 local integer ret_val
  1706.  
  1707.                 send delete_data to (display(current_object))
  1708.                 send popup
  1709.                 set highlight_state of (button(current_object)) to true
  1710.                 set kbd_input_mode to 2
  1711.                 get reorder_grp to ret_val
  1712.                 if not ret_val get reorder_sbj to ret_val
  1713.  
  1714.                 set kbd_input_mode to 1
  1715.                 send insert_cb SUCCESS_REPLY 0
  1716.  
  1717.                 if not ret_val send popup to (done(current_object))
  1718.                 else send deactivate_area
  1719.             end_procedure
  1720.  
  1721.             function reorder_grp returns integer
  1722.                 local integer rec_a rec_b ret_val
  1723.  
  1724.                 clear grp
  1725.                 find ge grp.recnum
  1726.  
  1727.                 [found] begin
  1728.                     move grp.recnum to rec_a
  1729.                     clear grp
  1730.                     find ge grp.grp_name
  1731.                     [found] move grp.recnum to rec_b
  1732.                 end
  1733.  
  1734.                 [found] repeat
  1735.                     if rec_b ne rec_a send swap_grp rec_a rec_b
  1736.                     move rec_a to rec_b
  1737.  
  1738.                     clear grp
  1739.                     move rec_a to grp.recnum
  1740.                     find gt grp.recnum
  1741.  
  1742.                     [found] begin
  1743.                         move grp.recnum to rec_a
  1744.                         clear grp
  1745.                         move rec_b to grp.recnum
  1746.                         find eq grp.recnum
  1747.                         [found] find gt grp.grp_name
  1748.                         [found] move grp.recnum to rec_b
  1749.                     end
  1750.                     
  1751.                     get scan 0 to ret_val
  1752.                     if ret_val function_return ret_val
  1753.                 [found] loop
  1754.  
  1755.                 function_return 0
  1756.             end_function
  1757.  
  1758.             procedure swap_grp integer rec_a integer rec_b
  1759.                 local string temp_name_a temp_name_b
  1760.  
  1761.                 move grp.grp_name to temp_name_b  // assume rec_b is in the buffer
  1762.  
  1763.                 reread grp
  1764.                 delete grp                        // delete b
  1765.  
  1766.                 clear grp
  1767.                 move rec_a to grp.recnum
  1768.                 find eq grp.recnum                // refind a
  1769.  
  1770.                 move grp.grp_name to temp_name_a  // record data in a
  1771.  
  1772.                 move temp_name_b to grp.grp_name  // overwrite a data with b data
  1773.  
  1774.                 saverecord grp                    // save b in a's place
  1775.  
  1776.                 send adjust_grp grp.recnum -1     // de-assign current links for a
  1777.                 send adjust_grp rec_b grp.recnum  // assign old b links to new b
  1778.  
  1779.                 clear grp
  1780.                 move temp_name_a to grp.grp_name  // re-create a (probably in b's place)
  1781.                 saverecord grp
  1782.  
  1783.                 send adjust_grp -1 grp.recnum     // re-assign old a links to new a
  1784.                 unlock
  1785.             end_procedure
  1786.  
  1787.             procedure adjust_grp integer old_rec integer new_rec
  1788.                 repeat
  1789.                     clear xrf
  1790.                     move old_rec to xrf.grp_recnum
  1791.                     find ge xrf.grp_recnum
  1792.                     [found] indicate found as xrf.grp_recnum eq old_rec
  1793.  
  1794.                     [found] begin
  1795.                         reread xrf
  1796.                         move new_rec to xrf.grp_recnum
  1797.                         saverecord xrf
  1798.                         unlock
  1799.                     end
  1800.                 [found] loop
  1801.             end_procedure
  1802.  
  1803.             function reorder_sbj returns integer
  1804.                 local integer rec_a rec_b ret_val
  1805.  
  1806.                 clear sbj
  1807.                 find ge sbj.recnum
  1808.  
  1809.                 [found] begin
  1810.                     move sbj.recnum to rec_a
  1811.                     clear sbj
  1812.                     find ge sbj.sbj_name
  1813.                     [found] move sbj.recnum to rec_b
  1814.                 end
  1815.  
  1816.                 [found] repeat
  1817.                     if rec_b ne rec_a send swap_sbj rec_a rec_b
  1818.                     move rec_a to rec_b
  1819.  
  1820.                     clear sbj
  1821.                     move rec_a to sbj.recnum
  1822.                     find gt sbj.recnum
  1823.  
  1824.                     [found] begin
  1825.                         move sbj.recnum to rec_a
  1826.                         clear sbj
  1827.                         move rec_b to sbj.recnum
  1828.                         find eq sbj.recnum
  1829.                         [found] find gt sbj.sbj_name
  1830.                         [found] move sbj.recnum to rec_b
  1831.                     end
  1832.                     
  1833.                     get scan 1 to ret_val
  1834.                     if ret_val function_return ret_val
  1835.                 [found] loop
  1836.  
  1837.                 function_return 0
  1838.             end_function
  1839.  
  1840.             procedure swap_sbj integer rec_a integer rec_b
  1841.                 local string temp_name_a temp_name_b
  1842.  
  1843.                 move sbj.sbj_name to temp_name_b  // assume rec_b is in the buffer
  1844.                 send delete_data to (sbj_text_b(current_object))
  1845.                 send read_dbms to (sbj_text_b(current_object)) sbj.sbj_text
  1846.  
  1847.                 reread sbj
  1848.                 delete sbj                        // delete b
  1849.  
  1850.                 clear sbj
  1851.                 move rec_a to sbj.recnum
  1852.                 find eq sbj.recnum                // refind a
  1853.  
  1854.                 move sbj.sbj_name to temp_name_a  // record data in a
  1855.                 send delete_data to (sbj_text_a(current_object))
  1856.                 send read_dbms to (sbj_text_a(current_object)) sbj.sbj_text
  1857.  
  1858.                 move temp_name_b to sbj.sbj_name  // overwrite a data with b data
  1859.                 send write_dbms to (sbj_text_b(current_object)) sbj.sbj_text
  1860.  
  1861.                 saverecord sbj                    // save b in a's place
  1862.  
  1863.                 send adjust_sbj sbj.recnum -1     // de-assign current links for a
  1864.                 send adjust_sbj rec_b sbj.recnum  // assign old b links to new b
  1865.  
  1866.                 clear sbj
  1867.                 move temp_name_a to sbj.sbj_name  // re-create a (probably in b's place)
  1868.                 send write_dbms to (sbj_text_a(current_object)) sbj.sbj_text
  1869.                 saverecord sbj
  1870.  
  1871.                 send adjust_sbj -1 sbj.recnum     // re-assign old a links to new a
  1872.                 unlock
  1873.             end_procedure
  1874.  
  1875.             procedure adjust_sbj integer old_rec integer new_rec
  1876.                 repeat
  1877.                     clear xrf
  1878.                     move old_rec to xrf.sbj_recnum
  1879.                     find ge xrf.sbj_recnum
  1880.                     [found] indicate found as xrf.sbj_recnum eq old_rec
  1881.  
  1882.                     [found] begin
  1883.                         reread xrf
  1884.                         move new_rec to xrf.sbj_recnum
  1885.                         saverecord xrf
  1886.                         unlock
  1887.                     end
  1888.                 [found] loop
  1889.             end_procedure
  1890.         end_object
  1891.  
  1892.         send popup to reorder
  1893. end
  1894.  
  1895. on_key kexit_application send exit_program
  1896.  
  1897. //////////////////////////////////
  1898. ////////////////////////////////// main logic
  1899. //////////////////////////////////
  1900.  
  1901. start_ui
  1902.  
  1903. if cmd_option ne REORD_MAINT_OPTION send insert_cb SUCCESS_REPLY 0
  1904.  
  1905. abort
  1906.  
  1907.