Kbase 19505: Zero (0) Byte File When Using OUTPUT THROUGH - Why?
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  2/7/2000 |
|
When using code similar to the following it is possible that the file will appear to have a file size of zero (0) bytes when running the shell script that is embedded in the 4GL code.
OUTPUT THROUGH cat > somefile.
FOR EACH Customer NO-LOCK:
DISPLAY CustNum Name CreditLimit Balance.
END.
OUTPUT CLOSE.
UNIX SILENT (someshellscript.sh).
You may find that adding a PAUSE 2 NO-MESSAGE command before the UNIX SILENT command will resolve the problem.
A probable cause for this problem is that the output through creates a subprocess and a pipe connected to stdin of the subprocess. The subprocess creates the file and does all the writing to it. When you execute the close, the *pipe* is closed, not the file. Then it may take a little time for the subprocess to be scheduled, respond, realize the pipe is closed and then close the file. In the meantime the 4GL program is continuing to run and goes on to the next statement.