Don't understand Fullpath() - not getting results I expect

Don't understand Fullpath() - not getting results I expect

Post by Ji » Thu, 08 Nov 2001 09:27:22



Hi,

I'm not sure I understand the Fullpath() command, as I get unexpected
results when trying to use it.  Perhaps it's best to state what I
need, and explore if Fullpath is the right way to go.

I have written many small progs in FoxPro2.5a for Windows.  Originally
for a stand alone machine, they are now accessible over a small (3 pc)
network in my office.  Originally, most directories were hard coded
into my apps, but now I would like to run these apps from any of the 3
pc's on the network.  Since FoxPro2.5 doesn't support the
\\computername\\drive\\directory\\ naming convention, I am forced to
use drive letters to designate files.  Dive letter mapping works;
however, the server's "C:\" drive is mapped as the "G:\" drive on the
2 workstations so when the apps are run from the server they
(accurately)
look for files on drive "C" but when run on the workstations, they
NEED to look on drive "G", but of course don't.

How can I tell my apps "when you're on the workstations, use drive G:"
??  Or (probably better) find the exact path of a file in realtime
relative to the machine requesting it, and call it that way?

I thought using fullpath would help me determine the path of a file to
be retrieved, and I could somehow test which machine is running, and
prepend the respective drive letter, but fullpath has me all turned
around.  I do not understand the concept or the results I am getting.
MS documentation on this command is poor.

What is the purpose of having to specify the second argument in
fullpath?  If you know the path relative to the first argument, why
not just use it?  Fullpath keeps returning the name of the file
specified in argument 1 as being in the directory from argument 2.
i.e. fullpath("\sometable.dbf", "C:\foxpro\new") returns
c:\foxpro\new\sometable.dbf when in actuality it is not located in the
"new" directory, but in the "foxpro" directory.  I don't get it.  It
just appears to be stringing the two together.  Is this even the way I
should be approaching my problem?

Any insight would very helpful.  I have been using FoxPro since 1994,
but I'm only an intermediate level user.  I have never written stand
alone apps, but I'm not totally a novice either.  I'm just stuck in
the middle.

Thanks,
Jim

 
 
 

Don't understand Fullpath() - not getting results I expect

Post by Steve Freide » Thu, 08 Nov 2001 11:56:23


I suggest you solve your problem by creating a small table on each
machine.  In that table have a field for the drive designation or even a
complete path.  Here's an example of how to do it:

  CREATE TABLE MyPath ( PathToStuf C(40) )

On main machine, MyPath.PathToStuf could be populated with "C:\FOXDATA\"
while on the other two machines it would be "G:\FOXDATA\" (or however
you name your directories).  Inside the app, instead of

  USE c:\foxdata\thisfile

you would

  USE ( TRIM( MyPath.PathToStuf ) + "thisfile" )

we do this and it works very well.  You can just as easily put the path
into a PUBLIC memory variable if you prefer.

Another approach is to set a DOS environmental variable on each machine,
retrieve that value with GETENV(), then use that inside your program in
a manner similar to what I've described above.

FULLPATH("") will return the current drive and directory.  I use this
all the time to save the current path, e.g.,

  cCurPath = FULLPATH("")

  SET DEFAULT TO SomethingNew
  DO something in SomethingNew

  SET DEFAULT TO &cCurPath

If FULLPATH() can find what you're looking for, it will return the path
to the file, but if it can't, it will act as if the file you want is in
the current drive/directory.  FULLPATH() is, therefore, pretty useless
at finding a file unless you're sure it's in the current directory or on
the FoxPro search path.   You could always:

  IF FILE( FULLPATH( "myfile" ) )
        * We know it's really there
  ELSE
        * It can't be found
  ENDIF

-=S=-


> Hi,

> I'm not sure I understand the Fullpath() command, as I get unexpected
> results when trying to use it.  Perhaps it's best to state what I
> need, and explore if Fullpath is the right way to go.

> I have written many small progs in FoxPro2.5a for Windows.  Originally
> for a stand alone machine, they are now accessible over a small (3 pc)
> network in my office.  Originally, most directories were hard coded
> into my apps, but now I would like to run these apps from any of the 3
> pc's on the network.  Since FoxPro2.5 doesn't support the
> \\computername\\drive\\directory\\ naming convention, I am forced to
> use drive letters to designate files.  Dive letter mapping works;
> however, the server's "C:\" drive is mapped as the "G:\" drive on the
> 2 workstations so when the apps are run from the server they
> (accurately)
> look for files on drive "C" but when run on the workstations, they
> NEED to look on drive "G", but of course don't.

> How can I tell my apps "when you're on the workstations, use drive G:"
> ??  Or (probably better) find the exact path of a file in realtime
> relative to the machine requesting it, and call it that way?

> I thought using fullpath would help me determine the path of a file to
> be retrieved, and I could somehow test which machine is running, and
> prepend the respective drive letter, but fullpath has me all turned
> around.  I do not understand the concept or the results I am getting.
> MS documentation on this command is poor.

