Page 1 of 1

Also for filename and subdir Resolved

Posted: Sun Mar 15, 2020 5:27 pm
by Silvio.Falconi
I have a file image on

cPathMask:="C:\Work\Prg\WinBeach\bitmaps\servizi\pattino.png"

the image is pattino.png

I wish save on record (dbf) only bitmaps\servizi\pattino.png

I saw also filename.prg and not found a solution

Function test()

Local cIniFile := cFilePath( GetModuleFileName( GetInstance() ) ) + "Test.ini"
Local cExePath := cFilePath( GetModuleFileName( GetInstance() ) )

Local cSerPath := GetIni( cIniFile, "Config", "Ser", cExePath+"bitmaps"+"\servizi\")
Local cPathMask:="C:\Work\Prg\WinBeach\bitmaps\servizi\pattino.png"
Local only_Image := cFileNoPath( cPathMask )
? only_Image
nSTART := RAT( "\", only_Image )
?SUBSTR(cPathMask,1,nSTART-1)
any solution please

Re: Also for filename and subdir

Posted: Sun Mar 15, 2020 11:20 pm
by cnavarro
Excuse me, I don't understand what you need
I attach some code

Code: Select all

Function Main()
Local cIniFile := cFilePath( GetModuleFileName( GetInstance() ) ) + "Test.ini"
Local cExePath := cFilePath( hb_Argv(0)  ) //cFilePath( GetModuleFileName( GetInstance() ) )
Local nStART
//Local cSerPath := GetIni( cIniFile, "Config", "Ser", cExePath+"bitmaps"+"\servizi\")
Local cPathMask:="C:\Work\Prg\WinBeach\bitmaps\servizi\pattino.png"
Local only_Image := cFileNoPath( cPathMask )
? cExePath
? only_Image
//nSTART := RAT( "\", only_Image )    // If you apply cFileNoPath to cPathMask, it is impossible obtain any "\"
nSTART := RAT( "\", cPathMask )
? SUBSTR( cPathMask, 1, nSTART - 1 ), cFilePAth( cPathMask )
Return nil



Re: Also for filename and subdir

Posted: Mon Mar 16, 2020 12:06 pm
by Silvio.Falconi
I need it return me " .\bitmaps\servizi\pattino.png"

I wish erase cExePath from "C:\Work\Prg\WinBeach\bitmaps\servizi\pattino.png"
cEXePath is "C:\Work\Prg\WinBeach\"

Re: Also for filename and subdir

Posted: Mon Mar 16, 2020 1:26 pm
by cnavarro
Silvio.Falconi wrote:I need it return me " .\bitmaps\servizi\pattino.png"

I wish erase cExePath from "C:\Work\Prg\WinBeach\bitmaps\servizi\pattino.png"
cEXePath is "C:\Work\Prg\WinBeach\"
Then

Code: Select all

? StrTran( "C:\Work\Prg\WinBeach\bitmaps\servizi\pattino.png", cExePath, "" )
 

Re: Also for filename and subdir

Posted: Mon Mar 16, 2020 7:07 pm
by Silvio.Falconi
Nice!
Thanks