Help with PutFile()
Moderator: Rathinagiri
Help with PutFile()
Hi. Is there a way to default the filename when using putfile()? I saw some posts about a fifth parameter that specifies the default file name, but when I tried the demo/sample, it did not work. I am probably doing something wrong - any help would be appreciated. Thanks.
- danielmaximiliano
- Posts: 2611
- Joined: Fri Apr 09, 2010 4:53 pm
- Location: Argentina
- Contact:
Re: Help with PutFile()
Hi :
This example work
This example work
Code: Select all
* (c) Jacek Kubica <kubica@wssk.wroc.pl>
*/
#include "minigui.ch"
Procedure Main
DEFINE WINDOW Win_1 ;
AT 0,0 ;
WIDTH 400 ;
HEIGHT 400 ;
TITLE 'Hello World!' ;
MAIN
DEFINE MAIN MENU
POPUP 'Common &Dialog Functions'
ITEM 'PutFile() without default file name' ;
ACTION MsgInfo ( Putfile ( { {'jpg Files','*.jpg'} , {'gif Files','*.gif'} } , 'Save Image As' , 'C:\' ) )
ITEM 'PutFile() without default extension' ;
ACTION MsgInfo ( Putfile ( { {'jpg Files','*.jpg'} , {'gif Files','*.gif'} } , 'Save Image As' , 'C:\' , ;
.f., "My_picture" ) )
ITEM 'PutFile() with default filename - My_picture.jpg' ;
ACTION MsgInfo ( Putfile ( { {'jpg Files','*.jpg'} , {'gif Files','*.gif'} } , 'Save Image As' , 'C:\' , ;
.f., "My_picture.jpg" ) )
END POPUP
END MENU
END WINDOW
CENTER WINDOW Win_1
ACTIVATE WINDOW Win_1
Return
*´¨)
¸.·´¸.·*´¨) ¸.·*¨)
(¸.·´. (¸.·` *
.·`. Harbour/HMG : It's magic !
(¸.·``··*
Saludos / Regards
DaNiElMaXiMiLiAnO
Whatsapp. := +54901169026142
Telegram Name := DaNiElMaXiMiLiAnO
¸.·´¸.·*´¨) ¸.·*¨)
(¸.·´. (¸.·` *
.·`. Harbour/HMG : It's magic !
(¸.·``··*
Saludos / Regards
DaNiElMaXiMiLiAnO
Whatsapp. := +54901169026142
Telegram Name := DaNiElMaXiMiLiAnO
- esgici
- Posts: 4543
- Joined: Wed Jul 30, 2008 9:17 pm
- DBs Used: DBF
- Location: iskenderun / Turkiye
- Contact:
Re: Help with PutFile()
Hi MarkMGOLDFARB wrote:Hi. Is there a way to default the filename when using putfile()? I saw some posts about a fifth parameter that specifies the default file name, but when I tried the demo/sample, it did not work. I am probably doing something wrong - any help would be appreciated. Thanks.
Parameter(s) more than four simply ignored by PutFile().
May be you are remembering something like this :
Code: Select all
Cfile:=putfile({{'txt','*.txt'},{'Configuracion','*.ini'}},"Grab\arArchivo")
Happy HMG'ing
Viva INTERNATIONAL HMG
Re: Help with PutFile()
Thank you both.
Daniel, the example you gave did not work for me.
Based on what Esgici wrote, there seems to be no way to default the filename. Am I missing something here? Should I be using a different function?
Thanks!
Daniel, the example you gave did not work for me.
Based on what Esgici wrote, there seems to be no way to default the filename. Am I missing something here? Should I be using a different function?
Thanks!
- esgici
- Posts: 4543
- Joined: Wed Jul 30, 2008 9:17 pm
- DBs Used: DBF
- Location: iskenderun / Turkiye
- Contact:
Re: Help with PutFile()
Hi Mark
Different function or different library
By the way, what importance with this default file name ?
This function is based on "Save As..." dialog of Windows. Yes, Windows allow specify a default file name in this dialog. But IMO this isn't so important. Let user to define his / her new file name any way he / she like
Regards
PS: To Rathi : Will be possible a little modification in f.PutFile() ( h_dialogs.prg ) and f.C_PutFile() ( in c_dialogs.c ) in the next release ?
The example isn't for HMG.3xxx.MGOLDFARB wrote:Thank you both.
Daniel, the example you gave did not work for me.
Based on what Esgici wrote, there seems to be no way to default the filename. Am I missing something here? Should I be using a different function?
Thanks!
Different function or different library
By the way, what importance with this default file name ?
This function is based on "Save As..." dialog of Windows. Yes, Windows allow specify a default file name in this dialog. But IMO this isn't so important. Let user to define his / her new file name any way he / she like
Regards
PS: To Rathi : Will be possible a little modification in f.PutFile() ( h_dialogs.prg ) and f.C_PutFile() ( in c_dialogs.c ) in the next release ?
Viva INTERNATIONAL HMG
Re: Help with PutFile()
Normally the file name should be the users choice, but in this case, the file name is required by entity that they need to send the file to. It would be great if this feature could be added to the putfile() function.
Is there a function to open a file with a specific name, but without the selection box? After I open the file, I am using the FWrite() function to populate the file.
Thanks again for the assist.
Mark
Is there a function to open a file with a specific name, but without the selection box? After I open the file, I am using the FWrite() function to populate the file.
Thanks again for the assist.
Mark
- esgici
- Posts: 4543
- Joined: Wed Jul 30, 2008 9:17 pm
- DBs Used: DBF
- Location: iskenderun / Turkiye
- Contact:
Re: Help with PutFile()
Hi Mark
( 5P stand for 5th parameter)
Regards
I hope you can use this until new release of HMG ( if you will like )MGOLDFARB wrote:... It would be great if this feature could be added to the putfile() function.
( 5P stand for 5th parameter)
Regards
Viva INTERNATIONAL HMG
Re: Help with PutFile()
You are amazing! Thank you!
Mark
Mark
- Rathinagiri
- Posts: 5471
- Joined: Tue Jul 29, 2008 6:30 pm
- DBs Used: MariaDB, SQLite, SQLCipher and MySQL
- Location: Sivakasi, India
- Contact:
Re: Help with PutFile()
Ok. Esgici. I will go through and include.
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
South or North HMG is worth.
...the possibilities are endless.
- esgici
- Posts: 4543
- Joined: Wed Jul 30, 2008 9:17 pm
- DBs Used: DBF
- Location: iskenderun / Turkiye
- Contact:
Re: Help with PutFile()
Yes, you can detect existence of a file with a specific name by FILE() ( or HB_FileExist() ) function and then open by FOPEN() function. Also you can determine file existence by directly using FOPEN(): If FOPEN() returns a negative value and FERROR() returns 2, file is not exist.MGOLDFARB wrote: Is there a function to open a file with a specific name, but without the selection box?
For text-only content you can use some other methods, like MEMOWRIT(), HB_MEMOWRIT() and so on ( In fact, these two function can write also non-text content).MGOLDFARB wrote: After I open the file, I am using the FWrite() function to populate the file.
By the way, a little warn about PutFile() :
Although its name is "Put", this function doesn't "put" anything to anywhere; that is it don't write anything to disk. It only return a file name ( or empty string if user not selected anything). File that name returned by PutFile() may exist or not. This is only difference between PutFile() and GetFile(); the second return only name of an existing file.
Therefore PutFile() function doesn't check overwrite status. This is totally responsibility of programmer and if not care, PutFile() become a dangerous tool. The "Default File Name" and network environments will increase the risk.
Of course no problem for intentionally overwrite.
Regards
Viva INTERNATIONAL HMG