> What is the purpose of having to specify the second argument in
> fullpath?  If you know the path relative to the first argument, why
> not just use it?  Fullpath keeps returning the name of the file
> specified in argument 1 as being in the directory from argument 2.
> i.e. fullpath("\sometable.dbf", "C:\foxpro\new") returns
> c:\foxpro\new\sometable.dbf when in actuality it is not located in the
> "new" directory, but in the "foxpro" directory.  I don't get it.  It
> just appears to be stringing the two together.  Is this even the way I
> should be approaching my problem?

> Any insight would very helpful.  I have been using FoxPro since 1994,
> but I'm only an intermediate level user.  I have never written stand
> alone apps, but I'm not totally a novice either.  I'm just stuck in
> the middle.

> Thanks,
> Jim


 
 
 

Don't understand Fullpath() - not getting results I expect

Post by Ji » Fri, 09 Nov 2001 03:24:42


Hi Steve,

Thank you for the great suggestions.  I'm glad you cleared up matters
on fullpath returning the path as if the file were in the default
directory when it can't be found - that explains some of the results I
had been getting.


> I suggest you solve your problem by creating a small table on each
> machine.  In that table have a field for the drive designation or even a
> complete path.  Here's an example of how to do it:

Not a bad idea.  It may require more re-programming than I feel like
doing at the moment, but it seems thorough.  I'm not sure I like the 3
separate tables in on 3 separate machines.  I might try one table with
all the paths combined with the environment variable idea below.  Oh
well, either way I knew it wouldn't be fun.

Quote:>   CREATE TABLE MyPath ( PathToStuf C(40) )

> On main machine, MyPath.PathToStuf could be populated with "C:\FOXDATA\"
> while on the other two machines it would be "G:\FOXDATA\" (or however
> you name your directories).  Inside the app, instead of

>   USE c:\foxdata\thisfile

> you would

>   USE ( TRIM( MyPath.PathToStuf ) + "thisfile" )

> we do this and it works very well.  You can just as easily put the path
> into a PUBLIC memory variable if you prefer.

> Another approach is to set a DOS environmental variable on each machine,
> retrieve that value with GETENV(), then use that inside your program in
> a manner similar to what I've described above.

This is very close to what I had planned on doing if I found out
fullpath wasn't going to give me what I wanted -- which it isn't.  I
haven't thought it completely through, but on the surface it seems
like it would require a little less programming.

- Show quoted text -

Quote:> FULLPATH("") will return the current drive and directory.  I use this
> all the time to save the current path, e.g.,

>   cCurPath = FULLPATH("")

>   SET DEFAULT TO SomethingNew
>   DO something in SomethingNew

>   SET DEFAULT TO &cCurPath

> If FULLPATH() can find what you're looking for, it will return the path
> to the file, but if it can't, it will act as if the file you want is in
> the current drive/directory.  FULLPATH() is, therefore, pretty useless
> at finding a file unless you're sure it's in the current directory or on
> the FoxPro search path.   You could always:

>   IF FILE( FULLPATH( "myfile" ) )
>    * We know it's really there
>   ELSE
>    * It can't be found
>   ENDIF

> -=S=-

Thanks again,

Jim

 
 
 

Don't understand Fullpath() - not getting results I expect

Post by Steve Freide » Fri, 09 Nov 2001 23:00:45


You're very welcome.  There was something the original Fox people did in
some of the supplied programs, e.g., genscrn.prg, that used fullpath()
in combination a SYS function - wait, here you go, from the FoxPro/Dos
2.6 help file on fullpath():

Quote:> When used with SYS(2014), FULLPATH() can make applications
> portable. That is, given the location of the current program
> and the location of other files used by the program,
> FULLPATH() and SYS(2014) can be used to obtain the paths for
> these files. Once the paths are determined, the files can be
> accessed by the program.

I confess to never having figured this one out.

-S-


> Hi Steve,

> Thank you for the great suggestions.  I'm glad you cleared up matters
> on fullpath returning the path as if the file were in the default
> directory when it can't be found - that explains some of the results I
> had been getting.


> > I suggest you solve your problem by creating a small table on each
> > machine.  In that table have a field for the drive designation or even a
> > complete path.  Here's an example of how to do it:

> Not a bad idea.  It may require more re-programming than I feel like
> doing at the moment, but it seems thorough.  I'm not sure I like the 3
> separate tables in on 3 separate machines.  I might try one table with
> all the paths combined with the environment variable idea below.  Oh
> well, either way I knew it wouldn't be fun.

> >   CREATE TABLE MyPath ( PathToStuf C(40) )

> > On main machine, MyPath.PathToStuf could be populated with "C:\FOXDATA\"
> > while on the other two machines it would be "G:\FOXDATA\" (or however
> > you name your directories).  Inside the app, instead of

> >   USE c:\foxdata\thisfile

