idlastro / Database Procedures: DBPRINT

[Source code]

NAME
DBPRINT
PURPOSE
Procedure to print specified items from a list of database entries
CALLING SEQUENCE
dbprint, list, [items, FORMS= , TEXTOUT= , /AdjustFormat, /NoHeader]  
INPUTS
list  - list of entry numbers to be printed, vector or scalar 
          if list = -1, then all entries will be printed.
          An error message is returned if any entry number is larger
          than the number of entries in the database
OPTIONAL INPUT-OUTPUT
items - items to be printed, specified in any of the following ways:
          form 1  scalar string giving item(s) as list of names
                  separated by commas
          form 2  string array giving list of item names
          form 3  string of form '$filename' giving name
                  of text file containing items (one item per
                  line)
          form 4  integer scalar giving single item number or
                    integer vector list of item numbers
          form 5  Null string specifying interactive selection.   This
                  is the default if 'items' is not supplied
          form 6  '*'     select all items, printout will be in
                  table format. 
       If items was undefined or a null string on input, then
       on output it will contain the items interactively selected.
OPTIONAL INPUT KEYWORDS
/ADJUSTFORMAT -  If set, then the format length for string items will
        be adjusted to the maximum length for the entries to be printed.
        This option will slow down DBPRINT because it requires the 
        string items be extracted and their maximum length determined 
        prior to any printing.   However, it enables the display of
        string items without any truncation or wasted space. 
FORMS - The number of printed lines per page. If forms is not 
        present, output assumed to be in PORTRAIT form, and 
        a heading and 47 lines are printed on each page, with
        a page eject between each page.  For LANDSCAPE form with
        headings on each page, and a page eject between pages, set 
        forms = 34.  For a heading only on the first page, and no
        page eject, set forms = 0.   This is the default for output
        to the terminal.
TEXTOUT - Integer (0-7) or string used to determine output device (see 
        TEXTOPEN for more info).  If not present, the !TEXTOUT system 
        variable is used.
        textout=0       Nowhere
        textout=1       if a TTY then TERMINAL using /more option
                            otherwise standard (Unit=-1) output
        textout=2       if a TTY then TERMINAL without /more option
                            otherwise standard (Unit=-1) output
        textout=3       dbprint.prt (file)
        textout=4       laser.tmp
        textout=5       user must open file
        textout=7      same as 3 but text is appended to .prt
        textout = filename   (default extension of .prt)
/NOHEADER - If this keyword is set, then the column headers will not
        be printed
EXAMPLE
The following example shows how a multiple valued item DATAMAX can be 
printed as separate columns.   In the WFPC2 target database, DATAMAX
is an item with 4 values, one for each of the 4 chips
IDL> dbopen,'wflog'
IDL> dbprint,list,'entry,datamax(0),datamax(1),datamax(2),datamax(3)'
SYSTEM VARIABLES
Output device controlled by non-standard system varaible !TEXTOUT, if 
TEXTOUT keyword is not used.    
NOTES
Users may want to adjust the default lines_per_page value given at
the beginning of the program for their own particular printer.
PROCEDURE CALLS
db_info(), db_item_info(), dbtitle(), dbxval(), textopen, textclose
zparcheck
HISTORY
version 2  D. Lindler  Nov. 1987 (new db format)
Test if user pressed 'Q' in response to /MORE W. Landsman  Sep 1991
Apply STRTRIM to free form (table) output    W. Landsman   Dec 1992
Test for string value of TEXTOUT         W. Landsman   Feb 1994
William Thompson, GSFC, 3 November 1994
                Modified to allow ZDBASE to be a path string.
W. Landsman, GSFC, July, 1997, Use CATCH to catch errors
Removed STRTRIM in table format output to handle byte values April 1999
Fixed occasional problem when /NOHEADER is supplied   Sep. 1999
Only byteswap when necessary for improved performance  Feb. 2000
Change loop index for table listing to type LONG  W. Landsman Aug 2000
Entry vector can be any integer type   W. Landsman Aug. 2001
Replace DATATYPE() with size(/TNAME)   W. Landsman  Nov. 2001
No page eject for TEXTOUT =5           W. Landsman  Nov. 2001
No initial page eject                  W. Landsman  Jan. 2002
Added AdjustFormat keyword             W. Landsman  Sep. 2002
Assume since V5.3 (STRJOIN)            W. Landsman Feb. 2004
Fix display on GUI terminals           W. Landsman March 2006
Remove VMS statements                  W. Landsman Sep 2006
Remove EXECUTE statement               W. Landsman Jan 2007
Fix display of multi element items     W. Landsman  Aug 2010
Fix problem with linked databases      W. Landsman Dec 2011