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

  1. ;Object Editing System - v3.10
  2. ;Copyright (c) 1991 - Global Technologies Corporation
  3. ;ALL RIGHTS RESERVED
  4. #include "dbrief.h"
  5. (macro _explode_object_window
  6.     (
  7.         (int                object_buffer
  8.                             obj_buffer_search
  9.                             _bcol
  10.                             _ecol
  11.                             _blin
  12.                             _elin
  13.                             _parse
  14.                             obj_in_memory
  15.                             apx_program_buffer
  16.                             apx_start_buffer
  17.         )
  18.         (string            object_name
  19.                             object_file
  20.                             object_label
  21.                             current_buffer_name
  22.                             _object
  23.                             _file_extension
  24.                             apx_program_name
  25.         )
  26.         (global            object_name
  27.                             object_buffer
  28.                             obj_in_memory
  29.         )
  30.         (if (== dbr_auto_header 1)
  31.             (= dbr_auto_header 99)
  32.         )
  33.         (message "Searching for object...")
  34.         (drop_bookmark 0 "y")
  35.         (inq_names NULL _file_extension NULL)
  36.         (= _file_extension (upper (+ "." _file_extension)))
  37.         (if (inq_marked _blin _bcol _elin _ecol)
  38.             (if (== _blin _elin)
  39.                 (
  40.                     (raise_anchor)
  41.                     (move_abs _blin _bcol)
  42.                     (= _object (upper (ltrim (trim (read (+ (- _ecol _bcol) 1))))))
  43.                     (= object_name _object)
  44.                     (= _parse 1)
  45.                 )
  46.             ;else
  47.                 (
  48.                     (raise_anchor)
  49.                     (_display_popup_message "Improper block marked!" "" 1)
  50.                     (= _object "No Object")
  51.                     (= _parse 0)
  52.                 )
  53.             )
  54.         ;else
  55.             (
  56.                 (beginning_of_line)
  57.                 (= _object (upper (ltrim (trim (read)))))
  58.                 (= _parse 0)
  59.                 (if (search_string (+ (_comment_character 1) "*-\\>") _object NULL 1)
  60.                     (
  61.                         (= object_file (substr _object (search_string (+ (_comment_character 1) "*-\\>") _object NULL 1)))
  62.                         (= object_file (ltrim (substr object_file (+ (index object_file "->") 2))))
  63.                     )
  64.                 ;else
  65.                     (= object_file "")
  66.                 )
  67.                 (if (index _object (_comment_character 1))
  68.                     (= _object (trim (substr _object 1 (- (index _object (_comment_character 1)) 1))))
  69.                 )
  70.                 (if (== (substr _object 1 8) "#INCLUDE")
  71.                     (
  72.                         (= object_file _object)
  73.                         (= object_file (ltrim (trim (substr object_file 9))))
  74.                         (if (index object_file "\>")
  75.                             (
  76.                                 (= object_file (substr object_file 2))
  77.                                 (= object_file (substr object_file 1 (- (index object_file "\>") 1)))
  78.                             )
  79.                         ;else
  80.                             (if (index object_file "\"")
  81.                                 (
  82.                                     (= object_file (substr object_file 2))
  83.                                     (= object_file (substr object_file 1 (- (index object_file "\"") 1)))
  84.                                 )
  85.                             ;else
  86.                                 (= object_file (trim (substr object_file 1 (+ (index object_file ".") 3))))
  87.                             )
  88.                         )
  89.                         (= object_name object_file)
  90.                         (if (exist (+ (+ (inq_environment "INCLUDE") "\\") object_name))
  91.                             (= object_name (+ (+ (inq_environment "INCLUDE") "\\") object_name))
  92.                         )
  93.                         (= object_file object_name)
  94.                         (= _file_extension (substr object_name (+ (index object_name ".") 1)))
  95.                         (= _parse 1)
  96.                     )
  97.                 )
  98.                 (if (== (substr _object 1 5) "PLAY ")
  99.                     (
  100.                         (= object_file (ltrim (trim (substr _object 6))))
  101.                         (= object_name object_file)
  102.                         (if (exist (+ object_name ".SC"))
  103.                             (= _file_extension ".SC")
  104.                         ;else
  105.                             (= _file_extension "")
  106.                         )
  107.                         (= _parse 1)
  108.                     )
  109.                 )
  110.                 (if (== (substr _object 1 (strlen (_execute_command))) (upper (_execute_command)))
  111.                     (
  112.                         (= object_name (substr _object (+ (strlen (_execute_command)) 1)))
  113.                         (if (index object_name " WITH ")
  114.                             (= object_name (substr object_name 1 (- (index object_name " WITH ") 1)))
  115.                         )
  116.                         (= _parse 1)
  117.                     )
  118.                 )
  119.                 (if (&& (== (substr _object 1 8) "SET PROC")(index _object " TO "))
  120.                     (
  121.                         (= object_name (substr _object (+ (index _object "TO ") 3)))
  122.                         (= _parse 1)
  123.                     )
  124.                 )
  125.                 (if (&& (== (substr _object 1 8) "SET FORM")(index _object " TO "))
  126.                     (
  127.                         (= object_name (substr _object (+ (index _object "TO ") 3)))
  128.                         (= _file_extension ".FMT")
  129.                         (= _parse 1)
  130.                     )
  131.                 )
  132.                 (if (index _object "(")
  133.                     (
  134.                         (= object_name (substr _object 1 (- (index _object "(") 1)))
  135.                         (if (index object_name "=")
  136.                             (= object_name (ltrim (substr object_name (+ (index object_name "=") 1))))
  137.                         )
  138.                         (if (== (upper (substr object_name 1 4)) "STOR")
  139.                             (= object_name (ltrim (substr object_name (index object_name " "))))
  140.                         )
  141.                         (if (index object_name " ")
  142.                             (= _parse 0)
  143.                         ;else
  144.                             (= _parse 1)
  145.                         )
  146.                     )
  147.                 )
  148.             )
  149.         )
  150.         (= object_name (ltrim (trim object_name)))
  151.         (if (== _parse 1)
  152.             (
  153.                 (if (|| (exist object_name)(exist (+ object_name _file_extension)))
  154.                     (
  155.                         (if (! (index object_name (upper _file_extension)))
  156.                             (+= object_name _file_extension)
  157.                         )
  158.                         (inq_names NULL NULL current_buffer_name)
  159.                         (if (== object_name (upper current_buffer_name))
  160.                             (_display_popup_message "Can't explode an object with the same name as the current buffer!" "" 1)
  161.                         ;else
  162.                             (
  163.                                 (int msg_level)
  164.                                 (if (index object_name "\\")
  165.                                     (= object_label (substr object_name (+ (rindex object_name "\\") 1)))
  166.                                 ;else
  167.                                     (= object_label object_name)
  168.                                 )
  169.                                 (= msg_level (inq_msg_level))
  170.                                 (set_msg_level 3)
  171.                                 (= dbr_current_buffer (inq_buffer))
  172.                                 (= obj_in_memory (edit_file object_name))
  173.                                 (= temp_int (inq_buffer))
  174.                                 (if (inq_modified)
  175.                                     (write_buffer)
  176.                                 )
  177.                                 (if (&& (!= 0 temp_int)(!= dbr_current_buffer temp_int))
  178.                                     (delete_buffer temp_int)
  179.                                 )
  180.                                 (set_msg_level msg_level)
  181.                                 (set_buffer dbr_current_buffer)
  182.                                 (attach_buffer dbr_current_buffer)
  183.                                 (if (>= (version) 310)
  184.                                     (execute_macro "db_hide 4 _object_action")
  185.                                 )
  186.                                 (create_window 18 (_menu_lines 50) 76 2 (+ object_label ": Ctrl-O To Save and Close Object"))
  187.                                 (if (exist (+ (substr object_name 1 (- (index object_name ".") 1)) ".OBK"))
  188.                                     (del (+ (substr object_name 1 (- (index object_name ".") 1)) ".OBK"))
  189.                                 )
  190.                                 (= object_buffer (create_buffer (+ (substr object_label 1 (- (index object_label ".") 1)) ".OBK") (+ (substr object_name 1 (- (index object_name ".") 1)) ".OBK") 0))
  191.                                 (attach_buffer object_buffer)
  192.                                 (read_file object_name)
  193.                                 (top_of_buffer)
  194.                                 (write_buffer)
  195.                                 (use_local_keyboard _obk_smart)
  196.                                 (refresh)
  197.                                 (message "")
  198.                             )
  199.                         )
  200.                     )
  201.                 ;else
  202.                     (
  203.                         (= obj_buffer_search 1)
  204.                         (= dbr_current_buffer (inq_buffer))
  205.                         (if (&& (strlen object_file)(exist object_file))
  206.                             (
  207.                                 (= obj_in_memory (edit_file object_file))
  208.                                 (= temp_int (inq_buffer))
  209.                                 (set_buffer dbr_current_buffer)
  210.                                 (attach_buffer dbr_current_buffer)
  211.                                 (set_buffer temp_int)
  212.                             )
  213.                         ;else
  214.                             (
  215.                                 (= obj_in_memory 0)
  216.                                 (set_buffer dbr_current_buffer)
  217.                                 (attach_buffer dbr_current_buffer)
  218.                             )
  219.                         )
  220.                         (while obj_buffer_search
  221.                             (
  222.                                 (inq_names NULL NULL current_buffer_name)
  223.                                 (message "Searching %s..." (upper current_buffer_name))
  224.                                 (drop_bookmark 2 "y")
  225.                                 (top_of_buffer)
  226.                                 (if (search_fwd (+ (+ "<\\c" (+ (_beg_of_rout_scan) "*{ @}|{\\t@}")) (+ object_name "[{\\n}|{\\t@}|{ @}|{(}]")) 1 0)
  227.                                     (
  228.                                         (message "")
  229.                                         (= object_buffer (inq_buffer))
  230.                                         (= obj_buffer_search 0)
  231.                                         (beginning_of_line)
  232.                                         (drop_bookmark 1 "y")
  233.                                         (drop_anchor 4)
  234.                                         (if (search_fwd (+ "<" (_end_of_rout_syntax)) 1 0)
  235.                                             (
  236.                                                 (move_rel 1 0)
  237.                                                 (cut 0)
  238.                                                 (goto_bookmark 0)
  239.                                                 (+= object_name ".OBK")
  240.                                                 (if (>= (version) 310)
  241.                                                     (execute_macro "db_hide 4 _object_action")
  242.                                                 )
  243.                                                 (create_window 18 (_menu_lines 50) 76 2 (+ (substr object_name 1 (- (index object_name ".") 1)) ": Ctrl-O To Save and Close Object"))
  244.                                                 (if (exist object_name)
  245.                                                     (del object_name)
  246.                                                 )
  247.                                                 (edit_file object_name)
  248.                                                 (refresh)
  249.                                                 (paste)
  250.                                                 (delete_line)
  251.                                                 (top_of_buffer)
  252.                                                 (write_buffer)
  253.                                             )
  254.                                         ;else
  255.                                             (
  256.                                                 (raise_anchor)
  257.                                                 (_display_popup_message "Object has no %s statement!" (_end_of_rout_syntax) 1)
  258.                                             )
  259.                                         )
  260.                                     )
  261.                                 ;else
  262.                                     (
  263.                                         (goto_bookmark 2)
  264.                                         (set_buffer (next_buffer))
  265.                                         (if (== dbr_current_buffer (inq_buffer))
  266.                                             (if dbr_apx_file_id
  267.                                                 (
  268.                                                     (= obj_buffer_search 1)
  269.                                                     (= apx_start_buffer (inq_buffer))
  270.                                                     (set_buffer dbr_apx_file_id)
  271.                                                     (top_of_buffer)
  272.                                                     (while (&& (search_fwd ";" 1 0)(== obj_buffer_search 1))
  273.                                                         (
  274.                                                             (beginning_of_line)
  275.                                                             (= apx_program_name (read))
  276.                                                             (= apx_program_name (trim (substr apx_program_name 50)))
  277.                                                             (= obj_in_memory (edit_file apx_program_name))
  278.                                                             (= apx_program_buffer (inq_buffer))
  279.                                                             (inq_names NULL NULL current_buffer_name)
  280.                                                             (message "Searching %s..." (upper current_buffer_name))
  281.                                                             (drop_bookmark 2 "y")
  282.                                                             (top_of_buffer)
  283.                                                             (if (search_fwd (+ (+ "<\\c" (+ (_beg_of_rout_scan) "*{ @}|{\\t@}")) (+ object_name "[{\\n}|{\\t@}|{ @}|{(}]")) 1 0)
  284.                                                                 (
  285.                                                                     (message "")
  286.                                                                     (= object_buffer (inq_buffer))
  287.                                                                     (= obj_buffer_search 0)
  288.                                                                     (beginning_of_line)
  289.                                                                     (drop_bookmark 1 "y")
  290.                                                                     (drop_anchor 4)
  291.                                                                     (if (search_fwd (+ "<" (_end_of_rout_syntax)) 1 0)
  292.                                                                         (
  293.                                                                             (move_rel 1 0)
  294.                                                                             (cut 0)
  295.                                                                             (goto_bookmark 0)
  296.                                                                             (+= object_name ".OBK")
  297.                                                                             (if (>= (version) 310)
  298.                                                                                 (execute_macro "db_hide 4 _object_action")
  299.                                                                             )
  300.                                                                             (create_window 18 (_menu_lines 50) 76 2 (+ (substr object_name 1 (- (index object_name ".") 1)) ": Ctrl-O To Save and Close Object"))
  301.                                                                             (if (exist object_name)
  302.                                                                                 (del object_name)
  303.                                                                             )
  304.                                                                             (edit_file object_name)
  305.                                                                             (refresh)
  306.                                                                             (paste)
  307.                                                                             (delete_line)
  308.                                                                             (top_of_buffer)
  309.                                                                             (write_buffer)
  310.                                                                         )
  311.                                                                     ;else
  312.                                                                         (
  313.                                                                             (raise_anchor)
  314.                                                                             (_display_popup_message "Object has no %s statement!" (_end_of_rout_syntax) 1)
  315.                                                                         )
  316.                                                                     )
  317.                                                                 )
  318.                                                             ;else
  319.                                                                 (
  320.                                                                     (set_buffer dbr_apx_file_id)
  321.                                                                     (if (== obj_in_memory 2)
  322.                                                                         (delete_buffer apx_program_buffer)
  323.                                                                     )
  324.                                                                     (move_rel 1 0)
  325.                                                                 )
  326.                                                             )
  327.                                                         )
  328.                                                     )
  329.                                                     (if obj_buffer_search
  330.                                                         (
  331.                                                             (set_buffer apx_start_buffer)
  332.                                                             (attach_buffer apx_start_buffer)
  333.                                                             (_display_popup_message "%s object NOT found!" object_name 1)
  334.                                                             (= obj_buffer_search 0)
  335.                                                             (goto_bookmark 0)
  336.                                                         )
  337.                                                     )
  338.                                                 )
  339.                                             ;else
  340.                                                 (
  341.                                                     (_display_popup_message "%s object NOT found!" object_name 1)
  342.                                                     (= obj_buffer_search 0)
  343.                                                     (goto_bookmark 0)
  344.                                                 )
  345.                                             )
  346.                                         )
  347.                                     )
  348.                                 )
  349.                                 (message "")
  350.                             )
  351.                         )
  352.                     )
  353.                 )
  354.             )
  355.         ;else
  356.             (
  357.                 (_display_popup_message "No object call on this line!" "" 1)
  358.                 (goto_bookmark 0)
  359.             )
  360.         )
  361.         (if (== dbr_auto_header 99)
  362.             (= dbr_auto_header 1)
  363.         )
  364.     )
  365. )
  366. (macro _implode_object_window
  367.     (
  368.         (message "Replacing object changes...")
  369.         (if (>= (version) 310)
  370.             (execute_macro "db_show 4")
  371.         )
  372.         (if (index object_name ".OBK")
  373.             (
  374.                 (if (inq_modified)
  375.                     (write_buffer)
  376.                 )
  377.                 (delete_window)
  378.                 (delete_buffer (inq_buffer))
  379.                 (set_buffer object_buffer)
  380.                 (goto_bookmark 1)
  381.                 (read_file object_name)
  382.                 (write_buffer)
  383.                 (goto_bookmark 2)
  384.                 (if (== dbr_object_backup_flag 0)
  385.                     (del object_name)
  386.                 )
  387.                 (attach_buffer dbr_current_buffer)
  388.                 (message "Object changes to %s complete." (upper (substr object_name  1 (- (index object_name ".") 1))))
  389.             )
  390.         ;else
  391.             (
  392.                 (if (inq_modified)
  393.                     (write_buffer)
  394.                 )
  395.                 (output_file object_name)
  396.                 (insert " ")
  397.                 (move_rel 0 -1)
  398.                 (delete_char)
  399.                 (write_buffer)
  400.                 (use_local_keyboard _prg_smart)
  401.                 (delete_window)
  402.                 (set_buffer dbr_current_buffer)
  403.                 (attach_buffer dbr_current_buffer)
  404.                 (if (== dbr_object_backup_flag 0)
  405.                     (del (+ (substr object_name 1 (- (index object_name ".") 1)) ".OBK"))
  406.                 )
  407.                 (message "Object changes to %s complete." (upper object_name))
  408.             )
  409.         )
  410.         (if (== obj_in_memory 2)
  411.             (delete_buffer object_buffer)
  412.         )
  413.         (goto_bookmark 0)
  414.     )
  415. )
  416.