> > you would

> >   USE ( TRIM( MyPath.PathToStuf ) + "thisfile" )

> > we do this and it works very well.  You can just as easily put the path
> > into a PUBLIC memory variable if you prefer.

> > Another approach is to set a DOS environmental variable on each machine,
> > retrieve that value with GETENV(), then use that inside your program in
> > a manner similar to what I've described above.

> This is very close to what I had planned on doing if I found out
> fullpath wasn't going to give me what I wanted -- which it isn't.  I
> haven't thought it completely through, but on the surface it seems
> like it would require a little less programming.

> > FULLPATH("") will return the current drive and directory.  I use this
> > all the time to save the current path, e.g.,

> >   cCurPath = FULLPATH("")

> >   SET DEFAULT TO SomethingNew
> >   DO something in SomethingNew

> >   SET DEFAULT TO &cCurPath

> > If FULLPATH() can find what you're looking for, it will return the path
> > to the file, but if it can't, it will act as if the file you want is in
> > the current drive/directory.  FULLPATH() is, therefore, pretty useless
> > at finding a file unless you're sure it's in the current directory or on
> > the FoxPro search path.   You could always:

> >   IF FILE( FULLPATH( "myfile" ) )
> >       * We know it's really there
> >   ELSE
> >       * It can't be found
> >   ENDIF

> > -=S=-

> Thanks again,

> Jim

 
 
 

Don't understand Fullpath() - not getting results I expect

Post by J. Waterreu » Sun, 18 Nov 2001 09:35:47


Hi Jim,

This could be simpler (if possible with your network software):
On your server make a drive g: also that is pointing to the c: drive of
that same machine.
Then you can use the same path on all machines.

Job


> Hi Steve,

> Thank you for the great suggestions.  I'm glad you cleared up matters
> on fullpath returning the path as if the file were in the default
> directory when it can't be found - that explains some of the results I
> had been getting.


> > I suggest you solve your problem by creating a small table on each
> > machine.  In that table have a field for the drive designation or even a
> > complete path.  Here's an example of how to do it:

> Not a bad idea.  It may require more re-programming than I feel like
> doing at the moment, but it seems thorough.  I'm not sure I like the 3
> separate tables in on 3 separate machines.  I might try one table with
> all the paths combined with the environment variable idea below.  Oh
> well, either way I knew it wouldn't be fun.

> >   CREATE TABLE MyPath ( PathToStuf C(40) )

> > On main machine, MyPath.PathToStuf could be populated with "C:\FOXDATA\"
> > while on the other two machines it would be "G:\FOXDATA\" (or however
> > you name your directories).  Inside the app, instead of

> >   USE c:\foxdata\thisfile

> > you would

> >   USE ( TRIM( MyPath.PathToStuf ) + "thisfile" )

> > we do this and it works very well.  You can just as easily put the path
> > into a PUBLIC memory variable if you prefer.

> > Another approach is to set a DOS environmental variable on each machine,
> > retrieve that value with GETENV(), then use that inside your program in
> > a manner similar to what I've described above.

> This is very close to what I had planned on doing if I found out
> fullpath wasn't going to give me what I wanted -- which it isn't.  I
> haven't thought it completely through, but on the surface it seems
> like it would require a little less programming.

> > FULLPATH("") will return the current drive and directory.  I use this
> > all the time to save the current path, e.g.,

> >   cCurPath = FULLPATH("")

> >   SET DEFAULT TO SomethingNew
> >   DO something in SomethingNew

> >   SET DEFAULT TO &cCurPath

> > If FULLPATH() can find what you're looking for, it will return the path
> > to the file, but if it can't, it will act as if the file you want is in
> > the current drive/directory.  FULLPATH() is, therefore, pretty useless
> > at finding a file unless you're sure it's in the current directory or on
> > the FoxPro search path.   You could always:

> >   IF FILE( FULLPATH( "myfile" ) )
> >       * We know it's really there
> >   ELSE
> >       * It can't be found
> >   ENDIF

> > -=S=-

> Thanks again,

> Jim

 
 
 

1. Getting Error 13, help - don't understand why

When you are using a Dynaset you have to be more descriptive with the SQL.
For a table you might be able to get away with that.

Try this:
Set rstLog = dbsPhoneForm.OpenRecordset("SELECT * FROM Log", dbOpenDynaset)

--
Richard Cardarelle
Eclipse Applications
www.eclipseapplications.com

Documents\PhoneForm\PhoneForm.mdb")

- Show quoted text -

2. JDBC study

3. I don't understand why this view is not updatable

4. Advice wanted on VAX dbms programs

5. I don't understand why this worked in 7.0 and now not in 2000

6. Concatenation of Text Column and Varchar Column?

7. Help: SO get's hidden and I don't understand why

8. VB 4.0 beginner

9. I don't understand ADO '-(

10. Cast and Schemas don't work as expected

11. Don't understand optimizer

12. don't understand sproc error message