Hi,

Is there a way in Foxpro to check if a filename the user entered is legal
before creating it ?

thanks !
Xavier

Re: check if filename is legal by Rick

Rick
Thu Jan 06 08:40:04 CST 2005

Xavier,
How do you mean "legal"?

DOS legal? Windows legal? UNIX legal? VFP table name legal? All these =
have different rules.

Does this include a full path name, or just the file itself?

Rick

"Nuyttens Xavier" <xavier@cpsit.be> wrote in message =
news:HubDd.21706$xk5.1583154@phobos.telenet-ops.be...
> Hi,
>=20
> Is there a way in Foxpro to check if a filename the user entered is =
legal=20
> before creating it ?
>=20
> thanks !
> Xavier=20
>=20
>

Re: check if filename is legal by Andrew

Andrew
Thu Jan 06 09:58:43 CST 2005

Nuyttens Xavier wrote:
> Hi,
>
> Is there a way in Foxpro to check if a filename the user entered is
> legal before creating it ?

I use FPW2.6 which has a library "foxtools". This has a function VALIDPATH()
which is supposed to do this but apparently it's not foolproof. Later
versions of Foxpro had the foxtools functions integrated in the language
itself but I don't know whether or not this function was dropped.

Foxtools.wri says:

VALIDPATH(<ExpC1>)
Returns: Logical
Description: Checks for a valid DOS filename and/or path syntax.
This function is not foolproof and can sometimes think a file has a valid
name when it doesn't. However, it will not reject as invalid a valid
name.
NOTE: Does not check to see if it exists
Example: ? VALIDPATH("C:\FOO") (returns: .T.)
? VALIDPATH("C:\THISISVERYLONG") (returns: .F.)


So I guess the answer to your question is "possibly, if so then not 100%
accurately" :)

--
HTH
Andrwe Howell



Re: check if filename is legal by Rick

Rick
Thu Jan 06 10:10:15 CST 2005

Andrew,
I'd forgotten about that FoxTools function! It's still there in VFP 9.0! =
Unfortunately it isn't clear what "rules" it uses - at least it's not =
just the DOS 8.3, it's happy with some sample Windows filenames I tried.

Rick

"Andrew Howell" <ajh@work> wrote in message =
news:eJAmdiA9EHA.1524@TK2MSFTNGP09.phx.gbl...
> Nuyttens Xavier wrote:
>> Hi,
>>
>> Is there a way in Foxpro to check if a filename the user entered is
>> legal before creating it ?
>=20
> I use FPW2.6 which has a library "foxtools". This has a function =
VALIDPATH()
> which is supposed to do this but apparently it's not foolproof. Later
> versions of Foxpro had the foxtools functions integrated in the =
language
> itself but I don't know whether or not this function was dropped.
>=20
> Foxtools.wri says:
>=20
> VALIDPATH(<ExpC1>)
> Returns: Logical
> Description: Checks for a valid DOS filename and/or path syntax.
> This function is not foolproof and can sometimes think a file has a =
valid
> name when it doesn't. However, it will not reject as invalid a =
valid
> name.
> NOTE: Does not check to see if it exists
> Example: ? VALIDPATH("C:\FOO") (returns: .T.)
> ? VALIDPATH("C:\THISISVERYLONG") (returns: .F.)
>=20
>=20
> So I guess the answer to your question is "possibly, if so then not =
100%
> accurately" :)
>=20
> --
> HTH
> Andrwe Howell
>=20
>

Re: check if filename is legal by Ook

Ook
Thu Jan 06 10:35:11 CST 2005

I would re-route the error trap and try to create the file. That seems to me
to be the easiest and most accurate way to tell. You can create the file in
a temp directory if you wish, and then delete it. I am assuming that VFP
won't allow you to create invalid filenames. I once ended up with two files
in a directory, same name but different case. I couldn't duplicate it, so
not sure exactly how it happened.


"Nuyttens Xavier" <xavier@cpsit.be> wrote in message
news:HubDd.21706$xk5.1583154@phobos.telenet-ops.be...
> Hi,
>
> Is there a way in Foxpro to check if a filename the user entered is legal
> before creating it ?
>
> thanks !
> Xavier
>
>



Re: check if filename is legal by Nuyttens

Nuyttens
Mon Jan 10 01:56:57 CST 2005

Thanks, however I need this function to check is the user typed a valid name
for a new Word document, so I don't think you can restrict them to DOS names
:) So, I think the only way is the "TRY...CATCH" as 'Ook' said, but I would
have prefered to use a function if one was available ofcourse.

