Consultor Eletrônico



Kbase 18411: How to Detect a File With No Size (0 bytes) using 4GL
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   12/12/2003
Status: Unverified

GOAL:

How to Detect a File With No Size (0 bytes) using 4GL

FIX:

This solution provides three examples on how to detect a file with no size.
The recommended method is to use the FILE-SIZE attribute of the FILE-INFO system handle. This attribute was introduced in Progress V9.0A.

To create an empty file, you can use the following program:

/* zerobyte.p */

output to zerobyte.out.        /*create zero byte file */
output close.


Methods:
1. Use the FILE-SIZE attribute of the FILE-INFO handle:


FILE-INFO:FILE-NAME = "zero.txt".
DISPLAY FILE-INFO:FILE-SIZE.


2. Detect no processing of input:


def var cnt as int.
input from zerobyte.out.
 repeat:
    create customer.
    import customer.
    cnt = cnt + 1.
 end.
if cnt = 0 then
  message "zerobyte file" view-as alert-box.


3. Use the Seek statement and Seek function:


 Define variable intFileSize as Integer No-undo.
 
Input from C:\X.X.
  Seek Input to End.
  Assign intFileSize = Seek(Input).
  Message "File Size is " + String(intFileSize) + " Bytes" View-as Alert-box.