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

  1. ;dBRIEF Source  - v3.10
  2. ;Copyright (c) 1991 - Global Technologies Corporation
  3. ;ALL RIGHTS RESERVED
  4. #include "dbrief.h"
  5. (macro _print_source
  6.     (
  7.         (int            print_buffer
  8.                         _lines
  9.                         line_counter
  10.                         page_counter
  11.                         temp_counter
  12.                         _width
  13.         )
  14.         (string        _file
  15.                         _buff
  16.                         _txtfile
  17.                         _output_file
  18.                         _switch
  19.                         _graphics
  20.                         _indenting
  21.                         _print_temp_str
  22.                         _printer_setup
  23.                         _spool
  24.                         previous_tab_setting
  25.         )
  26.         (= previous_tab_setting (use_tab_char "n"))
  27.         (= curr_indent_col 1)
  28.         (inq_names _file NULL _buff)
  29.         (if (! (get_parm 0 _file "File name to print: " NULL _file))
  30.             (return 0)
  31.         )
  32.         (set_msg_level 3)
  33.         (if (exist _file)
  34.             (edit_file _file)
  35.         ;else
  36.             (
  37.                 (_display_popup_message "%s not found!" (upper _file) 1)
  38.                 (return 0)
  39.             )
  40.         )
  41.         (set_msg_level 0)
  42.         (sprintf _print_temp_str "Printing %s - line #'s? [Yn]: " (upper _buff))
  43.         (if (! (get_parm 1 _switch _print_temp_str 1 "Y"))
  44.             (return 0)
  45.         )
  46.         (if (! (get_parm 2 _graphics "Conditional outlining? [yN]: " 1 "N"))
  47.             (return 0)
  48.         )
  49.         (if (! (get_parm 3 _indenting "Reindent? [yN]: " 1 "N"))
  50.             (return 0)
  51.         )
  52.         (= _width dbr_cols_page)
  53.         (if (! (get_parm 4 _width "Report width: " _width))
  54.             (return 0)
  55.         )
  56.         (= _printer_setup dbr_printer_setup)
  57.         (if (! (get_parm 5 _printer_setup "Printer setup string: " 32 _printer_setup))
  58.             (return 0)
  59.         )
  60.         (sprintf _print_temp_str "Print %s to file? [Yn]: " (upper _buff))
  61.         (if (! (get_parm 6 _txtfile _print_temp_str 1 "Y"))
  62.             (return 0)
  63.         )
  64.         (if (== (upper _txtfile) "Y")
  65.             (if (get_parm 7 _output_file "File name: " NULL (+ (substr (upper _file) 1 (- (index _file ".") 1)) ".PRN"))
  66.                 (message "")
  67.             ;else
  68.                 (return 0)
  69.             )
  70.         ;else
  71.             (if (! (get_parm 8 _spool "Spool to printer? [Yn]: " 1 "Y"))
  72.                 (return 0)
  73.             )
  74.         )
  75.         (save_position)
  76.         (= _switch (upper _switch))
  77.         (= dbr_current_buffer (inq_buffer))
  78.         (if (== (upper _txtfile) "Y")
  79.             (
  80.                 (if (exist _output_file)
  81.                     (del _output_file)
  82.                 )
  83.                 (= print_buffer (create_buffer "Print Source" _output_file))
  84.             )
  85.         ;else
  86.             (= print_buffer (create_buffer "Print Source" NULL 0))
  87.         )
  88.         (message "Printing, press any key to abort...")
  89.         (set_buffer print_buffer)
  90.         (if (!= (upper _spool) "Y")
  91.             (
  92.                 (if (>= (version) 310)
  93.                     (execute_macro "db_hide 1")
  94.                 )
  95.                 (create_window 30 20 74 3 "Printing, please wait...")
  96.                 (if (>= (version) 310)
  97.                     (execute_macro "db_show 1")
  98.                 )
  99.                 (attach_buffer print_buffer)
  100.             )
  101.         )
  102.         (set_buffer dbr_current_buffer)
  103.         (end_of_buffer)
  104.         (inq_position _lines NULL)
  105.         (top_of_buffer)
  106.         (= line_counter 0)
  107.         (= temp_counter 0)
  108.         (= page_counter 1)
  109.         (set_buffer print_buffer)
  110.         (_print_line _printer_setup _graphics _indenting _txtfile)
  111.         (_page_break _file page_counter _switch "N" "N" _txtfile _width)
  112.         (set_buffer dbr_current_buffer)
  113.         (while (&& (<= (++ line_counter) _lines)(! (inq_kbd_char)))
  114.             (
  115.                 (++ temp_counter)
  116.                 (move_abs line_counter 1)
  117.                 (= _print_temp_str (read))
  118.                 (set_buffer print_buffer)
  119.                 (if (== _switch "Y")
  120.                     (sprintf _print_temp_str "%-4d- %s" line_counter _print_temp_str)
  121.                 )
  122.                 (_print_line _print_temp_str _graphics _indenting _txtfile)
  123.                 (if (!= (upper _spool) "Y")
  124.                     (refresh)
  125.                 )
  126.                 (if (>= temp_counter dbr_lines_page)
  127.                     (
  128.                         (_print_line " \n" "N" "N" _txtfile)
  129.                         (++ page_counter)
  130.                         (_page_break _file page_counter _switch "N" "N" _txtfile _width)
  131.                         (= temp_counter 0)
  132.                     )
  133.                 )
  134.                 (set_buffer dbr_current_buffer)
  135.             )
  136.         )
  137.         (keyboard_flush)
  138.         (set_buffer print_buffer)
  139.         (_print_line " \n" "N" "N" _txtfile)
  140.         (if (== (upper _txtfile) "Y")
  141.             (write_buffer)
  142.         )
  143.         (set_buffer dbr_current_buffer)
  144.         (attach_buffer dbr_current_buffer)
  145.         (if (!= (upper _spool) "Y")
  146.             (delete_window)
  147.         )
  148.         (delete_buffer print_buffer)
  149.         (restore_position)
  150.         (if (== (upper _spool) "Y")
  151.             (
  152.                 (sprintf _print_temp_str "%s %s >&NUL" dbr_spooler _output_file)
  153.                 (dos _print_temp_str)
  154.                 (_display_popup_message "%s has been spooled." (upper _file) 0)
  155.             )
  156.         ;else
  157.             (_display_popup_message "Printing complete." "" 0)
  158.         )
  159.         (use_tab_char previous_tab_setting)
  160.     )
  161. )
  162. (macro _print_line
  163.     (
  164.         (string        _graphics
  165.                         _indenting
  166.                         _output
  167.                         _print_temp_str
  168.         )
  169.         (get_parm 0 _print_temp_str)
  170.         (get_parm 1 _graphics)
  171.         (get_parm 2 _indenting)
  172.         (get_parm 3 _output)
  173.         (if (|| (== (upper _graphics) "Y")(== (upper _indenting) "Y"))
  174.             (if (== (substr _print_temp_str 5 2) "- ")
  175.                 (_insert_graphics (substr _print_temp_str 1 6) (ltrim (trim (substr _print_temp_str 7))) _graphics)
  176.             ;else
  177.                 (_insert_graphics "" (ltrim (trim _print_temp_str)) _graphics)
  178.             )
  179.         ;else
  180.             (insert _print_temp_str)
  181.         )
  182.         (if (== (upper _output) "N")
  183.             (
  184.                 (move_rel -1 0)
  185.                 (drop_anchor)
  186.                 (end_of_line)
  187.                 (while (!= 0 (print))
  188.                     (
  189.                         (raise_anchor)
  190.                         (beginning_of_line)
  191.                         (drop_anchor)
  192.                         (end_of_line)
  193.                     )
  194.                 )
  195.                 (raise_anchor)
  196.                 (beginning_of_line)
  197.                 (move_rel 1 0)
  198.             )
  199.         )
  200.     )
  201. )
  202. (macro _page_break
  203.     (
  204.         (int            _page
  205.                         _width
  206.         )
  207.         (string        _name
  208.                         _line
  209.                         _graphics
  210.                         _indenting
  211.                         _output
  212.                         _print_temp_str
  213.         )
  214.         (get_parm 0 _name)
  215.         (get_parm 1 _page)
  216.         (get_parm 2 _line)
  217.         (get_parm 3 _graphics)
  218.         (get_parm 4 _indenting)
  219.         (get_parm 5 _output)
  220.         (get_parm 6 _width)
  221.         (sprintf _print_temp_str "Source Print - File: %s %s Page: %d\n" (upper _name) (_replicate " " (- (- _width (strlen _name)) 31)) _page)
  222.         (_print_line _print_temp_str _graphics _indenting _output)
  223.         (_print_line (+ (_replicate "-" _width) "\n") _graphics _indenting _output)
  224.         (if (== _line "Y")
  225.             (
  226.                 (_print_line "Line  Source\n" _graphics _indenting _output)
  227.                 (_print_line (+ "----- " (+ (_replicate "-" (- _width 6)) "\n")) _graphics _indenting _output)
  228.             )
  229.         ;else
  230.             (
  231.                 (_print_line "Source\n" _graphics _indenting _output)
  232.                 (_print_line (+ (_replicate "-" _width) "\n") _graphics _indenting _output)
  233.             )
  234.         )
  235.     )
  236. )
  237. 
  238.