This is very usefull, because according File Type selected by user, can be defined which kind of file can be used for EXPORT proposes.esgici wrote: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 ?
Help with PutFile()
Moderator: Rathinagiri
- Pablo César
- Posts: 4059
- Joined: Wed Sep 08, 2010 1:18 pm
- Location: Curitiba - Brasil
Re: Help with PutFile()
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
- esgici
- Posts: 4543
- Joined: Wed Jul 30, 2008 9:17 pm
- DBs Used: DBF
- Location: iskenderun / Turkiye
- Contact:
Re: Help with PutFile()
Hola amigo PabloPablo César wrote:This is very usefull, because according File Type selected by user, can be defined which kind of file can be used for EXPORT proposes.esgici wrote: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 ?

Thanks to remind

This was not only a wish, it was implemented too

So, (if you like) you can use it without waiting included in legal HMG distribution by admin.
Happy HMG'ing

Viva INTERNATIONAL HMG 

- Pablo César
- Posts: 4059
- Joined: Wed Sep 08, 2010 1:18 pm
- Location: Curitiba - Brasil
Re: Help with PutFile()
Yeah, thanks for your tip. But it would be a common benefits to all when it will be in the next releases and Mr. Rathinagiri has already agreed with this implementation.esgici wrote:So, (if you like) you can use it without waiting included in legal HMG distribution by admin.

HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
- esgici
- Posts: 4543
- Joined: Wed Jul 30, 2008 9:17 pm
- DBs Used: DBF
- Location: iskenderun / Turkiye
- Contact:
Re: Help with PutFile()
Thanks, you are right; probably Mr. Diamond was forgot itPablo César wrote:Yeah, thanks for your tip. But it would be a common benefits to all when it will be in the next releases and Mr. Rathinagiri has already agreed with this implementation.

TIA

Viva INTERNATIONAL HMG 

- Pablo César
- Posts: 4059
- Joined: Wed Sep 08, 2010 1:18 pm
- Location: Curitiba - Brasil
Help with PutFile()
Yes, I guess so... for also this question I make an update reminder in Pendings for NEXT release ( REMINDER ).esgici wrote:Thanks, you are right; probably Mr. Diamond was forgot it
There is another question, very important now with UNICODE mode enhancements in this last HMG version, which it will demand some modification (like as C HMG_ functions) in your code of PutFile5P.prg
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
- esgici
- Posts: 4543
- Joined: Wed Jul 30, 2008 9:17 pm
- DBs Used: DBF
- Location: iskenderun / Turkiye
- Contact:
Re: Help with PutFile()
Which modification(s) may be required, would you specify pleasePablo César wrote:...There is another question, very important now with UNICODE mode enhancements in this last HMG version, which it will demand some modification (like as C HMG_ functions) in your code of PutFile5P.prg

Viva INTERNATIONAL HMG 

- Pablo César
- Posts: 4059
- Joined: Wed Sep 08, 2010 1:18 pm
- Location: Curitiba - Brasil
Help with PutFile()
Before answer this your question, let me put clear something I noted recentely.esgici wrote:Which modification(s) may be required, would you specify please
You Esgici are indicating a 5th parameter for default indicated file at InputFile dialog. In other words and sample: By picture you can see where affects: But I as thinking in another parameter which allows to know the number option of array passed as at first parameter:
Note first parameter is an array with two elements (two types of files: TXT & PRG) and by this extra parameter, we supose to take which one have been choosen by user (as above image showing).
One good example is C:\MiniGUI\SAMPLES\Applications\DBFview\source\DBFview.prg (see below part of it):
Code: Select all
Static Procedure ExportData()
Local cExt, cSaveFile, nIndex := 1, cAlias, nRecno
IF !Empty(nFocus)
cSaveFile := PutFile( { {"DBF files (*.dbf)", "*.dbf"}, {"Text files (*.txt)", "*.txt"}, ;
{"Data files (*.dat)", "*.dat"}, {"Excel files (*.xls)", "*.xls"}, ;
{"Clipper, Foxpro files (*.prg)", "*.prg"}, {"All files (*.*)", "*.*"} }, , , , @nIndex )
IF !Empty( cSaveFile )
IF nIndex == 2
cExt := "txt"
ELSEIF nIndex == 3
cExt := "dat"
ELSEIF nIndex == 4
cExt := "xls"
ELSEIF nIndex == 5
cExt := "prg"
ELSE
cExt := "dbf"
ENDIF

