home *** CD-ROM | disk | FTP | other *** search
/ Piper's Pit BBS/FTP: ibm 0040 - 0049 / ibm0040-0049 / ibm0040.tar / ibm0040 / DBRIEF.ZIP / SOURCE / LIBRARY.M < prev    next >
Encoding:
Text File  |  1991-03-21  |  6.8 KB  |  279 lines

  1. ;dBRIEF Library  - v3.10
  2. ;Copyright (c) 1991 - Global Technologies Corporation
  3. ;ALL RIGHTS RESERVED
  4. #include "dbrief.h"
  5. (macro _init
  6.     (
  7.         (int                lib_current_buffer
  8.         )
  9.         (= lib_current_buffer (inq_buffer))
  10.         (if library_buffer
  11.             (
  12.                 (delete_buffer library_buffer)
  13.                 (= library_buffer 0)
  14.             )
  15.         )
  16.         (if (exist dbr_library)
  17.             (= library_buffer (create_buffer "Library" dbr_library 1))
  18.         ;else
  19.             (
  20.                 (= library_buffer (create_buffer "Library" "library.src" 1))
  21.                 (set_buffer library_buffer)
  22.                 (insert "\n* eof\n")
  23.                 (set_buffer lib_current_buffer)
  24.             )
  25.         )
  26.     )
  27. )
  28. (macro _sv
  29.     (returns "")
  30. )
  31. (macro sv
  32.     (
  33.         (if (== (inq_assignment "_implode_object_window" 1) "")
  34.             (
  35.                 (string            note_
  36.                                     name_
  37.                 )
  38.                 (if (inq_marked)
  39.                     (
  40.                         (if (get_parm 0 note_ "Module description: ")
  41.                             (if (get_parm 1 name_ "Module name: ")
  42.                                 (_process_library_call note_ name_)
  43.                             )
  44.                         )
  45.                     )
  46.                 ;else
  47.                     (libr)
  48.                 )
  49.             )
  50.         ;else
  51.             (_display_popup_message "SourceView unavailable during object edit!" "" 1)
  52.         )
  53.     )
  54. )
  55. (macro libr
  56.     (
  57.         (int        program_line
  58.                     start_line
  59.                     end_line
  60.                     screen_lines
  61.                     lib_menu_buffer
  62.                     lib_current_buffer
  63.         )
  64.         (string  menu_line
  65.                     routine_desc
  66.                     routine_name
  67.         )
  68.         (= temp_int 0)
  69.         (= lib_current_buffer (inq_buffer))
  70.         (= lib_menu_buffer (create_buffer "SourceView" NULL 1))
  71.         (set_buffer library_buffer)
  72.         (top_of_buffer)
  73.         (message "Scanning for modules...")
  74.         (while (search_fwd "note-" 1 0)
  75.             (
  76.                 (= routine_desc (substr (read) 6))
  77.                 (move_abs 0 1)
  78.                 (move_rel 1 0)
  79.                 (= routine_name (substr (read) 3))
  80.                 (if (strlen routine_desc)
  81.                     (
  82.                         (++ temp_int)
  83.                         (message "Scanning for modules [#%d]..." temp_int)
  84.                         (inq_position program_line)
  85.                         (sprintf menu_line "%s  %s Line:%d         |;_r_goto \"%d\"\n" (_pad_right routine_desc 48) (_pad_right routine_name 16) program_line program_line)
  86.                         (set_buffer lib_menu_buffer)
  87.                         (insert menu_line)
  88.                         (set_buffer library_buffer)
  89.                     )
  90.                 )
  91.                 (move_rel 1 0)
  92.                 (move_abs 0 1)
  93.             )
  94.         )
  95.         (= temp_int 0)
  96.         (set_buffer lib_menu_buffer)
  97.         (end_of_buffer)
  98.         (delete_line)
  99.         (inq_position program_line)
  100.         (top_of_buffer)
  101.         (set_buffer lib_current_buffer)
  102.         (if (> program_line 1)
  103.             (
  104.                 (_pick_menu "" "" 10 (_menu_lines program_line) 76 03 "_dbr_library_goto" lib_menu_buffer (substr (+ "Library: " dbr_library) 1 48))
  105.                 (if temp_int
  106.                     (
  107.                         (set_buffer library_buffer)
  108.                         (goto_line (+ temp_int 1))
  109.                         (beginning_of_line)
  110.                         (inq_position start_line NULL)
  111.                         (search_fwd "{note-}|{\\* eof}" 1 0)
  112.                         (move_rel -1 0)
  113.                         (inq_position end_line NULL)
  114.                         (set_buffer lib_current_buffer)
  115.                         (inq_position NULL temp_int)
  116.                         (set_buffer library_buffer)
  117.                         (while (<= start_line end_line)
  118.                             (
  119.                                 (move_abs start_line 1)
  120.                                 (= temp_str (read))
  121.                                 (++ start_line)
  122.                                 (set_buffer lib_current_buffer)
  123.                                 (move_abs 0 temp_int)
  124.                                 (insert temp_str)
  125.                                 (set_buffer library_buffer)
  126.                             )
  127.                         )
  128.                         (set_buffer lib_current_buffer)
  129.                         (move_abs 0 temp_int)
  130.                     )
  131.                 )
  132.             )
  133.         ;else
  134.             (_display_popup_message "No library modules found in %s!" (upper dbr_library) 1)
  135.         )
  136.     )
  137. )
  138. (macro _dbr_library_goto
  139.     (
  140.         (int                lib_event_type
  141.         )
  142.         (string            lib_event_string
  143.         )
  144.         (get_parm 0 lib_event_type)
  145.         (get_parm 1 lib_event_string)
  146.         (switch lib_event_type
  147.             45        NULL
  148.             27
  149.                 (
  150.                     (= temp_int 0)
  151.                     (exit)
  152.                 )
  153.             13
  154.                 (
  155.                     (= temp_int (atoi (substr lib_event_string (+ (index lib_event_string ";") 10))))
  156.                     (exit)
  157.                 )
  158.             00        NULL
  159.             01
  160.                 (message "Paste: %s" (substr lib_event_string 1 30))
  161.         )
  162.         (return 1)
  163.     )
  164. )
  165. (macro _process_library_call
  166.     (
  167.         (int                lib_file_position
  168.                             lib_current_buffer
  169.                             start_line
  170.                             end_line
  171.         )
  172.         (string            lib_file_name
  173.                             lib_temp_str
  174.                             lib_temp_name
  175.                             note_
  176.                             name_
  177.         )
  178.         (if (&& (inq_marked) (== (inq_assignment "_implode_object_window" 1) ""))
  179.             (
  180.                 (if (get_parm 0 note_ "Module description: ")
  181.                     (if (get_parm 1 name_ "Module name: ")
  182.                         (
  183.                             (copy)
  184.                             (= lib_current_buffer (inq_buffer))
  185.                             (set_buffer library_buffer)
  186.                             (end_of_buffer)
  187.                             (search_back "\* eof" 1 0)
  188.                             (beginning_of_line)
  189.                             (sprintf lib_temp_str "note- %s\n" note_)
  190.                             (insert lib_temp_str)
  191.                             (sprintf lib_temp_str "* %s\n" name_)
  192.                             (insert lib_temp_str)
  193.                             (paste)
  194.                             (insert "\n")
  195.                             (write_buffer)
  196.                             (set_buffer lib_current_buffer)
  197.                         )
  198.                     )
  199.                 )
  200.             )
  201.         ;else
  202.             (
  203.                 (save_position)
  204.                 (beginning_of_line)
  205.                 (= lib_temp_str (read))
  206.                 (= temp_int (index lib_temp_str (ltrim (trim lib_temp_str))))
  207.                 (= lib_temp_str (ltrim (trim lib_temp_str)))
  208.                 (= lib_file_position (index (upper lib_temp_str) ".SRC"))
  209.                 (if lib_file_position
  210.                     (
  211.                         (= lib_file_name (trim (ltrim (substr lib_temp_str 1 (+ lib_file_position 3)))))
  212.                         (= lib_temp_str (trim (ltrim (substr lib_temp_str (+ lib_file_position 5) 24))))
  213.                         (= lib_temp_name dbr_library)
  214.                         (= dbr_library lib_file_name)
  215.                         (_init)
  216.                     )
  217.                 )
  218.                 (if (strlen lib_temp_str)
  219.                     (
  220.                         (= lib_current_buffer (inq_buffer))
  221.                         (set_buffer library_buffer)
  222.                         (top_of_buffer)
  223.                         (+= lib_temp_str "\n")
  224.                         (if (search_fwd (+ "* " lib_temp_str) 0 0)
  225.                             (
  226.                                 (beginning_of_line)
  227.                                 (move_rel 1 0)
  228.                                 (inq_position start_line NULL)
  229.                                 (search_fwd "{note-}|{\\* eof}" 1 0)
  230.                                 (move_rel -1 0)
  231.                                 (inq_position end_line NULL)
  232.                                 (set_buffer lib_current_buffer)
  233.                                 (beginning_of_line)
  234.                                 (delete_to_eol)
  235.                                 (set_buffer library_buffer)
  236.                                 (while (<= start_line end_line)
  237.                                     (
  238.                                         (move_abs start_line 1)
  239.                                         (= lib_temp_str (read))
  240.                                         (++ start_line)
  241.                                         (set_buffer lib_current_buffer)
  242.                                         (move_abs 0 temp_int)
  243.                                         (insert lib_temp_str)
  244.                                         (set_buffer library_buffer)
  245.                                     )
  246.                                 )
  247.                                 (set_buffer lib_current_buffer)
  248.                                 (move_abs 0 temp_int)
  249.                                 (restore_position 0)
  250.                             )
  251.                         ;else
  252.                             (
  253.                                 (if (index lib_temp_str " ")
  254.                                     (= lib_temp_str (substr lib_temp_str 1 (- (index lib_temp_str " ") 1)))
  255.                                 )
  256.                                 (_display_popup_message "Library module %s!" (+ (+ (trim (upper lib_temp_str)) " not found in ") (upper dbr_library)) 1)
  257.                                 (set_buffer lib_current_buffer)
  258.                                 (attach_buffer lib_current_buffer)
  259.                                 (restore_position)
  260.                             )
  261.                         )
  262.                     )
  263.                 ;else
  264.                     (
  265.                         (restore_position)
  266.                         (_complete_conditional)
  267.                     )
  268.                 )
  269.                 (if lib_file_position
  270.                     (
  271.                         (= dbr_library lib_temp_name)
  272.                         (_init)
  273.                     )
  274.                 )
  275.             )
  276.         )
  277.     )
  278. )
  279.