Consultor Eletrônico



Kbase 18412: 4GL. SAMPLE CODE, Printer Selection From a List Using 4GL on UNIX
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   02/03/2005
Status: Unverified

GOAL:

SAMPLE CODE, Printer Selection From a List Using 4GL on UNIX

GOAL:

Printer Selection example for unix

GOAL:

Sample program demonstrating how to get multiple printers defined on UNIX and how to display them in a selection list, so that the end user can select and print to the desired printer.

FACT(s) (Environment):

Unix

FIX:

The sample program assumes a specific format for the output of the lpstat command. Since that can vary depending on the UNIX flavor, you may have to adjust the program to suit the output of your specific environment(s).

Please refer to your UNIX documentation or UNIX man command for additional information on lpstat and lp.

/* Sample program */
def var wline as char format "x(50)".
def var wprinter as char format "x(50)".
def var wlist as char view-as selection-list
inner-chars 15 inner-lines 10 sort.
def var wlog as logical.

form wlist with frame printer-list.
wlist:list-items = "".

input through "lpstat -v".
repeat:
import unformatted wline.
/*
The following line looks for "for" because it is part of the
lpstat output lines that contain the printer name,
*/
if wline matches "* for *" then do:
wprinter = entry(1,wline,":").
wprinter = entry(3,wprinter," ").
if wprinter <> "" then wlog = wlist:add-last(wprinter).
end.
end.
input close.

status input "Select printer and press F1 or press F4 to end.".
update wlist no-label with frame printer-list
view-as dialog-box title "Printers".

message "Printer selected is: " wlist:screen-value view-as alert-box.

output through value("lp -s -d" + wlist:screen-value).
display "Testing printer: " wlist:screen-value.
output close.


References To Written Documentation:

Progress Language Reference:
- IMPORT statement.
- INPUT THROUGH statement.
- OUTPUT THROUGH statement.