On Mon, 29 Nov 2004 16:37:32 -0500, you wrote:

>To All:
>
>I am writing an interesting program.  One that finds where a file is empty of 
>records or not.  I used the EXECUTE command with the COUNT command to get the 
>number of records in a file.  If its 0 then the file is empty.
>
>But is there a better way as the execution command causes problem in other 
>parts of this program.
>
>So, if anyone has any ideas along the lines of telling if a file is empty 
>(Unidata file), could you please give me a note!
>
>
>Thank You Very Much!


OPEN "", "SOMEFILE" TO F.SOMEFILE ELSE
   CRT "FAILED TO OPEN SOMEFILE"
   STOP
END
 
SELECT F.SOMEFILE
READNEXT K.SOMEFILE THEN
  FILE.EMPTY = 0       ;*  FALSE
  CLEARSELECT
END ELSE
  FILE.EMPTY = 1      ;*  TRUE
END
 
IF (FILE.EMPTY) THEN
    .....  Do something
END ELSE
   ....  Do something else
END


If you want to know how many records are in the file, then you could
loop off of the active select list incrementing a counter.  If you
don't need to know how many, but merely if there are *any*, this logic
will get you in and out fairly quickly.

Regards.

-- 
Allen Egerton
[EMAIL PROTECTED]
-------
u2-users mailing list
[EMAIL PROTECTED]
To unsubscribe please visit http://listserver.u2ug.org/

Reply via email to