NAME

lprint - print data on the line printer

SYNOPSIS

lprint [Item]. . .  [using StrExpr; Expr[, Expr]. . .  [;]]

DESCRIPTION

The lprint and lprint using statements work just like the ordinary print and print using statements except that the destination of the output is the line printer. 

EXAMPLE

The program
	lprint "Helping Hand Acceptance Corporation"
	lprint
	lprint "Save this portion for your records"
might be executed as follows:
	$ LPR="lpr"
	$ export LPR
	$ a.out
	$
The following will arrive at the line printer via the line printer spooler:
	Helping Hand Acceptance Corporation

	Save this portion for your records

SEE ALSO

lpos, print, print using, width

USAGE NOTES

The "line printer" is a term that can not be well defined under the UNIX operating system since there is no concept of a dedicated printer line in UNIX.  Often, however, there is a utility, a spooler, dedicated to managing the printer.  On other systems, a dedicated line is available.  To provide maximum flexibility, the printer is attached via a UNIX command which can be determined at the userís site as appropriate.  The command is indicated with the UNIX environment variable LPR.  Thus, if the common line printer spooler, lpr, is available, the shell commands:
	$ LPR="lpr"
	$ export LPR
prior to the execution of userís program will see that the output to the "printer" with lprint is sent via "lpr." On the other hand, if a dedicated spooler line, say "/dev/tty11," is available, the shell commands:
	$ LPR="cat -u >/dev/tty11"
	$ export LPR
prior to execution of the userís program will see that the output to the "printer" with lprint is sent directly to this line. 

Other printer arrangements can always be accommodated by an appropriate LPR command.  Note that these examples are appropriate for the ordinary UNIX shell "sh" or Bourne shell.  The syntax for setting and exporting environment variables under the Berkeley shell "csh" is different. 

Some printer applications require that output appear without delays due to buffering.  Basmark QuickBASIC introduces no buffering of its own, however, this does not guarantee that buffering will not be performed by the userís LPR command.  A spooler will always introduce buffering.  Even "cat" will cause some buffering unless it is used with the "-u" switch, as in the example above. 

Conceptually, the line printer may be regarded as a static, omnipresent facility.  Most applications are well served by this model, however, applications which need to circumvent the buffering introduced by a spooler or need to dynamically redefine the LPR command require a more detailed model: The line printer is merely a communication channel, much like a file, except that the output is sent to an executing program (the LPR command).  And while a file is opened and closed by explicit statements, the line printer channel is opened implicitly by the first lprint statement.  At this time, the LPR command is read and invoked.  The channel is closed only upon termination of the BASIC program.  Only then is the command signaled that output is complete.  Thus if a spooler buffers the output, physical printing will not begin until the BASIC program terminates.  Also, redefining the LPR command does not redirect the output. 

These problems could be circumvented by the means to explicitly close the line printer channel.  Buffered output would then be flushed.  The LPR command could be redefined and the next lprint statement would implicitly reopen the channel.  A special routine is provided in Basmark QuickBASIC to close the line printer as demonstrated in the following program:

	environ "LPR=cat >file1"
	lprint "this goes to file1"
	call lclose
	environ "LPR=cat >file2"
	lprint "this goes to file2"
	call lclose
The two messages are sent to their respective files.  The call lclose statements close the line printer and permit the redefinition of the LPR command.  Note that the last statement is unnecessary because of the implicit closing upon termination.  Also note that familiarity with the call statement is unnecessary here because these statements must be coded exactly as they appear and no additional coding nor special compiling command is required. 

from The Basmark QuickBASIC Programmerís Manual by Lawrence Leinweber