FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour save dir
Posts: 3107
Joined: Fri Oct 07, 2005 06:28 PM
save dir
Posted: Thu Apr 14, 2011 08:04 AM

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 ?

Best Regards, Saludos



Falconi Silvio
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Re: save dir
Posted: Thu Apr 14, 2011 11:36 AM

Just save and load the bitmaps to ".\bitmaps\"

James

FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 3107
Joined: Fri Oct 07, 2005 06:28 PM
Re: save dir
Posted: Thu Apr 14, 2011 11:42 AM

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

Best Regards, Saludos



Falconi Silvio
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Re: save dir
Posted: Thu Apr 14, 2011 01:10 PM
Code (fw): Select all Collapse
#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
FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 3107
Joined: Fri Oct 07, 2005 06:28 PM
Re: save dir
Posted: Thu Apr 14, 2011 07:13 PM

THIS GIVE ME
.\BITMAPS\
AND NOT
.\BITMAPS\NAMEBMP.BMP

Best Regards, Saludos



Falconi Silvio
Posts: 4043
Joined: Wed Dec 19, 2007 06:40 PM
Re: save dir
Posted: Thu Apr 14, 2011 08:58 PM
Silvio,

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.
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Re: save dir
Posted: Thu Apr 14, 2011 09:37 PM

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

FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 3107
Joined: Fri Oct 07, 2005 06:28 PM
Re: save dir
Posted: Fri Apr 15, 2011 06:36 AM

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

Best Regards, Saludos



Falconi Silvio

Continue the discussion