Help with PutFile()

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

MGOLDFARB
Posts: 71
Joined: Thu Jun 21, 2012 7:46 am

Help with PutFile()

Post by MGOLDFARB »

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.
User avatar
danielmaximiliano
Posts: 2611
Joined: Fri Apr 09, 2010 4:53 pm
Location: Argentina
Contact:

Re: Help with PutFile()

Post by danielmaximiliano »

Hi :
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
User avatar
esgici
Posts: 4543
Joined: Wed Jul 30, 2008 9:17 pm
DBs Used: DBF
Location: iskenderun / Turkiye
Contact:

Re: Help with PutFile()

Post by esgici »

MGOLDFARB 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.
Hi Mark

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")
or simply you have seen in an another place.

Happy HMG'ing :D
Viva INTERNATIONAL HMG :D
MGOLDFARB
Posts: 71
Joined: Thu Jun 21, 2012 7:46 am

Re: Help with PutFile()

Post by MGOLDFARB »

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!
User avatar
esgici
Posts: 4543
Joined: Wed Jul 30, 2008 9:17 pm
DBs Used: DBF
Location: iskenderun / Turkiye
Contact:

Re: Help with PutFile()

Post by esgici »

Hi Mark
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!
The example isn't for HMG.3xxx.

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 :D
MGOLDFARB
Posts: 71
Joined: Thu Jun 21, 2012 7:46 am

Re: Help with PutFile()

Post by MGOLDFARB »

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
User avatar
esgici
Posts: 4543
Joined: Wed Jul 30, 2008 9:17 pm
DBs Used: DBF
Location: iskenderun / Turkiye
Contact:

Re: Help with PutFile()

Post by esgici »

Hi Mark
MGOLDFARB wrote:... It would be great if this feature could be added to the putfile() function.
I hope you can use this until new release of HMG ( if you will like )

( 5P stand for 5th parameter)
Screen shoot of PutFile5P test prg
Screen shoot of PutFile5P test prg
PutFile5P.jpg (18.55 KiB) Viewed 4759 times
TestPF5P.zip
Source files for PutFile5P funcs and test prg
(1.37 KiB) Downloaded 382 times
Regards
Viva INTERNATIONAL HMG :D
MGOLDFARB
Posts: 71
Joined: Thu Jun 21, 2012 7:46 am

Re: Help with PutFile()

Post by MGOLDFARB »

You are amazing! Thank you!

Mark
User avatar
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()

Post by Rathinagiri »

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.
User avatar
esgici
Posts: 4543
Joined: Wed Jul 30, 2008 9:17 pm
DBs Used: DBF
Location: iskenderun / Turkiye
Contact:

Re: Help with PutFile()

Post by esgici »

MGOLDFARB wrote: Is there a function to open a file with a specific name, but without the selection box?
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: After I open the file, I am using the FWrite() function to populate the file.
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).

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 :D
Post Reply