Xavier

"Rick Bean" <rgbean@unrealmelange-inc.com> schreef in bericht
news:u28m2oA9EHA.1084@TK2MSFTNGP15.phx.gbl...
Andrew,
I'd forgotten about that FoxTools function! It's still there in VFP 9.0!
Unfortunately it isn't clear what "rules" it uses - at least it's not just
the DOS 8.3, it's happy with some sample Windows filenames I tried.

Rick

"Andrew Howell" <ajh@work> wrote in message
news:eJAmdiA9EHA.1524@TK2MSFTNGP09.phx.gbl...
> Nuyttens Xavier wrote:
>> Hi,
>>
>> Is there a way in Foxpro to check if a filename the user entered is
>> legal before creating it ?
>
> I use FPW2.6 which has a library "foxtools". This has a function
> VALIDPATH()
> which is supposed to do this but apparently it's not foolproof. Later
> versions of Foxpro had the foxtools functions integrated in the language
> itself but I don't know whether or not this function was dropped.
>
> Foxtools.wri says:
>
> VALIDPATH(<ExpC1>)
> Returns: Logical
> Description: Checks for a valid DOS filename and/or path syntax.
> This function is not foolproof and can sometimes think a file has a valid
> name when it doesn't. However, it will not reject as invalid a valid
> name.
> NOTE: Does not check to see if it exists
> Example: ? VALIDPATH("C:\FOO") (returns: .T.)
> ? VALIDPATH("C:\THISISVERYLONG") (returns: .F.)
>
>
> So I guess the answer to your question is "possibly, if so then not 100%
> accurately" :)
>
> --
> HTH
> Andrwe Howell
>
>



Re: check if filename is legal by Rick

Rick
Mon Jan 10 08:31:23 CST 2005

Well as Andrew suggests (and I confirmed), the FoxTools - VALIDPATH() =
function of VFP does check valid Windows's file names just fine.

Rick

"Nuyttens Xavier" <xavier@cpsit.be> wrote in message =
news:dzqEd.26389$wj.1819720@phobos.telenet-ops.be...
> Thanks, however I need this function to check is the user typed a =
valid name=20
> for a new Word document, so I don't think you can restrict them to DOS =
names=20
> :) So, I think the only way is the "TRY...CATCH" as 'Ook' said, but I =
would=20
> have prefered to use a function if one was available ofcourse.
>=20
> Xavier
>=20
> "Rick Bean" <rgbean@unrealmelange-inc.com> schreef in bericht=20
> news:u28m2oA9EHA.1084@TK2MSFTNGP15.phx.gbl...
> Andrew,
> I'd forgotten about that FoxTools function! It's still there in VFP =
9.0!=20
> Unfortunately it isn't clear what "rules" it uses - at least it's not =
just=20
> the DOS 8.3, it's happy with some sample Windows filenames I tried.
>=20
> Rick
>=20
> "Andrew Howell" <ajh@work> wrote in message=20
> news:eJAmdiA9EHA.1524@TK2MSFTNGP09.phx.gbl...
>> Nuyttens Xavier wrote:
>>> Hi,
>>>
>>> Is there a way in Foxpro to check if a filename the user entered is
>>> legal before creating it ?
>>
>> I use FPW2.6 which has a library "foxtools". This has a function=20
>> VALIDPATH()
>> which is supposed to do this but apparently it's not foolproof. Later
>> versions of Foxpro had the foxtools functions integrated in the =
language
>> itself but I don't know whether or not this function was dropped.
>>
>> Foxtools.wri says:
>>
>> VALIDPATH(<ExpC1>)
>> Returns: Logical
>> Description: Checks for a valid DOS filename and/or path syntax.
>> This function is not foolproof and can sometimes think a file has a =
valid
>> name when it doesn't. However, it will not reject as invalid a =
valid
>> name.
>> NOTE: Does not check to see if it exists
>> Example: ? VALIDPATH("C:\FOO") (returns: .T.)
>> ? VALIDPATH("C:\THISISVERYLONG") (returns: .F.)
>>
>>
>> So I guess the answer to your question is "possibly, if so then not =
100%
>> accurately" :)
>>
>> --
>> HTH
>> Andrwe Howell
>>
>>=20
>=20
>

Re: check if filename is legal by Nuyttens

Nuyttens
Fri Jan 14 07:07:14 CST 2005

You're right, I was confused with the FP2.6 test results, I tried it on
Foxpro 8 as you did, and it works fine. Thanks !