GETFILE()

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

Post Reply
User avatar
serge_girard
Posts: 3165
Joined: Sun Nov 25, 2012 2:44 pm
DBs Used: 1 MySQL - MariaDB
2 DBF
Location: Belgium
Contact:

GETFILE()

Post 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
There's nothing you can do that can't be done...
trmpluym
Posts: 303
Joined: Tue Jul 15, 2014 6:52 pm
Location: The Netherlands

Re: GETFILE()

Post 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
User avatar
serge_girard
Posts: 3165
Joined: Sun Nov 25, 2012 2:44 pm
DBs Used: 1 MySQL - MariaDB
2 DBF
Location: Belgium
Contact:

Re: GETFILE()

Post by serge_girard »

Thx Theo !

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

Serge
There's nothing you can do that can't be done...
trmpluym
Posts: 303
Joined: Tue Jul 15, 2014 6:52 pm
Location: The Netherlands

Re: GETFILE()

Post 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
User avatar
serge_girard
Posts: 3165
Joined: Sun Nov 25, 2012 2:44 pm
DBs Used: 1 MySQL - MariaDB
2 DBF
Location: Belgium
Contact:

Re: GETFILE()

Post by serge_girard »

Better indeed !

Serge
There's nothing you can do that can't be done...
Post Reply