FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Image Path
Posts: 7317
Joined: Thu Oct 18, 2012 07:17 PM
Image Path
Posted: Wed Sep 05, 2018 11:00 PM

On a procedure I must save the Path of Image

the user can select an image from computer and insert on the record

When the procedure save the record , save also the path of the image

I wish have a path like ".\images\fineimage.png"

Where the ".\images\" is the default path sample cPathImage:= ".\images\"

  1. How I can have the name of the Image and the extension to save as ".\images\fineimage.png" ?
  2. When I save the image the procedure must copy the file image from the folder of Computer where the final user selected the image into cPathImage

Do you have a small test trying to make it ?

Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Image Path
Posted: Fri Sep 07, 2018 08:31 AM

Silvio,

  1. The returned value of cGetFile() contains the path and filename
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 7317
Joined: Thu Oct 18, 2012 07:17 PM
Re: Image Path
Posted: Fri Sep 07, 2018 08:42 AM
yes antonio

but I have for a sample C:\Program Files (x86)\EasyBeach\images\image.png

I wish only .\images\image.png

I remember there are some function but I not found it

Now I found on Harbour

hb_PathJoin( "C:\Temp", ".." ) ==> C:\..
hb_PathNormalize( hb_PathJoin( "C:\Temp", ".." ) ) ==> C:\..
hb_PathJoin( "C:\Temp\xxxx", ".." ) ==> C:\Temp\..
hb_PathNormalize( hb_PathJoin( "C:\Temp\xxxx", ".." ) ) ==> C:

but not run ok
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Re: Image Path
Posted: Mon Sep 10, 2018 02:53 PM

Silvio,

If you already know the full path including the filename, then you can get just the path like this:

cFilePath( "C:\Program Files (x86)\EasyBeach\images\image.png" )

cFilePath() is a built-in function.

I will return: "C:\Program Files (x86)\EasyBeach\images\" (without the quotes).

Is that what you need?

FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Re: Image Path
Posted: Mon Sep 10, 2018 04:33 PM
Silvio,

Or, maybe this is what you want?

Code (fw): Select all Collapse
#include "fivewin.ch"

Function Main()
   Local cImageLocation

   cImageLocation :="C:\Program Files (x86)\EasyBeach\images\image.png"

   msgInfo( myPath(cImageLocation),"myPath(cImageLocation)" )  // returns ".\images\image.png"

Return nil


Function MyPath(cPath)
   Local nNewPath,nPos,nNewPos
   cNewPath:= cFilePath(cPath)
   cNewPath:= left(cNewPath,len(cNewPath)-1) // strip off last \
   nPos:= RAT("\", cNewPath)                 // find pos of 2nd to last \
   nNewPos:= len(cPath) - nPos               
   cNewPath:= ".\" + right(cPath,nNewPos)
Return cNewPath
FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10

Continue the discussion