GETFILE()

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

Post Reply
User avatar
serge_girard
Posts: 2140
Joined: Sun Nov 25, 2012 2:44 pm
DBs Used: 1 MySQL - MariaDB
2 DBF
Location: Belgium
Has thanked: 449 times
Been thanked: 102 times
Contact:

GETFILE()

Post by serge_girard » Thu Feb 08, 2018 6:24 pm

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

trmpluym
Posts: 229
Joined: Tue Jul 15, 2014 6:52 pm
Location: The Netherlands
Has thanked: 5 times
Been thanked: 19 times

Post by trmpluym » Thu Feb 08, 2018 10:14 pm

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

User avatar
serge_girard
Posts: 2140
Joined: Sun Nov 25, 2012 2:44 pm
DBs Used: 1 MySQL - MariaDB
2 DBF
Location: Belgium
Has thanked: 449 times
Been thanked: 102 times
Contact:

Post by serge_girard » Fri Feb 09, 2018 11:00 am

Thx Theo !

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

Serge

trmpluym
Posts: 229
Joined: Tue Jul 15, 2014 6:52 pm
Location: The Netherlands
Has thanked: 5 times
Been thanked: 19 times

Post by trmpluym » Fri Feb 09, 2018 12:53 pm

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

User avatar
serge_girard
Posts: 2140
Joined: Sun Nov 25, 2012 2:44 pm
DBs Used: 1 MySQL - MariaDB
2 DBF
Location: Belgium
Has thanked: 449 times
Been thanked: 102 times
Contact:

Post by serge_girard » Fri Feb 09, 2018 2:48 pm

Better indeed !

Serge

Post Reply