home *** CD-ROM | disk | FTP | other *** search
- ;dBRIEF Application Express - v3.10
- ;Copyright (c) 1990 - Global Technologies Corporation
- ;ALL RIGHTS RESERVED
- #include "dbrief.h"
- (macro apx
- (
- (int apx_menu_flag
- apx_temp_buffer
- )
- (if (== (inq_assignment "_implode_object_window" 1) "")
- (
- (message "Stand by...")
- (= apx_menu_flag 0)
- (while (!= apx_menu_flag 1)
- (
- (= apx_menu_flag 0)
- (_pick_menu (search_path (inq_environment dbr_mnu_path) "apx.mnu") "APX Menu" 42 12 75 02)
- (switch temp_str
- "NULL"
- (= apx_menu_flag 1)
- NULL
- (if (inq_macro (substr temp_str 1 (- (index temp_str " ")1)))
- (= apx_menu_flag (execute_macro temp_str))
- ;else
- (_display_popup_message "Error processing APX.MNU macro request!" "" 1)
- )
- )
- )
- )
- )
- ;else
- (_display_popup_message "APX system unavailable during object edit!" "" 1)
- )
- )
- )
- ;***
- ;* apx file operations macros
- ;***
- (macro _build_apx_file
- (
- (string file_name)
- (if (get_parm 0 file_name "APX File to Create [.apx-def]: ")
- (
- (if (strlen file_name)
- (
- (if (! (index (upper file_name) ".APX"))
- (= file_name (+ (substr file_name 1 (- (rindex file_name ".") 1)) ".APX"))
- )
- (if (exist file_name)
- (
- (_open_apx_file file_name)
- (returns 0)
- )
- ;else
- (if (_create_apx_file (upper file_name))
- (returns 0)
- )
- )
- )
- )
- )
- )
- )
- )
- (macro _create_apx_file
- (
- (int apx_temp_size
- apx_temp_buffer
- apx_return_value
- )
- (string apx_temp_name
- apx_file_spec
- apx_file_name
- apx_file_path
- )
- (get_parm 0 apx_file_name)
- (unregister_macro 6 "_call_first_packages")
- (unregister_macro 1 "_call_on_packages")
- (= apx_temp_buffer (inq_buffer))
- (if (!= dbr_apx_file_id 0)
- (
- (set_buffer dbr_apx_file_id)
- (if (inq_modified)
- (write_buffer)
- )
- (delete_buffer dbr_apx_file_id)
- (set_buffer apx_temp_buffer)
- (= dbr_apx_file_id 0)
- )
- )
- (= dbr_apx_file_id (create_buffer "APX File" apx_file_name 1))
- (if (get_parm 1 apx_file_spec (+ "File(s) to include in APX [*." (+ (_get_dialect_info dbr_dialect 3) " ok]: ")))
- (
- (= apx_file_path (substr apx_file_spec 1 (rindex apx_file_spec "\\")))
- (file_pattern apx_file_spec)
- (while (find_file apx_temp_name apx_temp_size)
- (
- (message "Adding %s to %s dictionary..." (upper apx_temp_name) "APX")
- (= apx_return_value (_create_apx_program 1 (upper (+ apx_file_path apx_temp_name))))
- )
- )
- (set_buffer dbr_apx_file_id)
- (write_buffer)
- )
- )
- (if (== 0 apx_return_value)
- (
- (delete_buffer dbr_apx_file_id)
- (_display_popup_message "Cannot create APX no matching files found!" "" 1)
- (= dbr_apx_file_id 0)
- )
- )
- (register_macro 6 "_call_first_packages")
- (register_macro 1 "_call_on_packages")
- (set_buffer apx_temp_buffer)
- (attach_buffer apx_temp_buffer)
- (return apx_return_value)
- )
- )
- (macro _open_apx_file
- (
- (string apx_file_name
- )
- (if (get_parm 0 apx_file_name "APX file [APX default]: ")
- (
- (= apx_file_name (upper apx_file_name))
- (if (! (index apx_file_name ".APX"))
- (if (index apx_file_name ".")
- (= apx_file_name (+ (substr apx_file_name 1 (- (index apx_file_name ".") 1)) ".APX"))
- ;else
- (= apx_file_name (+ apx_file_name ".APX"))
- )
- )
- (if (exist apx_file_name)
- (
- (= apx_file_name (upper apx_file_name))
- (= temp_int (inq_buffer))
- (if (!= dbr_apx_file_id 0)
- (
- (set_buffer dbr_apx_file_id)
- (if (inq_modified)
- (write_buffer)
- )
- (delete_buffer dbr_apx_file_id)
- (set_buffer temp_int)
- (= dbr_apx_file_id 0)
- )
- )
- (= dbr_apx_file_id (create_buffer "APX File" apx_file_name 1))
- (if (!= dbr_apx_file_id 0)
- (_display_popup_message "APX file %s is active." apx_file_name 0)
- ;else
- (
- (_display_popup_message "Unable to open %s!" apx_file_name 1)
- (= apx_file_name "")
- (= dbr_apx_file_id 0)
- )
- )
- )
- ;else
- (
- (_display_popup_message "APX file %s not found!" apx_file_name 1)
- (= apx_file_name "")
- (= dbr_apx_file_id 0)
- )
- )
- )
- )
- )
- )
- (macro _close_apx_file
- (
- (string apx_file_name
- )
- (= temp_int (inq_buffer))
- (if (!= dbr_apx_file_id 0)
- (
- (_display_popup_message "APX file %s closed." (_get_apx_file) 0)
- (set_buffer dbr_apx_file_id)
- (if (inq_modified)
- (write_buffer)
- )
- (delete_buffer dbr_apx_file_id)
- (set_buffer temp_int)
- (= apx_file_name "")
- (= dbr_apx_file_id 0)
- )
- ;else
- (_display_popup_message "APX file not open!" "" 1)
- )
- (return 0)
- )
- )
- (macro _display_apx_file
- (
- (if (!= dbr_apx_file_id 0)
- (_display_popup_message "APX application is %s." (_get_apx_file) 0)
- ;else
- (_display_popup_message "No APX application loaded." "" 0)
- )
- (return 0)
- )
- )
- ;***
- ;* apx program operations macros
- ;***
- (macro _create_apx_program
- (
- (int apx_temp_buffer
- apx_temporary_buffer
- apx_build_flag
- apx_return_value
- apx_in_memory
- )
- (string apx_program_name
- apx_full_name
- apx_program_description
- apx_format_string
- apx_t_date
- apx_t_time
- apx_num_lines
- apx_num_characters
- )
- (get_parm 0 apx_build_flag)
- (= apx_temp_buffer (inq_buffer))
- (if (!= dbr_apx_file_id 0)
- (
- (if (&& (! (get_parm 1 apx_program_name))(edit_file))
- (
- (inq_names apx_program_name NULL NULL)
- (delete_buffer (inq_buffer))
- )
- )
- (if (&& (strlen apx_program_name)(!= apx_program_name "NULL"))
- (
- (set_buffer dbr_apx_file_id)
- (top_of_buffer)
- (if (index apx_program_name "\\")
- (= apx_full_name apx_program_name)
- ;else
- (
- (getwd NULL apx_full_name)
- (+= apx_full_name (+ "\\" apx_program_name))
- )
- )
- (if (search_fwd apx_full_name 0 1)
- (_display_popup_message "File %s already in APX dictionary!" apx_program_name 1)
- ;else
- (
- (= apx_in_memory (edit_file apx_program_name))
- (inq_names NULL NULL apx_program_name)
- (= apx_temporary_buffer (inq_buffer))
- (if apx_build_flag
- (= apx_program_description (+ (_pad_right apx_program_name 13) "(no description)"))
- ;else
- (
- (get_parm 2 apx_program_description "Program desc: " 35)
- (if (== (strlen apx_program_description) 0)
- (= apx_program_description "(no description)")
- )
- )
- )
- (set_buffer dbr_apx_file_id)
- (if (&& (!= apx_in_memory 1) (== apx_build_flag 1))
- (delete_buffer apx_temporary_buffer)
- )
- (end_of_buffer)
- (search_back ";")
- (move_rel 1 0)
- (beginning_of_line)
- (sprintf apx_format_string "%s;%s|%s\n" (_pad_right apx_program_description 35) (upper (_pad_right apx_program_name 12)) (upper apx_full_name))
- (insert apx_format_string)
- (write_buffer)
- (= apx_return_value 1)
- (if (! apx_build_flag)
- (_display_popup_message "%s has been added to APX dictionary." (upper apx_program_name) 0)
- )
- )
- )
- )
- )
- )
- ;else
- (_display_popup_message "APX file not loaded!" "" 1)
- )
- (set_buffer apx_temp_buffer)
- (attach_buffer apx_temp_buffer)
- (return apx_return_value)
- )
- )
- (macro _delete_apx_program
- (
- (string apx_program_name
- dict_delete
- dict_delete_prompt
- file_delete
- file_delete_prompt
- )
- (if (!= dbr_apx_file_id 0)
- (
- (= apx_program_name (_apx_prg_menu " ─┘ to DELETE"))
- (if (&& (strlen apx_program_name)(!= apx_program_name "NULL"))
- (
- (= temp_int (inq_buffer))
- (set_buffer dbr_apx_file_id)
- (top_of_buffer)
- (beginning_of_line)
- (if (search_fwd apx_program_name 0 0)
- (
- (move_abs 0 37)
- (= apx_program_name (read))
- (= apx_program_name (trim (substr apx_program_name 1 12)))
- (= dict_delete "N")
- (sprintf dict_delete_prompt "Delete %s from %s, OK? [yN]: " (upper apx_program_name) (_get_apx_file))
- (= file_delete "N")
- (sprintf file_delete_prompt "Delete %s from disk? [yN]: " (upper apx_program_name))
- (get_parm 0 dict_delete dict_delete_prompt 1 "N")
- (get_parm 1 file_delete file_delete_prompt 1 "N")
- (if (== (upper dict_delete) "Y")
- (
- (delete_line)
- (write_buffer)
- )
- )
- (set_buffer temp_int)
- )
- )
- (if (== (upper file_delete) "Y")
- (del apx_program_name)
- )
- )
- )
- )
- ;else
- (_display_popup_message "APX file not loaded!" "" 1)
- )
- (return 0)
- )
- )
- (macro _select_apx_program
- (
- (if (== (inq_assignment "_implode_object_window" 1) "")
- (
- (string apx_program_name
- )
- (if (!= dbr_apx_file_id 0)
- (
- (= apx_program_name (_apx_prg_menu " Select File"))
- (if (!= apx_program_name "NULL")
- (
- (edit_file apx_program_name)
- (return 1)
- )
- )
- )
- ;else
- (_display_popup_message "APX file not loaded!" "" 1)
- )
- )
- ;else
- (_display_popup_message "APX system unavailable during object edit!" "" 1)
- )
- (return 0)
- )
- )
- (macro _modify_apx_program
- (
- (string apx_program_name
- apx_new_description
- )
- (if (!= dbr_apx_file_id 0)
- (
- (= apx_program_name (_apx_prg_menu " ─┘ to MODIFY"))
- (if (!= apx_program_name "NULL")
- (
- (if (get_parm 0 apx_new_description "Program desc: " 35)
- (
- (if (== (strlen apx_new_description) 0)
- (= apx_new_description "(no description)")
- )
- (= temp_int (inq_buffer))
- (set_buffer dbr_apx_file_id)
- (top_of_buffer)
- (search_fwd apx_program_name 0 1)
- (beginning_of_line)
- (drop_anchor)
- (move_rel 0 34)
- (cut)
- (insert (_pad_right apx_new_description 35))
- (write_buffer)
- (set_buffer temp_int)
- )
- )
- )
- )
- )
- ;else
- (_display_popup_message "APX file not loaded!" "" 1)
- )
- (return 0)
- )
- )
- (macro _apx_prg_menu
- (
- (int apx_menu_buffer
- apx_current_buffer
- apx_menu_lines
- )
- (string apx_menu_prompt
- apx_program_description
- )
- (get_parm 0 apx_menu_prompt)
- (= apx_current_buffer (inq_buffer)) ;save the buffer id of the current prg
- (save_position) ;save the current buffer's position
- (set_buffer dbr_apx_file_id) ;switch to the apx dictionary
- (top_of_buffer) ;start at the top of the data dictionary
- (= apx_menu_buffer (create_buffer "APX Menu" NULL 1))
- (= apx_menu_lines 0)
- (while (&& (search_fwd ";" 1 0)(! (inq_kbd_char)))
- (
- (beginning_of_line)
- (= apx_program_description (trim(read)))
- (sprintf apx_program_description "%s %s ..;%s|\n" (substr apx_program_description 1 35) (substr apx_program_description 37 12) (substr apx_program_description 50))
- (set_buffer apx_menu_buffer)
- (insert apx_program_description)
- (++ apx_menu_lines)
- (set_buffer dbr_apx_file_id)
- (move_rel 1 0)
- (move_abs 0 1)
- )
- )
- (keyboard_flush)
- (set_buffer apx_menu_buffer)
- (end_of_buffer)
- (delete_line)
- (top_of_buffer)
- (set_buffer apx_current_buffer)
- (restore_position)
- (= temp_str "NULL")
- (_pick_menu "" "" 20 (_menu_lines (+ apx_menu_lines 1)) 70 03 "_apx_prg_select" apx_menu_buffer (+ (+ (_get_apx_file) " ") apx_menu_prompt))
- (returns temp_str)
- )
- )
- (macro _apx_prg_select
- (
- (int apx_event_type
- menu_line
- )
- (get_parm 0 apx_event_type)
- (get_parm 1 temp_str)
- (= temp_str (substr temp_str 53))
- (switch apx_event_type
- 45 NULL
- 27
- (
- (= temp_str "NULL")
- (exit)
- )
- 13
- (
- (= temp_str (trim (substr temp_str 1 (- (index temp_str "|") 1))))
- (exit)
- )
- 02 NULL
- 03 NULL
- 00 NULL
- 01
- (
- (= temp_str (trim (substr temp_str 1 (- (index temp_str "|") 1))))
- (message "Pick - %s" temp_str)
- )
- )
- (return 1)
- )
- )
- ;***
- ;* apx scanner operations
- ;***
- (macro _scan_apx_programs_r
- (
- (if (!= dbr_apx_file_id 0)
- (return (_apx_scan_menu (+ "<" (_beg_of_rout_scan)) "Routines"))
- ;else
- (_display_popup_message "APX file not loaded!" "" 1)
- )
- )
- )
- (macro _scan_apx_programs_p
- (
- (if (!= dbr_apx_file_id 0)
- (return (_apx_scan_menu (+ "<" (_beg_of_proc_scan)) "Procedures"))
- ;else
- (_display_popup_message "APX file not loaded!" "" 1)
- )
- )
- )
- (macro _scan_apx_programs_f
- (
- (if (!= dbr_apx_file_id 0)
- (return (_apx_scan_menu (+ "<" (_beg_of_func_scan)) "Functions"))
- ;else
- (_display_popup_message "APX file not loaded!" "" 1)
- )
- )
- )
- (macro _scan_apx_programs_t
- (
- (if (!= dbr_apx_file_id 0)
- (return (_apx_scan_menu NULL))
- ;else
- (_display_popup_message "APX file not loaded!" "" 1)
- )
- )
- )
- (macro _apx_scan_menu
- (
- (extern _reg_exp
- )
- (int apx_scan_buffer
- apx_program_buffer
- apx_program_line
- apx_temp_line
- apx_temp_col
- apx_menu_lines
- apx_not_in_memory
- )
- (string apx_scan_line
- apx_program_description
- apx_program_name
- apx_current_file
- apx_routine_name
- apx_search_lbl
- apx_search_str
- )
- (if (get_parm 0 apx_search_str "Text to scan for: ")
- (
- (if (! (get_parm 1 apx_search_lbl))
- (= apx_search_lbl (upper apx_search_str))
- )
- (inq_names apx_current_file NULL NULL)
- (save_position) ;save the current buffer's position
- (top_of_buffer)
- (set_buffer dbr_apx_file_id) ;switch to the apx dictionary
- (top_of_buffer) ;start at the top of the data dictionary
- (= apx_scan_buffer (create_buffer "APX Scan" NULL 1))
- (= apx_menu_lines 0)
- (while (&& (search_fwd ";" 1 0)(! (inq_kbd_char)))
- (
- (beginning_of_line)
- (= apx_program_description (read))
- (sprintf temp_str "%s %s |JUMP LIN0||%s\n" (substr apx_program_description 1 35) (_pad_right (substr apx_program_description 37 12) 12) (trim (substr apx_program_description 50)))
- (= apx_program_name (trim (substr apx_program_description 50)))
- (set_buffer apx_scan_buffer)
- (insert temp_str)
- (++ apx_menu_lines)
- (= apx_not_in_memory (edit_file apx_program_name))
- (= apx_program_buffer (inq_buffer))
- (inq_position apx_temp_line apx_temp_col)
- (top_of_buffer)
- (while (&& (search_fwd apx_search_str _reg_exp 0)(! (inq_kbd_char)))
- (
- (beginning_of_line)
- (= apx_routine_name (trim (ltrim (read))))
- (if (strlen apx_routine_name)
- (
- (++ apx_menu_lines)
- (message "Scanning for %s [#%d]..." apx_search_lbl apx_menu_lines)
- (inq_position apx_program_line NULL)
- (sprintf apx_scan_line " ->%05d: %s |JUMP LINE||%s\n" apx_program_line (substr (_pad_right apx_routine_name 48) 1 48) apx_program_name)
- (set_buffer apx_scan_buffer)
- (insert apx_scan_line)
- (set_buffer apx_program_buffer)
- )
- )
- (move_rel 1 0)
- (move_abs 0 1)
- )
- )
- (keyboard_flush)
- (set_buffer apx_program_buffer)
- (move_abs apx_temp_line apx_temp_col)
- (set_buffer dbr_apx_file_id)
- (if (== apx_not_in_memory 2)
- (delete_buffer apx_program_buffer)
- )
- (move_rel 1 0)
- (move_abs 0 1)
- )
- )
- (keyboard_flush)
- (set_buffer apx_scan_buffer)
- (end_of_buffer)
- (delete_line)
- (top_of_buffer)
- (edit_file apx_current_file)
- (restore_position)
- (_pick_menu "" "" 20 (_menu_lines (+ apx_menu_lines 1)) 70 03 "_apx_scan_select" apx_scan_buffer (+ (+ "APX Scan: " (trim (substr apx_search_lbl 1 18))) " <Grey - to Print>"))
- (if (!= temp_str "NULL")
- (
- (= apx_program_name (trim (substr temp_str 72)))
- (= apx_program_line (atoi (substr temp_str 4 5)))
- (edit_file apx_program_name)
- (if (index temp_str "JUMP LINE")
- (goto_line apx_program_line)
- ;else
- (top_of_buffer)
- )
- (return 1)
- )
- ;else
- (return 0)
- )
- )
- )
- )
- )
- (macro _apx_scan_select
- (
- (int apx_event_type
- )
- (get_parm 0 apx_event_type)
- (get_parm 1 temp_str)
- (switch apx_event_type
- 27
- (
- (= temp_int 0)
- (= temp_str "NULL")
- (exit)
- )
- 45
- (
- (translate "\\|JUMP*>" "" 1 1 0)
- (top_of_buffer)
- (insert "APX Scan Print\n")
- (insert "--------------------------------------------------------------------------\n")
- (insert "Line# Source Line\n")
- (insert "----- -------------------------------------------------------------------\n\n")
- (end_of_buffer)
- (insert "\n\n")
- (top_of_buffer)
- (drop_anchor)
- (end_of_buffer)
- (print)
- (= temp_int 0)
- (= temp_str "NULL")
- (exit)
- )
- 13
- (exit)
- 00 NULL
- 01
- (
- (if (index temp_str "JUMP LINE")
- (message "Jump to %s" (substr temp_str 3 35))
- ;else
- (message "Jump to line 1, %s" (trim (upper (substr temp_str 72))))
- )
- )
- )
- (return 1)
- )
- )
- (macro _get_apx_file
- (
- (int get_temp_buffer
- )
- (string apx_id_file
- )
- (= apx_id_file "No APX File")
- (if dbr_apx_file_id
- (
- (= get_temp_buffer (inq_buffer))
- (set_buffer dbr_apx_file_id)
- (inq_names apx_id_file NULL NULL)
- (if (rindex apx_id_file "\\")
- (= apx_id_file (substr apx_id_file (+ (rindex apx_id_file "\\") 1)))
- )
- (set_buffer get_temp_buffer)
- )
- )
- (returns (upper apx_id_file))
- )
- )