Progress
Portability Guide
Standard System Commands
Where possible, use standard system commands instead of variants unique to certain hardware manufacturers. Table 4–1 lists the OS statements that promote portability by avoiding limitations of operating-system-specific commands. These statements allow you to create a single version of a procedure that works differently on varying operating systems.
See the Progress Language Reference for more information on these statements.
OS-COMMAND
Use the OS-COMMAND statement to execute an operating system statement that you cannot execute using the OS statements listed in Table 4–1. The OS-COMMAND statement provides a generic, operating-system-independent way to escape to the current operating system, which lets you:
The arguments to OS-COMMAND must be appropriate for the current operating system. Therefore, where possible, read these arguments at run time from the user, database table, or environment variables rather than hard coding them. The following procedure prompts the user for an operating system command, then uses the OS-COMMAND statement to execute the command:
The OS-COMMAND statement eliminates the need to use the OPSYS function to determine the operating system. However, if you cannot use the OS-COMMAND statement, use the OPSYS function to determine the operating system you are running on, and use conditional logic to execute the appropriate code using one of the operating-system-specific escape statements.
The NO-WAIT option of OS-COMMAND is valid only in multi-tasking environments. This option causes Progress to pass control to the statement following the OS-COMMAND, without waiting for the operating system command to terminate. If you are using the OS-COMMAND statement to run an independent Windows application, use the NO-WAIT option.
For more information, see the OS-COMMAND Statement reference entry in the Progress Language Reference.
INPUT FROM OS-DIR
You generally use the INPUT FROM statement to read the contents of an operating system file; however, you can also read a list of the files in a directory using the OS-DIR option of the INPUT FROM statement. The INPUT FROM statement specifies a new input source. Using INPUT FROM OS-DIR indicates that you want your input to be the filenames found in the directory you specify. If that directory is not a valid directory or you do not have permission to read it, an error condition occurs. Otherwise, Progress generates the directory list and sends it to the calling program through the INPUT stream. An INPUT CLOSE statement discards any unread filenames from the list.
The following example uses the OS-GETENV function to find the path of the
DLC
directory, then uses the OS-DIR option of INPUT FROM to read the contents of the directory:
When you use the OS-DIR option, the UNBUFFERED option is ignored. OS-DIR always buffers exactly one filename at a time. When you try to read beyond the last filename in the list, Progress generates the ENDKEY condition.
See the Progress Language Reference for more information on the INPUT FROM statement.
Copyright © 2004 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095 |