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

  1. ;dBRIEF Common - v3.10
  2. ;Copyright (c) 1990 - Global Technologies Corporation
  3. ;ALL RIGHTS RESERVED
  4. (macro _frame_component
  5.     (
  6.         (int                component_number
  7.                             frame_x
  8.                             frame_y
  9.                             line_number
  10.                             frame_column
  11.         )
  12.         (string            component_string
  13.                             frame_character
  14.         )
  15.         (get_parm 0 component_number)
  16.         (get_parm 1 frame_x)
  17.         (get_parm 2 frame_y)
  18.         (get_parm 3 frame_character)
  19.         (get_parm 4 line_number)
  20.         (get_parm 5 frame_column)
  21.         (switch component_number
  22.             1
  23.                 (sprintf component_string "@ %02d,%02d SAY        \"%s" frame_x frame_y frame_character)
  24.             2
  25.                 (sprintf component_string "%s\"\n" frame_character)
  26.             3
  27.                 (sprintf component_string "@ %02d,%02d SAY \"%s" frame_x frame_y frame_character)
  28.             4
  29.                 (sprintf component_string "@ ROW()+1,%02d SAY \"%s" frame_y frame_character)
  30.             5
  31.                 (sprintf component_string "%s\"\n" frame_character)
  32.         )
  33.         (return component_string)
  34.     )
  35. )
  36. (macro _continuation_character
  37.     (
  38.         (return ";")
  39.     )
  40. )
  41. (macro _comment_character
  42.     (
  43.         (int                comment_type
  44.         )
  45.         (get_parm 0 comment_type)
  46.         (switch comment_type
  47.             1
  48.                 (if (== dbr_dialect 12)
  49.                     (return "//")
  50.                 ;else
  51.                     (return "&&")
  52.                 )
  53.             2
  54.                 (return "NOTE")
  55.             3
  56.                 (if (== dbr_dialect 12)
  57.                     (return "//")
  58.                 ;else
  59.                     (return "*")
  60.                 )
  61.         )
  62.     )
  63. )
  64. (macro _beg_of_rout_scan
  65.     (
  66.         (return "{FUNC}|{PROC}|{{STAT}|{LOCA}*{FUNC}|{PROC}}|{\\* ROUTINE SECTION}")
  67.     )
  68. )
  69. (macro _beg_of_proc_scan
  70.     (
  71.         (return "{PROCEDURE}|{PROC}|{{STAT}|{LOCA}*{PROC}}|{\\* ROUTINE SECTION}")
  72.     )
  73. )
  74. (macro _beg_of_func_scan
  75.     (
  76.         (return "{FUNCTION}|{FUNC}|{{STAT}|{LOCA}*{FUNC}}|{\\* ROUTINE SECTION}")
  77.     )
  78. )
  79. (macro _end_of_rout_syntax
  80.     (
  81.         (return "RETURN")
  82.     )
  83. )
  84. (macro _execute_command
  85.     (
  86.         (return "DO ")
  87.     )
  88. )
  89. (macro _do_case_syntax
  90.     (
  91.         (int                do_case_command
  92.         )
  93.         (get_parm 0 do_case_command)
  94.         (switch do_case_command
  95.             0
  96.                 (return "DO C")
  97.             1
  98.                 (return "DO CASE")
  99.             2
  100.                 (return "CASE")
  101.             3
  102.                 (return (+ (_comment_character 3) " DO ..."))
  103.             4
  104.                 (return "OTHERWISE")
  105.             5
  106.                 (return "ENDCASE")
  107.         )
  108.     )
  109. )
  110. (macro _do_while_syntax
  111.     (
  112.         (int                do_while_command
  113.         )
  114.         (get_parm 0 do_while_command)
  115.         (switch do_while_command
  116.             0
  117.                 (return "DO W")
  118.             1
  119.                 (return "DO WHILE .T.")
  120.             2
  121.                 (return "ENDDO")
  122.         )
  123.     )
  124. )
  125. (macro memv
  126.     (
  127.         (int                beg_col
  128.         )
  129.         (string            type_code1
  130.                             type_code2
  131.                             field_name
  132.                             dos_line
  133.                             alias
  134.         )
  135.         (if (! (get_parm 0 temp_str "Equal, Store or Replace statements [Esr]: " 1 "E"))
  136.             (return 0)
  137.         )
  138.         (if (! (get_parm 1 alias "Alias name (optional):"))
  139.             (return 0)
  140.         )
  141.         (if (strlen alias)
  142.             (+= alias "->")
  143.         )
  144.         (= temp_str (upper temp_str))
  145.         (if (== temp_str "S")
  146.             (
  147.                 (= type_code1 "STORE")
  148.                 (= type_code2 "TO")
  149.             )
  150.         ;else
  151.             (
  152.                 (= type_code1 "REPLACE")
  153.                 (= type_code2 "WITH")
  154.             )
  155.         )
  156.         (inq_position NULL beg_col)
  157.         (while (get_parm 0 field_name "Enter field name, ESC to exit: " 9)
  158.             (if (!= (substr field_name 1 1) " ")
  159.                 (
  160.                     (if (== temp_str "E")
  161.                         (
  162.                             (if (strlen dbr_mem_trail)
  163.                                 (sprintf dos_line "%s = %s%s" (_pad_right (+ field_name dbr_mem_trail) 10) alias field_name)
  164.                             ;else
  165.                                 (sprintf dos_line "%s = %s%s" (_pad_right (+ dbr_mem_lead field_name) 10) alias field_name)
  166.                             )
  167.                         )
  168.                     ;else
  169.                         (
  170.                             (if (strlen dbr_mem_trail)
  171.                                 (sprintf dos_line "%s %s %s %s" type_code1 (+ alias (_pad_right field_name 10)) type_code2 (+ field_name dbr_mem_trail))
  172.                             ;else
  173.                                 (sprintf dos_line "%s %s %s %s" type_code1 (+ alias (_pad_right field_name 10)) type_code2 (+ dbr_mem_lead field_name))
  174.                             )
  175.                         )
  176.                     )
  177.                     (move_abs 0 beg_col)
  178.                     (insert (+ dos_line "\n"))
  179.                 )
  180.             )
  181.         )
  182.         (move_abs 0 beg_col)
  183.     )
  184. )
  185. (macro @
  186.     (
  187.         (int                xx
  188.                             yy
  189.         )
  190.         (string            say_spec
  191.                             stmt
  192.                             prompt_string
  193.         )
  194.         (if (get_parm 0 prompt_string "Starting line & column coordinates [x,y]: ")
  195.             (if (get_parm 1 stmt "SAY or GET [Sg]: " 1 "S")
  196.                 (
  197.                     (= xx (atoi (substr prompt_string 1 (- (index prompt_string ",") 1))))
  198.                     (= yy (atoi (substr prompt_string (+ (index prompt_string ",") 1))))
  199.                     (if (== (substr (upper stmt) 1 1) "S")
  200.                         (= stmt "SAY")
  201.                     ;else
  202.                         (= stmt "GET")
  203.                     )
  204.                     (inq_position NULL curr_indent_col)
  205.                     (sprintf prompt_string "ESC to quit  @ %d,%d %s " xx yy stmt)
  206.                     (while (get_parm 3 say_spec prompt_string)
  207.                         (
  208.                             (sprintf prompt_string "@ %0d,%0d %s %s\n" xx yy stmt say_spec)
  209.                             (move_abs 0 curr_indent_col)
  210.                             (insert prompt_string)
  211.                             (++ xx)
  212.                             (sprintf prompt_string "ESC to quit  @ %d,%d %s " xx yy stmt)
  213.                         )
  214.                     )
  215.                     (move_abs 0 curr_indent_col)
  216.                 )
  217.             )
  218.         )
  219.     )
  220. )
  221. (macro _cond_insert
  222.     (
  223.         (int                _cond_case
  224.                             _cond_indent_col
  225.                             _cond_tab_col
  226.         )
  227.         (string            _cond_command
  228.                             _cond_match
  229.         )
  230.         (get_parm 0 _cond_command)
  231.         (get_parm 1    _cond_match)
  232.         (get_parm 2 _cond_case)
  233.         (get_parm 3 _cond_indent_col)
  234.         (= _cond_tab_col (- dbr_comment_tab (+ _cond_indent_col (strlen _cond_command))))
  235.         (if dbr_orig_cond_comment
  236.             (
  237.                 (if _cond_tab_col
  238.                     (sprintf _cond_command "%s%s%s %s" _cond_command (_replicate " " _cond_tab_col) (_comment_character 1) _cond_match)
  239.                 ;else
  240.                     (sprintf _cond_command "%s%s%s %s" _cond_command (_replicate " " 2) (_comment_character 1) _cond_match)
  241.                 )
  242.                 (_case_insert _cond_command 1 0 _cond_case)
  243.             )
  244.         ;else
  245.             (_case_insert (+ _cond_command "\n") 1 0 _cond_case)
  246.         )
  247.     )
  248. )
  249. (macro _complete_conditional
  250.     (
  251.         (int                temp_line
  252.                             temp_col
  253.                             completion_line
  254.                             prev_indent_col
  255.                             character_case
  256.         )
  257.         (string            token
  258.                             matching_command
  259.                             orig_line
  260.                             _message
  261.         )
  262.         (save_position)
  263.         (search_back "<*\\c[~ \\t\\n]")
  264.         (down)
  265.         (inq_position completion_line prev_indent_col)
  266.         (= temp_col prev_indent_col)
  267.         (= orig_line "XX")
  268.         (while (&& (|| (! (index (_complete_cond_table) (upper (substr orig_line 1 2)))) (>= temp_col prev_indent_col))(!= temp_line 1))
  269.             (
  270.                 (up)
  271.                 (beginning_of_line)
  272.                 (inq_position temp_line NULL)
  273.                 (= orig_line (ltrim (read)))
  274.                 (beginning_of_line)
  275.                 (if (> (strlen orig_line) 0)
  276.                     (
  277.                         (search_back "<*\\c[~ \\t\\n]")
  278.                         (inq_position NULL temp_col)
  279.                     )
  280.                 ;else
  281.                     (= orig_line "XX")
  282.                 )
  283.             )
  284.         )
  285.         (= token (substr (upper orig_line) 1 4))
  286.         (if (<= (atoi (substr orig_line 1 1) 0) 95)
  287.             (= character_case 1)
  288.         )
  289.         (if (== (substr token 1 3) "IF ")
  290.             (= token (substr token 1 3))
  291.         )
  292.         (if (== dbr_dialect 12)
  293.             (if (&& (index "LOCA~STAT" token) (|| (index (upper orig_line) "FUNC")(index (upper orig_line) "PROC")))
  294.                 (if (index (upper orig_line) "FUNC")
  295.                     (= token "FUNC")
  296.                 ;else
  297.                     (= token "PROC")
  298.                 )
  299.             )
  300.         )
  301.         (move_abs temp_line 1)
  302.         (search_back "<*\\c[~ \\t\\n]")
  303.         (inq_position NULL curr_indent_col)
  304.         (move_abs completion_line curr_indent_col)
  305.         (= matching_command (_matching_conditional token))
  306.         (if (strlen matching_command)
  307.             (_cond_insert (_matching_conditional token) orig_line character_case curr_indent_col)
  308.         ;else
  309.             (
  310.                 (_case_insert "\n" 1 0)
  311.                 (= curr_indent_col prev_indent_col)
  312.                 (move_abs completion_line curr_indent_col)
  313.             )
  314.         )
  315.         (message "")
  316.     )
  317. )
  318. (macro _find_matching_endtext
  319.     (
  320.         (if (search_fwd "<{ @}|{\\t@}endt" 1 0)
  321.             (
  322.                 (beginning_of_line)
  323.                 (inq_position dbr_curr_line)
  324.                 (move_rel 1 0)
  325.                 (= dbr_text_flag 1)
  326.             )
  327.         ;else
  328.             (
  329.                 (sprintf temp_str "%d" dbr_curr_line)
  330.                 (_display_popup_message "ENDTEXT not found to match TEXT at line # %s!" temp_str 0)
  331.                 (push_back 65)
  332.             )
  333.         )
  334.     )
  335. )
  336. (macro _comment_conditionals
  337.     (
  338.         (int            cond_last_line
  339.                         cond_temp_buffer
  340.                         cond_stack_buffer
  341.                         cond_line_number
  342.                         cond_current_line
  343.         )
  344.         (string        cond_command_line
  345.                         cond_token
  346.                         cond_new_line
  347.                         cond_line_str
  348.         )
  349.         (= cond_temp_buffer (inq_buffer))
  350.         (save_position)
  351.         (= cond_stack_buffer (create_buffer "stack" NULL 1))
  352.         (set_buffer cond_temp_buffer)
  353.         (attach_buffer cond_temp_buffer)
  354.         (if (inq_marked cond_current_line NULL cond_last_line NULL)
  355.             (
  356.                 (raise_anchor)
  357.                 (-= cond_current_line 1)
  358.             )
  359.         ;else
  360.             (
  361.                 (end_of_buffer)
  362.                 (inq_position cond_last_line)
  363.                 (top_of_buffer)
  364.                 (inq_position cond_current_line)
  365.             )
  366.         )
  367.         (_uncomment_conditionals 0)
  368.         (while (&& (<= cond_current_line cond_last_line)(! (inq_kbd_char)))
  369.             (
  370.                 (message "Scanning line: %d" cond_current_line)
  371.                 (set_buffer cond_temp_buffer)
  372.                 (= cond_command_line (trim (read)))
  373.                 (= cond_token (substr (upper (ltrim cond_command_line)) 1 4))
  374.                 (if (== (substr cond_token 1 3) "IF ")
  375.                     (= cond_token "IF  ")
  376.                 )
  377.                 (if (&& (index (_dialect_table) (trim cond_token))(> (strlen (trim cond_token)) 0))
  378.                     (
  379.                         (if (index (_indenting_conditionals) cond_token)
  380.                             (
  381.                                 (inq_position cond_line_number NULL)
  382.                                 (sprintf cond_line_str " [line: %d]" cond_line_number)
  383.                                 (= cond_new_line cond_command_line)
  384.                                 (if dbr_comment_lines
  385.                                     (= cond_new_line (+ (+ (+ (_comment_character 1) " ") (ltrim cond_new_line)) (+ cond_line_str "\n")))
  386.                                 ;else
  387.                                     (= cond_new_line (+ (+ (_comment_character 1) " ") (+= (ltrim cond_new_line) "\n")))
  388.                                 )
  389.                                 (set_buffer cond_stack_buffer)
  390.                                 (top_of_buffer)
  391.                                 (beginning_of_line)
  392.                                 (insert cond_new_line)
  393.                             )
  394.                         ;else
  395.                             (if (index (_reseting_conditionals) cond_token)
  396.                                 (
  397.                                     (set_buffer cond_stack_buffer)
  398.                                     (top_of_buffer)
  399.                                     (= cond_new_line (read))
  400.                                     (+= cond_command_line (trim cond_new_line))
  401.                                 )
  402.                             ;else
  403.                                 (if (index (_outdenting_conditionals) cond_token)
  404.                                     (
  405.                                         (set_buffer cond_stack_buffer)
  406.                                         (top_of_buffer)
  407.                                         (= cond_new_line (read))
  408.                                         (+= cond_command_line (trim cond_new_line))
  409.                                         (delete_line)
  410.                                     )
  411.                                 )
  412.                             )
  413.                         )
  414.                         (set_buffer cond_temp_buffer)
  415.                         (delete_to_eol)
  416.                         (insert cond_command_line)
  417.                         (if (&& (search_string (_comment_character 1) cond_command_line) (!= dbr_comment_tab 0))
  418.                             (
  419.                                 (beginning_of_line)
  420.                                 (= temp_str (read))
  421.                                 (beginning_of_line)
  422.                                 (delete_to_eol)
  423.                                 (insert (trim (substr temp_str 1 (- (index temp_str (_comment_character 1)) 1))))
  424.                                 (if (<  (strlen (trim (substr temp_str 1 (- (index temp_str (_comment_character 1)) 1)))) (- dbr_comment_tab 1))
  425.                                     (move_abs 0 dbr_comment_tab)
  426.                                 ;else
  427.                                     (
  428.                                         (end_of_line)
  429.                                         (move_rel 0 2)
  430.                                     )
  431.                                 )
  432.                                 (insert (trim (substr temp_str (index temp_str (_comment_character 1)))))
  433.                             )
  434.                         )
  435.                     )
  436.                 )
  437.                 (move_abs (++ cond_current_line) 1)
  438.             )
  439.         )
  440.         (_display_popup_message "Commenting Complete." "" 0)
  441.         (message "")
  442.         (set_buffer cond_temp_buffer)
  443.         (attach_buffer cond_temp_buffer)
  444.         (refresh)
  445.         (restore_position)
  446.         (delete_buffer cond_stack_buffer)
  447.     )
  448. )
  449. (macro _structure
  450.     (
  451.         (int            structure_buffer
  452.         )
  453.         (string        _dbf_file
  454.                         _str_file
  455.                         _switch
  456.         )
  457.         (if (get_parm 1 _dbf_file "DBF file name: ")
  458.             (if (get_parm 2 _switch "Window, Buffer or Printer [wbp] " 1 "W")
  459.                 (
  460.                     (if (== (upper _switch) "T")
  461.                         (if (get_parm 3 _switch "Window, Buffer or Printer [wbp] " 1 "W")
  462.                             (= _switch (substr (upper _switch) 1 1))
  463.                         )
  464.                     )
  465.                     (= _switch (upper _switch))
  466.                     (= _str_file (_parse_child _dbf_file _str_file))
  467.                     (if (index _str_file ".")
  468.                         (= _str_file (+ (substr _str_file 1 (- (index _str_file ".") 1)) ".str"))
  469.                     ;else
  470.                         (
  471.                             (= _str_file (+ _str_file ".str"))
  472.                             (= _dbf_file (+ _dbf_file ".dbf"))
  473.                         )
  474.                     )
  475.                     (if (exist _dbf_file)
  476.                         (
  477.                             (message "Stand by...")
  478.                             (= temp_str (+ "dbrief " _dbf_file))
  479.                             (+= temp_str ">&")
  480.                             (+= temp_str _str_file)
  481.                             (dos temp_str)
  482.                             (= dbr_current_buffer (inq_buffer))
  483.                             (= structure_buffer (create_buffer "Structure" _str_file))
  484.                             (if (index "W~P" (upper _switch))
  485.                                 (
  486.                                     (message "Getting structure, please wait...")
  487.                                     (set_buffer structure_buffer)
  488.                                     (keyboard_push)
  489.                                     (if (>= (version) 310)
  490.                                         (execute_macro "db_hide 0 _pick_action")
  491.                                     )
  492.                                     (create_window 30 20 75 3 (+ (upper _dbf_file) ":   Esc"))
  493.                                     (if (>= (version) 310)
  494.                                         (execute_macro "db_show 0")
  495.                                     )
  496.                                     (attach_buffer structure_buffer)
  497.                                     (top_of_buffer)
  498.                                     (if (inq_modified)
  499.                                         (write_buffer)
  500.                                     )
  501.                                     (refresh)
  502.                                     (if (== (upper _switch) "P")
  503.                                         (
  504.                                             (message "Printing, please wait...")
  505.                                             (end_of_buffer)
  506.                                             (insert " \n")
  507.                                             (top_of_buffer)
  508.                                             (drop_anchor)
  509.                                             (end_of_buffer)
  510.                                             (print)
  511.                                             (top_of_buffer)
  512.                                         )
  513.                                     )
  514.                                     (assign_to_key "<Esc>" "exit")
  515.                                     (assign_to_key "<Up>" "up")
  516.                                     (assign_to_key "<Down>" "down")
  517.                                     (assign_to_key "<Home>" "top_of_buffer")
  518.                                     (assign_to_key "<End>" "end_of_buffer")
  519.                                     (assign_to_key "<PgUp>" "page_up")
  520.                                     (assign_to_key "<PgDn>" "page_down")
  521.                                     (message "")
  522.                                     (process)
  523.                                     (keyboard_pop)
  524.                                     (delete_window)
  525.                                     (delete_buffer structure_buffer)
  526.                                     (set_buffer dbr_current_buffer)
  527.                                     (attach_buffer dbr_current_buffer)
  528.                                     (if (&& (== dbr_delete_str 1)(exist _str_file))
  529.                                         (del _str_file)
  530.                                     )
  531.                                 )
  532.                             ;else
  533.                                 (
  534.                                     (set_buffer structure_buffer)
  535.                                     (attach_buffer structure_buffer)
  536.                                     (top_of_buffer)
  537.                                     (refresh)
  538.                                 )
  539.                             )
  540.                             (message "")
  541.                         )
  542.                     ;else
  543.                         (_display_popup_message "File %s not found!" (upper _dbf_file) 0)
  544.                     )
  545.                 )
  546.             )
  547.         )
  548.     )
  549. )
  550. (macro _generate_fields
  551.     (
  552.         (int            structure_buffer
  553.                         field_num
  554.                         field_len
  555.                         field_dec
  556.                         count
  557.                         max_count
  558.         )
  559.         (string        _dbf_file
  560.                         _str_file
  561.                         _psu_file
  562.                         _switch
  563.                         _operation
  564.                         field_name
  565.                         field_type
  566.         )
  567.         (get_parm 0 _dbf_file)
  568.         (get_parm 1 _switch)
  569.         (= _operation (upper (inq_called)))
  570.         (= _str_file (_parse_child _dbf_file _str_file))
  571.         (= _psu_file _str_file)
  572.         (if (index _str_file ".")
  573.             (= _str_file (+ (substr _str_file 1 (- (index _str_file ".") 1)) ".gen"))
  574.         ;else
  575.             (
  576.                 (= _str_file (+ _str_file ".gen"))
  577.                 (= _dbf_file (+ _dbf_file ".dbf"))
  578.             )
  579.         )
  580.         (if (exist _dbf_file)
  581.             (
  582.                 (message "Stand by...")
  583.                 (= temp_str (+ "dbrief " _dbf_file))
  584.                 (+= temp_str ">&")
  585.                 (+= temp_str _str_file)
  586.                 (dos temp_str)
  587.                 (= dbr_current_buffer (inq_buffer))
  588.                 (= structure_buffer (create_buffer (+ (upper _psu_file) ".DBF") _str_file))
  589.                 (if (exist _str_file)
  590.                     (del _str_file)
  591.                 )
  592.                 (set_buffer structure_buffer)
  593.                 (if (>= (version) 310)
  594.                     (execute_macro "db_hide 1")
  595.                 )
  596.                 (create_window 30 20 74 3 "\Generating, please wait...")
  597.                 (if (>= (version) 310)
  598.                     (execute_macro "db_show 1")
  599.                 )
  600.                 (attach_buffer structure_buffer)
  601.                 (end_of_buffer)
  602.                 (insert "\n***\n")
  603.                 (top_of_buffer)
  604.                 (= max_count 24)
  605.                 (= count 1)
  606.                 (while (<= (++ count) max_count)
  607.                     (insert "\n")
  608.                 )
  609.                 (save_position)
  610.                 (if (search_fwd "{SDU Error}|{SYS1107:}")
  611.                     (
  612.                         (restore_position)
  613.                         (delete_line)
  614.                         (delete_line)
  615.                         (delete_line)
  616.                         (delete_line)
  617.                         (_display_popup_message "Error processing %s!" (+ (upper _dbf_file) ".DBF") 1)
  618.                     )
  619.                 ;else
  620.                     (
  621.                         (restore_position)
  622.                         (delete_line)
  623.                         (delete_line)
  624.                         (delete_line)
  625.                         (delete_line)
  626.                         (message "Generating, press any key to abort...")
  627.                         (while (&& (!= (read 1) "\*")(! (inq_kbd_char)))
  628.                             (
  629.                                 (= field_num (atoi (read 5)))
  630.                                 (move_abs 0 8)
  631.                                 (if (& (inq_kbd_flags) 0x40)
  632.                                     (
  633.                                         (= _psu_file (upper _psu_file))
  634.                                         (= field_name (upper (read 10)))
  635.                                     )
  636.                                 ;else
  637.                                     (
  638.                                         (= _psu_file (lower _psu_file))
  639.                                         (= field_name (lower (read 10)))
  640.                                     )
  641.                                 )
  642.                                 (move_abs 0 20)
  643.                                 (= field_type (trim (read 9)))
  644.                                 (move_abs 0 32)
  645.                                 (= field_len (atoi (read 4)))
  646.                                 (if (== (upper field_type) "NUMERIC")
  647.                                     (
  648.                                         (move_abs 0 38)
  649.                                         (= field_dec (atoi (read 4)))
  650.                                     )
  651.                                 )
  652.                                 (switch _switch
  653.                                     "="
  654.                                         (if (strlen dbr_mem_trail)
  655.                                             (sprintf temp_str "%s = %s->%s" (_pad_right (+ (trim field_name) dbr_mem_trail) 12) _psu_file field_name)
  656.                                         ;else
  657.                                             (sprintf temp_str "%s = %s->%s" (_pad_right (+ dbr_mem_lead (trim field_name)) 12) _psu_file field_name)
  658.                                         )
  659.                                     "S"
  660.                                         (= temp_str (_structure_build "STORE " " TO " _psu_file field_name 1))
  661.                                     "R"
  662.                                         (= temp_str (_structure_build "REPLACE " " WITH " _psu_file field_name 1))
  663.                                     "I"
  664.                                         (
  665.                                             (switch (upper field_type)
  666.                                                 "LOGICAL"
  667.                                                     (= temp_str "STORE .F.                  ")
  668.                                                 "DATE"
  669.                                                     (= temp_str "STORE ctod(space(8))  ")
  670.                                                 "NUMERIC"
  671.                                                     (= temp_str "STORE 0                      ")
  672.                                                 NULL
  673.                                                     (
  674.                                                         (sprintf temp_str "STORE space(%d)" field_len)
  675.                                                         (sprintf temp_str (+ temp_str (substr "             " 1 (- 22 (strlen temp_str)))))
  676.                                                     )
  677.                                             )
  678.                                             (= temp_str (_structure_build "" (+ temp_str " TO ") _psu_file field_name 0))
  679.                                         )
  680.                                 )
  681.                                 (move_rel 2 0)
  682.                                 (beginning_of_line)
  683.                                 (save_position)
  684.                                 (move_abs field_num 1)
  685.                                 (if (== (upper field_type) "MEMO")
  686.                                     (
  687.                                         (insert (+ temp_str (_replicate " " 50)))
  688.                                         (if (> dbr_comment_tab 40)
  689.                                             (move_abs 0 dbr_comment_tab)
  690.                                         ;else
  691.                                             (move_abs 0 50)
  692.                                         )
  693.                                         (insert (+ (_comment_character 1) " Memo Field\n"))
  694.                                     )
  695.                                 ;else
  696.                                     (insert (+ temp_str "\n"))
  697.                                 )
  698.                                 (refresh)
  699.                                 (restore_position)
  700.                             )
  701.                         )
  702.                         (if (inq_kbd_char)
  703.                             (
  704.                                 (keyboard_flush)
  705.                                 (_display_popup_message "%s operation aborted!" _operation 1)
  706.                             )
  707.                         ;else
  708.                             (
  709.                                 (move_abs (+ field_num 1) 1)
  710.                                 (drop_anchor)
  711.                                 (end_of_buffer)
  712.                                 (delete_block)
  713.                                 (top_of_buffer)
  714.                                 (get_parm 2 temp_str "Insert or Abandon [Ia]: " 1 "I")
  715.                             )
  716.                         )
  717.                     )
  718.                 )
  719.                 (if (== (upper temp_str) "I")
  720.                     (
  721.                         (drop_anchor)
  722.                         (end_of_buffer)
  723.                         (move_abs 0 128)
  724.                         (copy)
  725.                         (raise_anchor)
  726.                     )
  727.                 )
  728.                 (delete_window)
  729.                 (delete_buffer structure_buffer)
  730.                 (set_buffer dbr_current_buffer)
  731.                 (attach_buffer dbr_current_buffer)
  732.                 (del _str_file)
  733.                 (if (== (upper temp_str) "I")
  734.                     (
  735.                         (save_position)
  736.                         (beginning_of_line)
  737.                         (insert "\n")
  738.                         (restore_position)
  739.                         (save_position)
  740.                         (drop_anchor)
  741.                         (paste)
  742.                         (rein 0)
  743.                         (restore_position)
  744.                     )
  745.                 )
  746.             )
  747.         ;else
  748.             (_display_popup_message "File %s not found!" (upper _dbf_file) 1)
  749.         )
  750.     )
  751. )
  752. (macro _structure_build
  753.     (
  754.         (string            cmd_1
  755.                             cmd_2
  756.                             d_name
  757.                             f_name
  758.                             t_string
  759.         )
  760.         (int                flag_2
  761.         )
  762.         (get_parm 0 cmd_1)
  763.         (get_parm 1 cmd_2)
  764.         (get_parm 2 d_name)
  765.         (get_parm 3 f_name)
  766.         (get_parm 4 flag_2)
  767.         (if (& (inq_kbd_flags) 0x40)
  768.             (
  769.                 (= cmd_1 (upper cmd_1))
  770.                 (= cmd_2 (upper cmd_2))
  771.                 (= d_name (upper d_name))
  772.                 (= f_name (upper f_name))
  773.             )
  774.         ;else
  775.             (
  776.                 (= cmd_1 (lower cmd_1))
  777.                 (= cmd_2 (lower cmd_2))
  778.                 (= d_name (lower d_name))
  779.                 (= f_name (lower f_name))
  780.             )
  781.         )
  782.         (if flag_2
  783.             (= t_string (+ cmd_1 (+ (+ d_name "->") f_name)))
  784.         )
  785.         (if (strlen dbr_mem_trail)
  786.             (+= t_string (+ (+ cmd_2 (trim (substr f_name 1 9))) dbr_mem_trail))
  787.         ;else
  788.             (+= t_string (+ (+ cmd_2 dbr_mem_lead) (substr f_name 1 9)))
  789.         )
  790.         (return t_string)
  791.     )
  792. )
  793. (macro writ
  794.     (
  795.         (string            _cmd_line
  796.         )
  797.         (if (inq_marked)
  798.             (if (get_parm 0 _cmd_line "Procedure or Function? [pF]: " 1 "F")
  799.                 (switch (upper (substr _cmd_line 1 1))
  800.                     "P"
  801.                         (_create_routine_from_block "Procedure" (_end_of_rout_syntax) "prochead.cfg" (substr (_beg_of_proc_scan) 2 4))
  802.                     "F"
  803.                         (_create_routine_from_block "Function" (+ (_end_of_rout_syntax) "()") "funchead.cfg" (substr (_beg_of_func_scan) 2 4))
  804.                 )
  805.             )
  806.         ;else
  807.             (_display_popup_message "No marked block for Function Writer!" "" 1)
  808.         )
  809.     )
  810. )
  811.