Dpr - Display/print D-files.

[ English | Japanese ]

[visit D-home]

SYNOPSIS

Dpr [ options ] [ -p field-format-list ] [ -P printer ] [ input-file.. ]

DESCRIPTION

Dpr prints D-file to the terminal or a printer. Currently, it supports only line-column type devices.

It makes a table-format print out of a D-file. A record is arranged in a row with its fields aligned in columns. When a field value is too long to be printed in a line, it is just truncated at the right margin of the page. A field is never folded into multiple lines.

An output format may be specified for a field. Of the output format specification (see the manual of D_fmt), only options l, r and cfmt of the output format is valid. Other format specifications are ignored. Output format is specified by -f option or -p option. The -f option provides format only. Fields not listed in -f option are printed in the default format. The -p option limits the field to be printed, and provides the order of fields as well as to provide the format.

Repeating fields (same name fields in a record) are arranged in a vertical box, each line of the box contains an individual field. When the repeat count (number of same name fields) exceeds the maximum number of lines in a page, rest of the fields is just discarded. A record never goes across the page boundary.

When the table becomes too wide for the page, Dpr makes a layered page. A page is divided into two or more layers, and a record is printed across these layers. To help to identify same record, the record number (starts from 1) is shown at the top column of each layer. Arbitrary fields may be used instead of the record number with -i option.

Page size may be given by -x and -y options. But, if the output is tty, they are taken from the window size. When the output is a printer, -x and -y dimensions are taken from the environment variable Dprintcap. You have to set value to the environment correctly to use -P option. (See PRINTER OUTPUT section). When the output is redirected (to a file), predefined values (80 columns by 40 rows) are used.

Title line shows the input file name, date and time (of Dpr execution) and the page number. This is not displayed when the input file is standard input. You can give the header title(s) by the -h option(s). These titles are used in the header instead of the input file name. Multiple -h options are printed as multiple line header, as the first option in the first line, etc.

When -g option is given, Dpr makes page change each time it encounters the value of given fields is changed. This value is printed as the last line of header, and the fields are removed from the page body (unless they are listed in -p option).

By default Dpr writes the result to the standard output, and when it is terminal, it uses more to provide page view. Page view program can be changed by PAGER environment variable.

When -P option is given, Dpr writes the result to the printer. For printer output, an environment variable Dprintcap is mandatory. See PRINTER OUTPUT section below.

Control characters in ASCII are represented in caret form; for example TAB is represnted by "^I". Other control characters are shown in "<xx>" form, where xx is hexadecimal value of the code. Characters not represented in the current locale code are printed as QUESTION MARK (?).

OPTIONS

-f field-format-list
gives the output formats for the fields.
-g key-field-list
group by fields; these field values are printed at the last line of the header. Page change is made each time the value of these fields is changed
-h header-title
gives the header. There may be two or more -h options. In this case the first -h header-title comes to the first header line, and second one comes to the second line, and so on.
-i field-list
gives the identification fields. These fields are printed at the top columns instead of rec#. When a page is layered, identification fields are repeated in the top of each layer. The value of identification fields is expected to be unique for readability, but is not necessarily be.
-k key-flags
default key-flags for the -g key-field-list. Note that this default value has effect only for the fields which have no key-flags in the list. See the manual of Dintro.
-n
when this option is given, end of page is controlled only by new line functions. Otherwise, end of page is controlled by form-feed control character. This option is line-column device specific.
-p field-format-list
gives the field names, their order and formats to be printed.
-P printer
gives the printer name to be printed. If this option is not given, standard output is used.
-T directory
(Windows only) gives the directory name to store temporary file for printing. (Thus used with -P). When this options is not given, Dpr tries TEMP environment if any, and then "c:\temp" and "." (current directory). You need this option only when above directories are not available (for example you are running windows on a CD-ROM).
-x page-width
in the line-column device, gives the columns in a page. When this option is not given, the value is taken from the window size (terminal output), from Dprintcap environment (printer output) or from the predefined value 80 (output redirection).
-y page-hight
in the line-column device, gives the rows (lines) in a page. When this option is not given, the value is taken from the window size (terminal output), from Dprintcap environment (printer output) or from the predefined value 40 (output redirection).
-z default-options
gives the default options (lr) for -f and -p field-lists. Default value is none.
-D idatautf=8|16|32
UTF I/O feature (see manual page of UTF I/O feature.) Output is always in the locale code.

ENVIRONMENTS

Dprintcap
This environment variable is mandatory for -P option. It keeps the formated information for printers. See PRINTER OUTPUT section below for the detail.
PAGER
gives the program name to use for page view on the terminal output. When this variables is not defined, Dpr uses more.
TEMP
This option is only for Windows. In Windows, Dpr makes a temporary file and this temporary file is put under this directory when -T option is not given.
Didatautf
for UTF I/O feature. Output is always in the locale code.

PRINTER OUTPUT

Dpr makes a temporal text file and send it to a printer using a command (through pipe in UNIX). You have to learn about the command. In Windows, it is lpr (Windows NT4.0 or later), In UNIX, it is lp or lpr. (You may use any other command having same function.) These commands should accept a text file (from standard input in UNIX) and print it to a printer with fixed pitch default font.

You have to know how many lines and columns can the printer print with the default paper and default fixed pitch font. These numbers may be found in the manual of the printer. But, if they are not available, you may check them by test pattern printing. Note that columns are counted by the unit of ASCII character font pitch.

Environment variable Dprintcap has one or more entries separated by SEMICOLON (:). Each entry has five fields separated by COLON (:). These fields are positional and name, type, columns, rows and command, in this order.

Name is the name used in the Dpr command -P option. It may be same as the printer name used in the system, but, not necessarily be same. This name is used only for associating the Dpr command and an entry of Dprintcap. Name should be unique in Dprintcap entries.

Type is "t", which means "text" type. Other types such as "postscript" may be supported in future versions.

Columns and rows are number of maximum columns and rows printed by the command. These numbers are used by Dpr when no -x or -y options are given.

Command is a character string used by Dpr command, but for the filename argument. It is something like "lpr -S server -P printer. See the examples below.

In Windows, Dprintcap environment is usually set from Control Panel -- System (detail is different depending on the version). Or, you may set this by "set" command. In UNIX, Dprintcap environment is usually set from .profile, .cshrc or such shell initializing script.

EXAMPLES

Display fields "filename" and "size" from a D-file

Dpr -p "filename,size"

Print a D-file named "test1.d" with ID field "student-id", and page break at each "classroom":

Dpr -i student-id -g classroom test1.d

Setup Dprintcap environment (WindowsNT4.0 or later):
(you may set the environment from "System" Control Panel)

set Dprintcap=LBP0:t:106:76:lpr -S PRTSERV -P LBP0;LBP1:t:106:76:lpr -S PRTSERV -P LBP1

Setup Dprintcap environment (UNIX sh):

Dprintcap="LBP0:t:106:76:lp -d LBP0"
export Dprintcap

Setup Dprintcap environment (UNIX csh):

setenv Dprintcap "LBP0:t:106:76:lpr -PLBP0"

Print a D-file named "list.d" to the printer defined as LBP0:

Dpr -P LBP0 list.d

DIAGNOSTICS

See the manual of D_msg.

SEE ALSO

Dintro, D_fmt, D_msg.

AUTHOR

MIYAZAWA Akira


miyazawa@nii.ac.jp
2003