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
>