Thanks all; "test -e" (for files) or "test -d" (for directories) seems to be
what I was looking for.
What is DIR() ?
I don't find it in HELP BASIC DIR and it won't compile (no matter how I use
it I get "array DIR never dimensioned").

/Scott

On Tue, Mar 4, 2008 at 6:33 AM, David A. Green <[EMAIL PROTECTED]>
wrote:

> I use DIR() Function.
>
> Thanks,
> David A. Green
> www.dagconsulting.com
> (480) 813-1725
>
>
> -----Original Message-----
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] On Behalf Of Scott Ballinger
> Sent: Monday, March 03, 2008 6:28 PM
> To: [email protected]
> Subject: [U2] test for a unix file?
>
> I have a standard subroutine that I use in UV BASIC when I need to check
> for
> the existence (or non-existance) of a unix file:
>
>     FILE.TEST.SUB
> 0001 SUB(FILENAME,ANS)
> 0002 * return ans = 1 if filename exists
> 0003 * redirect to bit bucket to suppress 'not on file' msg
> 0004 * filename includes full path to file
> 0005 EXECUTE "SH -c 'ls -d ":FILENAME:" 2> /dev/null'" CAPTURING XXX
> 0006
> 0007 FN = FILENAME
> 0008 CONVERT "\" TO "" IN FN  ;*  in case we escaped any special
> characters
> 0009
> 0010 IF XXX<1> EQ FN THEN ANS = 1 ELSE ANS = 0
> 0011
> 0012 RETURN
> 0013
>
> It works fine, but seems pretty slow, particularly if I am churning though
> thousands of tests (like from a big select list).
> Can anyone suggest a faster/more efficient way to test if a unix level
> file
> exists from inside UV BASIC ?
>
> Thanks,
> /Scott Ballinger
> Pareto Corporation
> Edmonds WA USA
> 206 713 6006
> -------
> u2-users mailing list
> [email protected]
> To unsubscribe please visit http://listserver.u2ug.org/
> -------
> u2-users mailing list
> [email protected]
> To unsubscribe please visit http://listserver.u2ug.org/
-------
u2-users mailing list
[email protected]
To unsubscribe please visit http://listserver.u2ug.org/

Reply via email to