Page 1 of 1

GETFILE()

Posted: Thu Feb 08, 2018 6:24 pm
by serge_girard
Hello,

I notice strange behaviour with the GETFILE() function (or is it me making a mistake?)

I want to open the System Dialog at my StartUpFolder. So I code this:

Code: Select all

PUBLIC cCurrentSRT    := GetStartUpFolder()  
Msginfo(cCurrentSRT)  // OK correct folder !

DO WHILE TRUE
   cMAIL  := Getfile ( { {'CSV Files','*.CSV'}  } , 'CSV',  cCurrentSRT + '\' , .f. ,   .f. )  // Gives last opened folder !!!
   IF EMPTY(cMAIL)   
      RETURN
   ENDIF

   IF !FILE(cMAIL)
      MSGINFO(cMAIL + ' does not exist!')
      RETURN
   ENDIF

   EXIT
ENDDO

oFile := TFileRead():New( cMAIL )
...etc.....

The GETFILE however is always opening the folder I used before instead of the startupfolder.

Am I doing something wrong or what ?

Serge

Re: GETFILE()

Posted: Thu Feb 08, 2018 10:14 pm
by trmpluym
Serge,

You need to remove the part

Code: Select all

+ "\"
see this example:

Code: Select all

*------------------------------------------------------------*
#include <hmg.ch>
*------------------------------------------------------------*
PROC MAIN

PUBLIC cCurrentSRT    := GetStartUpFolder() 
 
Msginfo(cCurrentSRT)  // OK correct folder !

DO WHILE .T.
   cMAIL  := Getfile ( { {'CSV Files','*.CSV'}  } , 'CSV',  cCurrentSRT , .f. ,   .f. )  // Gives last opened folder !!!

   IF EMPTY(cMAIL)   
      RETURN
   ENDIF           
   
   MsgDebug(cMAIL)

ENDDO

RETU
*------------------------------------------------------------*
Theo

Re: GETFILE()

Posted: Fri Feb 09, 2018 11:00 am
by serge_girard
Thx Theo !

Rathi, some demo's need to be corrected (Samples\getfile\demo.prg)

Serge

Re: GETFILE()

Posted: Fri Feb 09, 2018 12:53 pm
by trmpluym
Serge, Rathi,

Maybe better to change the Getfile function to check if the last character is "\" and when it is "\" remove it.

This way it is more robust to use.

Another wish for 3.4.5 :D

Theo

Re: GETFILE()

Posted: Fri Feb 09, 2018 2:48 pm
by serge_girard
Better indeed !

Serge