Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Location of VCX file

Status
Not open for further replies.

andy0923

Programmer
Jul 26, 2002
65
US
Hello Everyone

Hope this is not too dumb a question as I dont have too much experience using classes.

What code could be recommended to make the location of a class library independent of a particular drive letter?

In other words, I would like to use a form (compiled through IDE or EXE) on one computer where the vcx might be located on c:\foxpro\mylibrary.vcx while on a laptop or another computer it might be f:\user\library.vcx.

I keep thinking a simple if or iif or icase statement would help the mess i find myself in with error instantiating class/unable to find........

Thanks for any help
 
Hi,
I suppose the class is in a project. So make sure on both machine's both directory's have same structure. So e.g. on pcA you could have D:\myProject\data; D:\myproject\Classes e.s.o. on while on pcB you could have E:\FoxFiles\ClientA\MyProject\data ; E:\FoxFiles\ClientA\MyProject\CLasses e.s.o.
Now you construct for each pc an own private startapp.prg to you make sure the default is either D:\myProject or D:\FoxFiles\ClientA. Than you call a routine to construct your path with all relevant subdirectories like in this case data;\Classes e.s.o.
In this way you can switch from between both pc when project is still under construction.
When project is finished and you have made an app, exe or dll it will work on any pc since everything is compiled by VFP.
Good luck!
Jockey(2)
 
Thanks so much for your response.

Not necessarily in projects. some forms are called from prg while others are called in ide with a do form command.

 
As long as all the files are on a single drive and the relative locations of the files are the same, you shouldn't have problems.

Tamar
 
Unfortunately that is the problem, they are not on the same drive as noted above.
 
>>Unfortunately that is the problem, they are not on the same drive as noted above

The you have a problem! The reason is that VFP uses relative paths to locate referenced files UNLESS things are on different physical drives in which case it includes the drive letter.

Really the only thing to do is NOT to keep your VCX files on different drives because then you can simply set paths and everything will work. You don't have to keep them in the same directory - just on the same drive!


----
Andy Kramek
Visual FoxPro MVP
 
What you could do is blend the different drive into a folder an the same drive to enable relative paths to the VCXes.

a) create an empty (!) new folder on an NTFS partition
b) start windows Disk Management
c) right clik on the drive, where VCXes are located to activate the context menu
d) choose "change drive letters and paths"
e) click "Add"
f) in the following dialog you can choose the empty NTFS folder created in a) to blend in the drives contents in that folder.

From then on you can access the VCXes with their old drive letter, or as content of that folder.

There's also the other way around, you can use the DOS command SUBST to blend in some filled folder as a new drive letter. See HELP SUBST in a dos console.

Despite that, when compiled into an exe paths, even relative paths become irrelevant, as the vfp runtime will always look for the classes compiled into the exe file first.

While debugging a project SET CLASSLIB, SET PROCEDURE and both at development and runtime SET PATH helps to point vfp to the locations to look for VCXes, PRGs and files in general.

Bye, Olaf.
 
Thanks again, Olaf. I considered all of that. Matter of fact, partitioning the drive is what got me into this mess in the first place. Afraid to use SUBST.

Made a decision to keep all VCX'x on C drive. Life will be simpler that way.
 
>>Made a decision to keep all VCX'x on C drive. Life will be simpler that way.

It's not just a question of WHERE the VCX's are, it's a matter of where they are IN RELATION to your application!

If you create your forms on a different drive from the VCXs that define the classes used, then you will still have the same problem because the references to the VCX will still include the drive letter!

To avoid the issue you need to keep your whole project on on the same physical drive - not just the VCXs!

----
Andy Kramek
Visual FoxPro MVP
 
My 10 cents; Make life easier for yourself and others who may have to maintain your application by creating a folder and subfolders. One for Databases, forms, classes, reports etc. In your startup program set a path to all of them. This will ease the development. Once the application is compiled all this becomes moot as the exe will use the forms, reports and classes, compiled within it.
 
You are correct Andy as well - have run into numerous other issues with forms and config.

For a fulltime developer, Inaginecorp, your suggestion makes perfect sense as well.
 
It's true that lief is easiest, if you have all project files on one drive within one main project folder and several subfolders.

From my experience blending in a drive as a subfolder via disk management is very helpful to get a quasi situation of all the project and project related files seemingly to be on one drive, while they stay on different drives.

And the diametral SUBST command which blends in a folder as a new drive is useful if you eg have a large backend of data stored on a LAN drive, but work on a notbook disconnected from the LAN and need to "emulate" that LAN drive.

It's always best to keep the files together, but if you would have to cope with several file repositories where to store data, classes etc. on seperate drives, disk management would be your life saver.

Bye, Olaf.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top