Progress
Programming
Handbook
Receiving Input from Multiple Sources
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
p-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 thep-datf1.d
file, you also need input from the file.The
p-chgin2.p
procedure uses multiple input sources to perform the work described above. Becausep-chgin2.p
uses the same data file (p-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 runp-chgin2.p
. Use the following procedure to delete the customers:
Figure 7–6 shows the
p-chgin2.p
procedure.p-chgin2.pFigure 7–6: Multiple Input Sources
![]()
These are the specific steps the procedure follows:
- The DISPLAY statement displays some text.
- The first INPUT FROM statement redirects the input source to the
p-datf1.d
file.- The SET statement assigns the values in the
p-datf1.d
file to the cust–num–var, name–var, and sales–rep–var variables. As it assigns the values to these variables, you see the values on the terminal screen.- The INPUT FROM TERMINAL statement redirects the input source to the terminal. The INPUT CLOSE statement could have been used instead of the INPUT FROM TERMINAL statement. 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 SET answer statement prompts you to create database records for the customer data just displayed. If you answer yes, the procedure:
Copyright © 2004 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095 |