Progress
Language Reference


INPUT FROM Statement

Interfaces
OS
SpeedScript
All
NT, UNIX only
Yes

Specifies a new input source.

SYNTAX

INPUT [ STREAM stream ] FROM
  {     opsys-file
     |  opsys-device
     |  TERMINAL
     |  VALUE ( expression )
     |  OS-DIR ( directory ) [ NO-ATTR-LIST ]
  }
  [ BINARY ]
  [ ECHO | NO-ECHO ] 
  [ MAP protermcap-entry | NO-MAP ]
  [ UNBUFFERED ] 
  [     NO-CONVERT 
     |  { CONVERT
            [ TARGET target-codepage ] 
            [ SOURCE source-codepage ]
        }
  ] 

STREAM stream

Specifies the name of a stream. If you do not name a stream, Progress uses the unnamed stream. See the DEFINE STREAM Statement reference entry and the Progress Programming Handbook for more information on streams.

opsys-file

The name of the file that contains the data you want to input to a procedure. If you do not specify a full pathname, Progress looks for the file in your working directory. Also, remember that UNIX file names are case sensitive.

opsys-device

The name of a UNIX or Windows device.

TERMINAL

Indicates that you want to get input from your terminal. The terminal is the default input source. You cannot use TERMINAL with STREAM.

VALUE ( expression )

An expression whose value is the source where you want to input data.

OS-DIR (directory)[ NO-ATTR-LIST ]

Indicates that you want your input to be the filenames found in directory. The value of directory is a character expression specifying an operating system directory. If directory is not a directory or you do not have permission to read it, then the INPUT statement raises ERROR. Otherwise, Progress generates the directory list and feeds it back to the calling program through the INPUT stream. An INPUT CLOSE statement discards any unread filenames from the list.

Each line read from the input stream is a string composed of three tokens: the file’s base name, the file’s absolute path name, and an attribute list consisting of one or more of the characters FDSMXHLP, unless you specified the NO-ATTR-LIST option. If you specified that option, you will not get the string attribute for each line of the resulting list. You are guaranteed to get exactly one of:

NO-ATTR-LIST

Omits the string attribute field that indicates the type of the file. This can speed up program execution. An example of this form of the statement is as follows:

INPUT FROM OS-DIR("c:\mydir") [ NO-ATTR-LIST ]. 

BINARY

Allows all input to be read directly without any conversion or interpretation. By default, NUL (\0) terminates character strings, and other control characters are interpreted as expected for the operating system.

ECHO

Displays all input data on the current output device. Data is echoed by default.

NO-ECHO

Accepts input data without displaying it on the current output device. If you do not use this option, INPUT FROM automatically displays input data on the current output device.

MAP protermcap-entry | NO MAP

The protermcap-entry value is an entry from the PROTERMCAP file. Use MAP to read from an input stream that uses a different character translation from the current stream. Typically, protermcap-entry is a slash-separated combination of a standard device entry and one or more language-specific add-on entries (MAP laserwriter/french or MAP hp2/spanish/italian, for example). Progress uses the PROTERMCAP entries to build a translation table for the stream. Use NO-MAP to make Progress bypass character translation altogether. See the Progress Internationalization Guide for more information on PROTERMCAP and national language support.

UNBUFFERED

Reads one character at a time from a normally buffered data source, such as a file. Use the UNBUFFERED option only when you can intermingle the input operations of a UNIX process, invoked with the Progress UNIX statement, with the input that follows the Progress INPUT FROM statement.

CONVERT

Allows you to modify the character conversions occurring between the external file and Progress. By default, the INPUT FROM statement converts characters from the code page specified with the Stream Code Page (-cpstream) parameter to the code page specified with the Internal Code Page (-cpinternal) parameter. If you specify SOURCE source-codepage alone, the conversion accepts source-codepage as the code page name of the external file (instead of -cpstream). If you specify TARGET target-codepage, the conversion accepts target-codepage as the internal code page (instead of -cpinternal). If you specify both SOURCE source-codepage and TARGET target-codepage, it converts characters from the source-codepage to target-codepage (instead of -cpstream to -cpinternal).

TARGET target-codepage

Specifies the target code page of the character conversion (replacing -cpinternal). The name that you specify must be a valid code page name available in the DLC/convmap.cp file (a binary file that contains all of the tables that Progress uses for character management).

SOURCE target-codepage

Specifies the source code page of the character conversion (replacing -cpstream). The name that you specify must be a valid code page name available in the DLC/convmap.cp file (a binary file that contains all of the tables that Progress uses for character management).

NO-CONVERT

Specifies that no character conversions occur between the external file and memory. By default, the INPUT FROM statement converts characters from the -cpstream code page to the -cpinternal code page.

EXAMPLE

Instead of getting input from the terminal, this procedure gets input from a file named r-in.dat. The SEARCH function determines the full pathname of this file.

r-in.p
INPUT FROM VALUE(SEARCH("r-in.dat")).

REPEAT:
    PROMPT-FOR cust.cust-num credit-limit.
    FIND customer USING INPUT cust-num.
    ASSIGN credit-limit.
END.

INPUT CLOSE. 

This is what the contents of the r-in.dat file look like.

1 55800
2 41300
5 88000 

The PROMPT-FOR statement uses the first data item (1) as the cust-num and the second data item (55800) as the credit-limit. The FIND statement finds the customer whose cust-num is 1 and assigns the value of 55800 as that customer’s credit limit. On the next iteration of the REPEAT block, the PROMPT-FOR statement uses the value of 2 as the cust-num, the value of 41300 as the credit-limit, etc.

The INPUT CLOSE statement closes the input source, resetting it to the terminal. When you run this procedure, the data in the window is simply an echo of the data that the procedure is reading from the taxno.dat file. If you do not want to display the data, add the word NO-ECHO to the end of the INPUT FROM statement.

NOTES

SEE ALSO

DEFINE STREAM Statement, INPUT CLOSE Statement, INPUT THROUGH Statement


Copyright © 2004 Progress Software Corporation
www.progress.com
Voice: (781) 280-4000
Fax: (781) 280-4095