Receiving input from multiple sources
- Last Updated: January 17, 2024
- 2 minute read
- OpenEdge
- Version 12.8
- Documentation
At some points in a procedure you might want to get input from the terminal, but at other points you might want to get input from a file. A single procedure can use multiple input sources.
For example, suppose you want to create records for the customers in the i-datf1.d data file. Before creating the records, you probably want to display the customer numbers in the file and ask if the user wants to create customer records for those numbers. To do this, you need input from the terminal. If the user wants to create customer records for the customers in the i-datf1.d file, you also need input from the file.
The i-chgin2.p procedure uses multiple input sources to perform the work described above. Because i-chgin2.p uses the same data file (i-datf1.d) you used in the previous section to create customer records, you must delete customers 90, 91, and 92 from your database before you run i-chgin2.p. Use the i-io3.p procedure to delete the customers.
i-io3.p
|
The following figure shows the i-chgin2.p procedure.

These are the specific steps that the i-chgin2.p procedure follows:
- The
DISPLAYstatement displays some text. - The first
INPUT FROMstatement redirects the input source to the i-datf1.d file. - The
SETstatement assigns the values in the i-datf1.d file to thecust–num–var,name–var, andsales–rep–varvariables. As it assigns the values to these variables, you see the values on the terminal screen. - The
INPUT FROM TERMINALstatement redirects the input source to the terminal. TheINPUT CLOSEstatement could have been used instead of theINPUT FROM TERMINALstatement. However, since this procedure might have been called from another procedure, it is better to be explicit about the input source you want to use. - The
SETanswer statement prompts you to create database records for the customer data just displayed. If you answer yes, the procedure:- Redirects the input source to come from the beginning of the i-datf1.d file
- Creates a customer record and assigns values to the cust–num., name,
and sales–rep fields in that record for each iteration of a
REPEATblock - Ends the
REPEATblock when theSETstatement reaches the end of the input file