PreviousNextIndex

INPUT THROUGH statement

Uses the output from a program as the input to an ABL procedure.

Syntax

INPUT [ STREAM stream | STREAM-HANDLE handle ] THROUGH 
  { program-name | VALUE ( expression ) } 
  [ argument | VALUE ( expression ) ] ... 
  [ ECHO | NO-ECHO ]  
  [ MAP protermcap-entry | NO-MAP ] 
  [ UNBUFFERED ] 
  [     NO-CONVERT 
     |  { CONVERT 
           [ TARGET target-codepage ] 
           [ SOURCE source-codepage ] 
        } 
  ] 

STREAM stream
STREAM-HANDLE handle
program-name
VALUE ( expression)
argument
ECHO
NO-ECHO
MAP protermcap-entry | NO-MAP
UNBUFFERED
CONVERT
TARGET target-codepage
SOURCE target-codepage
NO-CONVERT
Examples

This procedure uses as its input source the output of the UNIX echo command. Before the command runs, the UNIX shell substitutes the process-id number for $$ and the current directory search path for $PATH. The results are then echoed and become available as a line of input to ABL. When the IMPORT statement is executed, the line of input from echo is read and the values are assigned to the two variables. Those variables can then be used for any purpose. In this example, the word echo must be lowercase and the word $PATH must be uppercase, since they both pass to UNIX:

r-ithru.p
DEFINE VARIABLE process-id AS CHARACTER NO-UNDO. 
DEFINE VARIABLE dir-path   AS CHARACTER NO-UNDO  
  VIEW-AS EDITOR SIZE 60 BY 10. 
INPUT THROUGH echo $$ $PATH NO-ECHO. 
SET process-id dir-path WITH FRAME indata NO-BOX NO-LABELS. 
DISPLAY process-id dir-path FORMAT "x(70)". 
INPUT CLOSE. 

When you use INPUT THROUGH, the UNIX program you name is executed as a separate process under its own shell. Therefore, the values of shell variables (such as $$) are values from that shell rather than the shell from which the AVM executes.

The following procedure uses INPUT THROUGH twice to get input from the UNIX pwd and ls commands. The pwd command supplies the name of the current directory and the ls command supplies the name of each UNIX file in your current directory. After the variable fn is set, it displays on the screen.

r-ithru2.p
DEFINE VARIABLE dir-name AS CHARACTER NO-UNDO FORMAT "x(64)". 
DEFINE VARIABLE fn       AS CHARACTER NO-UNDO FORMAT "x(32)". 
FORM fn 
  WITH DOWN FRAME dir-list. 
/* Get the name of the current directory. */ 
INPUT THROUGH pwd NO-ECHO. 
SET dir-name. 
INPUT CLOSE. 
/* Use the directory name as a label for fn. */ 
fn:LABEL IN FRAME dir-list = dir-name. 
/* List the directory. */ 
INPUT THROUGH ls NO-ECHO. 
/* For each entry in the directory, read the entry into fn and display it. */ 
REPEAT: 
  SET fn WITH NO-BOX NO-LABELS FRAME indata. 
  DISPLAY fn VIEW-AS TEXT WITH FRAME dir-list. 
  DOWN WITH FRAME dir-list. 
END. 
INPUT CLOSE. 

Notes
See also

DEFINE STREAM statement, INPUT CLOSE statement, INPUT FROM statement, Stream object handle


OpenEdge Release 10.2B
Copyright © 2009 Progress Software Corporation
PreviousNextIndex