when I load a bitmaps the function getdir save on cDir all directory
for sample
c:\work\prg\codici\bitmaps\xxx.bmp
I wish only .\bitmaps\xxx.bmp
because if I insert the exe to another folder or pc it not found the bitmaps
any idea ?
save dir
- James Bott
- Posts: 4654
- Joined: Fri Nov 18, 2005 4:52 pm
- Location: San Diego, California, USA
- Contact:
Re: save dir
Just save and load the bitmaps to ".\bitmaps\"
James
James
Re: save dir
James,
I have on dialog
@ 40, 10 SAY "Image:" OF oDlg SIZE 21, 8 PIXEL
@ 38, 39 GET aGet[3] var cTabImage OF oDlg SIZE 205, 12 PIXEL
@ 38, 263 BUTTON oBtnSel PROMPT "..." OF oDlg PIXEL SIZE 10, 9 ;
ACTION ( cTabImage:=cGetFile( "*.*", "Select a file" ),;
aGet[3]:refresh())
FUNCTION GetDir( oGet )
LOCAL cFile
cFile := cGetDir32()
IF ! empty( cFile )
oGet:cText := cFile + "\"
ENDIF
RETURN nil
and it take c:\work\prg\codici\bitmaps\xxx.bmp
I have on dialog
@ 40, 10 SAY "Image:" OF oDlg SIZE 21, 8 PIXEL
@ 38, 39 GET aGet[3] var cTabImage OF oDlg SIZE 205, 12 PIXEL
@ 38, 263 BUTTON oBtnSel PROMPT "..." OF oDlg PIXEL SIZE 10, 9 ;
ACTION ( cTabImage:=cGetFile( "*.*", "Select a file" ),;
aGet[3]:refresh())
FUNCTION GetDir( oGet )
LOCAL cFile
cFile := cGetDir32()
IF ! empty( cFile )
oGet:cText := cFile + "\"
ENDIF
RETURN nil
and it take c:\work\prg\codici\bitmaps\xxx.bmp
Best Regards, Saludos
Falconi Silvio
Falconi Silvio
- James Bott
- Posts: 4654
- Joined: Fri Nov 18, 2005 4:52 pm
- Location: San Diego, California, USA
- Contact:
Re: save dir
Code: Select all
#include "fivewin.ch"
function main()
local cFile:="c:\work\prg\codici\bitmaps\xxx.bm"
msgInfo( relativePath( cFile ) )
return nil
Function RelativePath( cFile )
local cPath, cRelPath, cTemp
cPath:= cFilePath(cFile)
cTemp:= left(cPath,len(cPath)-1)
cRelPath:= "." + right(cPath, len(cPath) + 1 - rat("\",cTemp) )
return cRelPath
Re: save dir
THIS GIVE ME
.\BITMAPS\
AND NOT
.\BITMAPS\NAMEBMP.BMP
.\BITMAPS\
AND NOT
.\BITMAPS\NAMEBMP.BMP
Best Regards, Saludos
Falconi Silvio
Falconi Silvio
Re: save dir
Silvio,
You can still add :
relativePath( cFile ) + cFileNoPath( cFile )
to add the Filename.
Best Regards
Uwe
You can still add :
relativePath( cFile ) + cFileNoPath( cFile )
to add the Filename.
Best Regards
Uwe
Since 1995 ( the first release of FW 1.9 )
i work with FW.
If you have any questions about special functions, maybe i can help.
i work with FW.
If you have any questions about special functions, maybe i can help.
- James Bott
- Posts: 4654
- Joined: Fri Nov 18, 2005 4:52 pm
- Location: San Diego, California, USA
- Contact:
Re: save dir
Silvio,
I re-read you original message, and you are allowing users to select files from any directory (you are when using cGetFile()), then you need to store the directory with the filename. Using my relative directory will only work if they select files from a subdirectory of the EXE.
If you move the EXE and the data file where you have stored the selected files, (which contains the relative path), files will fail to be found if the user did not select a file from a subdirectory of the original EXE.
I note that the function RelativePath() really has a flaw in that it expects the selected file to be in a subdirectory of the EXE. If the user selects a file from somewhere else, it will return the wrong relative path.
I think the best solution is to store all bitmaps in the .\bitmaps subdirectory of the EXE. If the user selects a bitmap from somewhere else, then you could copy it to the .\bitmaps subdirectory. Then you could just store the filename and hardcode the path ".\bitmaps" in your code.
Alternately, you could not use cGetFile() function and just show a list of all bitmaps in the .\bitmap directory. This would prevent users from loading bitmaps from another location.
You should probably also have an error trap in your code if the bitmap is not found when the EXE is attempting to load it. Upon this error, you could offer the user a chance to select a new bitmap or just provide a default bitmap until the user does want to select one.
James
I re-read you original message, and you are allowing users to select files from any directory (you are when using cGetFile()), then you need to store the directory with the filename. Using my relative directory will only work if they select files from a subdirectory of the EXE.
If you move the EXE and the data file where you have stored the selected files, (which contains the relative path), files will fail to be found if the user did not select a file from a subdirectory of the original EXE.
I note that the function RelativePath() really has a flaw in that it expects the selected file to be in a subdirectory of the EXE. If the user selects a file from somewhere else, it will return the wrong relative path.
I think the best solution is to store all bitmaps in the .\bitmaps subdirectory of the EXE. If the user selects a bitmap from somewhere else, then you could copy it to the .\bitmaps subdirectory. Then you could just store the filename and hardcode the path ".\bitmaps" in your code.
Alternately, you could not use cGetFile() function and just show a list of all bitmaps in the .\bitmap directory. This would prevent users from loading bitmaps from another location.
You should probably also have an error trap in your code if the bitmap is not found when the EXE is attempting to load it. Upon this error, you could offer the user a chance to select a new bitmap or just provide a default bitmap until the user does want to select one.
James
Re: save dir
James ,
I use also for backup or restore this
cPath := cFilePath(GetModuleFileName(GetInstance()))+SUBSTR(cPath,2)
But I not Know where the user take the bitmaps , and I cannot use a BitmapsPath Fix
I try to use the application on another pc but then it not run because on first pc I have a bitmaps into a folder and the 2 pc I have the bitmaps on another folder
I believe it can be usell if the procedure when the user when take the bitmaps save the bitmaps on his folder sample .\bitmaps\ and save on archive the right
path .\bitmaps\namebmp.bmp then the user can use th e application on another pc with no problem
I use also for backup or restore this
cPath := cFilePath(GetModuleFileName(GetInstance()))+SUBSTR(cPath,2)
But I not Know where the user take the bitmaps , and I cannot use a BitmapsPath Fix
I try to use the application on another pc but then it not run because on first pc I have a bitmaps into a folder and the 2 pc I have the bitmaps on another folder
I believe it can be usell if the procedure when the user when take the bitmaps save the bitmaps on his folder sample .\bitmaps\ and save on archive the right
path .\bitmaps\namebmp.bmp then the user can use th e application on another pc with no problem
Best Regards, Saludos
Falconi Silvio
Falconi Silvio