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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

path and directories.... 1

Status
Not open for further replies.

Mandy_crw

Programmer
Jul 23, 2020
585
PH
hi everyone... is there a way that i dont have to specify the c:\ for my pictures? Because i always change the path everytime i create an exe file for another computer... then i i need to edit, i need to change it again to original path for the pictures to appear.... thanks in advanced....


DEFINE CLASS StudentRec AS Form

showwindow = 2
*Picture = "C:\Program Files\SCMS Info Wave\Img\background3.jpg"
*_screen.controlbox = .f.
DataSession = 2
Height = 650
Width =1095
minbutton = .t.
BorderStyle=2
Maxbutton =.f.
Autocenter = .t.
Alwaysontop = .f.
Caption = "SCMS Students Account Record 2021!"

ADD OBJECT image11 AS image WITH ;
Picture = "C:\Program Files\SCMS Info Wave\Img\banner.png", ;
Stretch = 2, ;
Height = 178, ;
Left = 1, ;
Top = 1, ;
borderstyle = 0,;
Width = 746, ;
Name = "Image11",;
visible = .t.

ADD OBJECT image10 AS image WITH ;
Picture = "C:\Program Files\SCMS Info Wave\Img\banner side.gif",;
Stretch = 2, ;
Height = 620, ;
Left = 750, ;
Top = 1, ;
borderstyle = 0,;
Width = 340, ;
Name = "Image10",;
visible = .t.
 
Mandy, first point is that you should not be storing your images in a directory below Program Files. In fact, you should not be using directories below program files for any data that might change or move or be updated or deleted within your application.

Second point: you should not be hard-coding the paths to your directories. As you have discovered, these paths could be different on different computers, and you don't want to have to keep changing them.

The best approach is to store your paths in some sort of configuration file. I use an INI file for that, but you could also use a plain text file, a DBF or an entry in the Windows Registry. The point is that it should be somewhere that is easy to access and to edit.

Your program can then access the path, and use it in place of the hard-coded path. And the easiest way to do that is with SET PATH ... ADDITIVE. That way, you just set it once; you won't need to refer to it again each time you want to open a file.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Oh.... thank you Mike... you always answer my query in a very comprehensive way.... You're a very good Teacher.... Thanks and God bless you...
 
I do it another way. First my programs should never be in Program Files.
They are always installed on a server and it does not matter what the directory is called, but pictures are installed in HOME()+'\IMGS'
 
Mandy,

When you create an EXE, the images set in image Picture properties are automatically added to the project (See "Other Files" in your Project Manager) and become part of the compiled EXE. You do not need to distribute the images with the EXE. You should be able to distribute the same EXE to multiple computers. Is there a reason why you are compiling seperate EXEs? Also, the Program Files folder is used for 64bit applications and the Program Files (x86) folder is used for 32bit applications as a best practice. Below is a partial screen shot of a project with 91 forms and over 150 images. I compile once and distribute to a few hundred machines. Of course, if you have OCXs, DLLs, FLLs, etc., you will have to distribute those along with the VFP runtimes.

I disagree with Mike's statement about harded paths. We use them all the time. Example:
Code:
goApp("Forms").AddNew("cfrmemailsend","c:\fxframe\projects\mediabits\uicontrols\lbforms.vcx", "", "cfrmsendemail")
The VFP compiler is smarter than many people think. I can move the EXE to another folder and it will run fine. There are exceptions - the EXE still has to find external files (eg OCXs, DLLs, FLLs) that are not included and not compiled into the EXE. Also, SET PATH should be used and set to the EXE folder

Capture18_wpxbpb.png
 
Hi vernpace... yes I compile for the picture... and everytime i put in another computer i would edit the path of the images, then compile for an exe again... and its confusing sometimes... Thank you vernpace...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top