Last edited by Pablo César on Wed May 22, 2013 1:40 am, edited 1 time in total.
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
- Pablo César
- Posts: 4059
- Joined: Wed Sep 08, 2010 1:18 pm
- Location: Curitiba - Brasil
Help with PutFile()
For example, replacing hb_parc by HMG_parc. And add after line #pragma begindump this:esgici wrote:Which modification(s) may be required, would you specify please
#define COMPILE_HMG_UNICODE
#include "HMG_UNICODE.h"
Mr. Rathinagiri, what do you think about 5th and 6th extra parameters in InputFile source code ? Both ideas are usefull...

HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
- Pablo César
- Posts: 4059
- Joined: Wed Sep 08, 2010 1:18 pm
- Location: Curitiba - Brasil
Help with PutFile()
I've tried to compose right code, but there some errors in C code. Here are for both codes proposed:
c_dialogs.c
h_dialogs.prg
Please Dr. Soto, would help us in this ? My C knowledges are not so good than yours. 
c_dialogs.c
Code: Select all
HB_FUNC( C_PUTFILENEW )
{
OPENFILENAME ofn;
TCHAR buffer[512];
char cExt[ 4 ];
int flags = OFN_FILEMUSTEXIST | OFN_EXPLORER ;
if ( hb_parl(4) )
{
flags = flags | OFN_NOCHANGEDIR ;
}
if( strlen( HMG_parc( 5 ) ) != 0 )
strcpy( buffer, HMG_parc( 5 ) );
else
strcpy( buffer, "" );
if( strlen( HMG_parc( 6 ) ) != 0 )
strcpy( cExt, HMG_parc( 6 ) );
else
strcpy( cExt, "" );
//******************************************************************************************************//
// ofn.lpstrFilter = A buffer containing pairs of null-terminated filter strings.
// The last string in the buffer must be terminated by two NULL characters.
// The following code converts a ANSI (CHAR) filter string into a UNICODE (UNSIGNED INT) filter string
#define _MAX_FILTER 32*1024
INT i, j=0, cont=0;
CHAR *p = (CHAR*) hb_parc(1);
TCHAR Filter [_MAX_FILTER];
memset((void*) &Filter, 0, sizeof(Filter));
for (i=0; *p != '\0'; i++)
{ cont = cont + strlen(p) + 1;
if (cont < _MAX_FILTER)
{ lstrcpy (&Filter[j],HMG_CHAR_TO_WCHAR(p));
/*
TCHAR Text [100];
wsprintf(Text,_TEXT("%d %d %s"),i,cont,&Filter[j]);
MessageBox (NULL, Text, _TEXT("DEBUG"), MB_OK);
*/
j = j + lstrlen (HMG_CHAR_TO_WCHAR(p)) + 1;
p = p + strlen(p) + 1;
}
else
break;
}
//**********************************************************************//
memset ((void*)&buffer, 0, sizeof(buffer));
memset( (void*) &ofn, 0, sizeof( OPENFILENAME ) );
ofn.lStructSize = sizeof(OPENFILENAME);
ofn.hwndOwner = GetActiveWindow() ;
// ofn.lpstrFilter = (LPCTSTR) hb_parc(1);
ofn.lpstrFilter = (LPCTSTR) &Filter;
ofn.lpstrFile = (LPTSTR) &buffer;
ofn.nMaxFile = 512;
ofn.lpstrInitialDir = (LPCTSTR) HMG_parc(3);
ofn.lpstrTitle = (LPCTSTR) HMG_parc(2);
ofn.Flags = flags;
ofn.lpstrDefExt = cExt;
if( GetSaveFileName( &ofn ) )
{
HMG_retc(ofn.lpstrFile);
}
else
{
hb_retc( "" );
}
}
Code: Select all
*-----------------------------------------------------------------------------*
Function PutfileNew ( aFilter, title, cIniFolder, nochangedir, cDeFilName, cFileName )
*-----------------------------------------------------------------------------*
Local c:='' , n
DEFAULT cFileName := ""
DEFAULT cDeFilName := ""
DEFAULT aFilter:={}
DEFAULT title := ""
DEFAULT cIniFolder := ""
For n := 1 TO HMG_LEN ( aFilter )
c += aFilter [n] [1] + CHR(0) + aFilter [n] [2] + CHR(0)
Next
c := c + CHR(0)
Return C_PutFileNew ( c, title, cIniFolder, nochangedir, cDeFilName, cFileName )

HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
- esgici
- Posts: 4543
- Joined: Wed Jul 30, 2008 9:17 pm
- DBs Used: DBF
- Location: iskenderun / Turkiye
- Contact:
Re: Help with PutFile()
Hi Pablo
Good suggestions, I agree with you, these enhancements will be good and useful.
By the way,

TIA
Good suggestions, I agree with you, these enhancements will be good and useful.
By the way,
... or he didn't like itprobably Mr. Diamond was forgot it

TIA

Viva INTERNATIONAL HMG 
