Page 1 of 1
Default folder issue
Posted: Fri Jun 12, 2020 6:04 am
by Paramvir
Hi
I defined a path for getfile() function, but it does not honour it. It always open the last directory file path selected. Please see this code:
Code: Select all
CDEFAULTPATH:=diskname() + ":\" + CurDir()+"\PDF_REPORTS\"
cdir := GetFile( { { "PDF REPORT FILES", "*.PDF" }} ,;
" SELECT PDF REPORT FILE TO OPEN ",CDEFAULTPATH,,.T.)
What I want is that every time I run this function in my application, i should get the default folder as specified in the variable cdefaultpath. But Getfile() does not honour it and instead, it shows the last directory path actually used. I have tried changing .t. to .f. also but it has no effect. The variable cdefaultpath contains the correct value when i display it. Any idea to solve this issue? Thank you all.
Re: Default folder issue
Posted: Fri Jun 12, 2020 6:48 am
by dragancesu
Are cDeafaulPath folder exsist? When not exsist result is unpredictable
Re: Default folder issue
Posted: Fri Jun 12, 2020 7:09 am
by Paramvir
dragancesu wrote: ↑Fri Jun 12, 2020 6:48 am
Are cDeafaulPath folder exsist? When not exsist result is unpredictable
Thank you Dragancesu.
cDEFAULTPATH, as you see, is a variable name that stores the path I require by using curdir() and a folder named pdf_reports. The folder pdf_reports pre-exists and i created it to store pdf report files. In fact when i retrieve cdefaultpath value, it correctly displays the complete path.
Re: Default folder issue
Posted: Fri Jun 12, 2020 8:12 am
by AUGE_OHR
hi,
4th Parameter in your code is missing ... hm
try Demo c:\hmg.3.4.4\SAMPLES\Functions\GETFILE\demo.prg
Re: Default folder issue
Posted: Fri Jun 12, 2020 9:02 am
by Paramvir
AUGE_OHR wrote: ↑Fri Jun 12, 2020 8:12 am
hi,
4th Parameter in your code is missing ... hm
try Demo c:\hmg.3.4.4\SAMPLES\Functions\GETFILE\demo.prg
Thank you Auge_Ohr.
As per the HMG Reference, the 4th parameter is for multiselect of files:
/*
Syntax:
GetFile ( acFilter ,
cTitle ,
cDefaultPath ,
lMultiSelect ,
lNoChangeDir ,
nFilterIndex ) --> SelectedFileName(s)
Tips:
- If <lMultiSelect> option is used, a character array containing selected filenames is returned (maximun number of selected files returned is 1024).
- If <lNoChangeDir> option is omitted, default value is .F.
- If passed <nFilterIndex> by reference, will return index of file filter selected by user
*/
So the 4th parameter can be .t. or .f. I gave it .f. and rebuilt the app but still the same issue. The issue is that Getfile function seems to ignore the variable cdefaultpath and just remembers the last folder actually used.
Re: Default folder issue
Posted: Fri Jun 12, 2020 9:20 am
by Paramvir
Thank you Dragancesu and Auge_Ohr.
The problem is solved.
A small but costly syntax error on my part:
CDEFAULTPATH:=diskname() + ":\" + CurDir()+"\PDF_REPORTS\"
I shouldn't have used "\" at the end.
Thank you all
Re: Default folder issue
Posted: Fri Jun 12, 2020 11:42 am
by bpd2000
Check with
Code: Select all
// nice function to know current working directory
// usage:
Function Main
local msg := hb_cwd()
msginfo(msg ,"Current path: hb_cwd()")
msginfo(win_GetShortPathName( msg ),"win_GetShortPathName")
msginfo(hb_dirBase() ,"hb_dirBase() ")
msginfo(GetStartupFolder(),"GetStartupFolder()")
return nil
FUNCTION win_GetShortPathName( cPath )
LOCAL cShort := Space(5000)
wapi_GetShortPathName( cPath, @cShort, Len( cShort) )
RETURN cShort
Re: Default folder issue
Posted: Sat Jun 13, 2020 1:57 pm
by Paramvir
bpd2000 wrote: ↑Fri Jun 12, 2020 11:42 am
Check with
Code: Select all
// nice function to know current working directory
// usage:
Function Main
local msg := hb_cwd()
msginfo(msg ,"Current path: hb_cwd()")
msginfo(win_GetShortPathName( msg ),"win_GetShortPathName")
msginfo(hb_dirBase() ,"hb_dirBase() ")
msginfo(GetStartupFolder(),"GetStartupFolder()")
return nil
FUNCTION win_GetShortPathName( cPath )
LOCAL cShort := Space(5000)
wapi_GetShortPathName( cPath, @cShort, Len( cShort) )
RETURN cShort
Thank you. These are indeed very good directory functions.