Page 1 of 1
Senddata Getdata
Posted: Mon Oct 25, 2010 6:09 pm
by danielmaximiliano
Hola a Todos:
estoy intentando implementar Senddata y Getdata desde aplicaciones HMG
hay algun ejemplo estas Funciones? ya que al tratar de implementar esas funciones me da error.
recuerdo que la aplicacion que envia datos se cierra despues y la aplicacion que recibe cienpre esta abierta.
Google Translate
Hi Everyone:
I'm trying to implement SendData and HMG Getdata from applications
is there any example of these functions? because when trying to implement these functions gives me error.
I remember the application that sends data and closes after receiving the application is always open.
Saludos
DaNiElMaXiMiLiAnO
Re: Senddata Getdata
Posted: Mon Oct 31, 2011 9:09 pm
by Pablo César
Hola Daniel,
Conseguistes algun ejemplo ? Encontré este aqui:
Code: Select all
#include "minigui.ch"
Function Main
REQUEST HB_GT_WIN_DEFAULT
LOCAL title:='Harbour MiniGUI Demo'
SET STATIONNAME TO "MAINPROC"
_HMG_Commpath:= GetCurrentFolder()+"\"
DEFINE WINDOW Form_1 ;
AT 0,0 ;
WIDTH 640 HEIGHT 480 ;
TITLE title ;
MAIN ;
FONT 'Arial' SIZE 10;
ON INIT ConsoleInit(title)
DEFINE LABEL Label1
ROW 10
COL 10
VALUE "Good morning"
END LABEL
DEFINE TEXTBOX Box1
ROW 10
COL 100
WIDTH 60
HEIGHT 24
VALUE " 5"
NUMERIC .F.
END TEXTBOX
DEFINE BUTTON Btn1
ROW 50
COL 10
CAPTION 'Press me'
ACTION {||FN1(), SetProperty("Form_1","Box1","Value",GetData())}
END BUTTON
DEFINE BUTTON Btn2
ROW 100
COL 10
CAPTION 'Message'
ACTION FN2(Form_1.Box1.value)
END BUTTON
DEFINE BUTTON Btn3
ROW 150
COL 10
CAPTION 'EXIT'
ACTION Form_1.release
END BUTTON
END WINDOW
Form_1.Center()
Form_1.Activate()
Return Nil
FUNCTION FN1()
HIDE WINDOW Form_1
ShowConsole()
CLEAR SCREEN
r1 := "0000"
r2 := "0000"
@ 10,10 SAY ' S1 ' get r1 pict '9999'
@ 12,10 SAY ' S2 ' get r2 pict '9999'
read
HideConsole()
RESTORE WINDOW Form_1
SHOW WINDOW Form_1
SendData("MAINPROC",r2)
RETURN
FUNCTION FN2(n)
LOCAL i
N:=VAL(n)
HIDE WINDOW Form_1
ShowConsole()
CLEAR SCREEN
FOR i:=1 TO n
? "i= ",i
NEXT
WAIT
HideConsole()
RESTORE WINDOW Form_1
SHOW WINDOW Form_1
MsgBox('Box1 value is '+TRANSFORM(n,'99'),'Test')
RETURN
FUNCTION ConsoleInit(title)
SetConsoleTitle(title)
HideConsole()
RETURN
/*
* embeded C code
* can be put in separate .c file (without #pragma of course)
*/
#pragma BEGINDUMP
#include "hbapi.h"
#include "hbapiitm.h"
#include <windows.h>
// doesn't work with win32 function GetConsoleWindow()
HWND GetConWin()
{
HWND nH;
char realtitle[ MAX_PATH ];
GetConsoleTitle( realtitle,MAX_PATH );
SetConsoleTitle( "Finding Handle" );
nH=( HWND) FindWindow( NULL,"Finding Handle" ) ;
SetConsoleTitle( realtitle );
return nH;
}
HB_FUNC( GETCONSOLEWINDOW )
{
hb_retnl((long) GetConWin() );
}
HB_FUNC(HIDECONSOLE )
{
ShowWindow(GetConWin(),SW_MINIMIZE); // SW_HIDE
}
HB_FUNC(SHOWCONSOLE )
{
ShowWindow(GetConWin(),SW_RESTORE); //SW_SHOW
ShowWindow(GetConWin(),SW_SHOW); // because 1'st time console stays minimized
}
HB_FUNC(SETCONSOLETITLE)
{ char * szTitle=hb_parc(1);
SetConsoleTitle(szTitle);
}
#pragma ENDDUMP
Pero está dando este error:
Re: Senddata Getdata
Posted: Mon Oct 31, 2011 9:59 pm
by danielmaximiliano
Hola Pablo:
estaba mirando Send/Get Data porque necesitaba enviar un dato entre aplicaciones , ya que mi aplicacion necesita comunicarse con otras que verdaderamente es el mismo desarrollo y en este caso esta separado de la aplicacion principal.
Antes hablamos de los años 90 y pico.. era parte del mismo programa.
Ahora se componen de diferentes modulos que se pueden usar separados. una solucion un poco sucia fue utilizar archivos de texto para intercambiar datos.
Re: Senddata Getdata
Posted: Mon Oct 31, 2011 11:12 pm
by Pablo César
Ahh bueno, pensé que habias concluído algo sobre SendData e GetData. Yo seguiré intentando. Todo esto es para mi aprendizado y comovi tu mensaje sin respuesta quise exponer lo que tengo. Gracias por responder, un grande abrazo.
Senddata Getdata
Posted: Tue Feb 24, 2015 1:13 am
by Pablo César
Passed a quite long time... but finnaly I backed to this matter.
Now with some more HMG knowledge in my small luggage !

This error happen because in the previous code sample was missing
COMMPATH definition.
In HMG instead of Minigui Extended we need to define thru
SET COMMPATH TO command.
- So added SET COMMPATH TO command.
- There was also an hard execution when trying to the button EXIT. I replaced Form.Release by TerminateProcess()
- Some other functions was added like: SetForegroundWindow and SetConsoleTitle.
- Replace SW_MINIMIZE property by SW_HIDE for console opend session
Code: Select all
/*
Based on Grigory MixedMode demo
Adapted version for HMG
By Pablo César Arrascaeta
On February 23rd, 2015
*/
#include <hmg.ch>
REQUEST HB_GT_WIN_DEFAULT
Function Main()
Local title:='Harbour MiniGUI Demo'
SET STATIONNAME TO "MAINPROC"
SET COMMPATH TO GetCurrentFolder()+"\"
DEFINE WINDOW Form_1 ;
AT 0,0 ;
WIDTH 640 HEIGHT 480 ;
TITLE title+" - GUI" ;
MAIN ;
FONT 'Arial' SIZE 10;
ON INIT ConsoleInit(title+" - Console")
DEFINE LABEL Label1
ROW 10
COL 10
VALUE "Good morning"
END LABEL
DEFINE TEXTBOX Box1
ROW 10
COL 100
WIDTH 60
HEIGHT 24
VALUE " 5"
NUMERIC .F.
END TEXTBOX
DEFINE BUTTON Btn1
ROW 50
COL 10
CAPTION 'Press me'
ACTION {||FN1(), SetProperty("Form_1","Box1","Value",AllTrim(Str(GetData())))}
END BUTTON
DEFINE BUTTON Btn2
ROW 100
COL 10
CAPTION 'Message'
ACTION FN2(Form_1.Box1.value)
END BUTTON
DEFINE BUTTON Btn3
ROW 150
COL 10
CAPTION 'EXIT'
ACTION TerminateProcess() // Form_1.release
END BUTTON
END WINDOW
Form_1.Center()
Form_1.Activate()
Return Nil
FUNCTION FN1()
HIDE WINDOW Form_1
ShowConsole()
CLEAR SCREEN
r1 := 0
r2 := 0
@ 10,10 SAY ' S1 ' get r1 pict '9999'
@ 12,10 SAY ' S2 ' get r2 pict '9999'
read
HideConsole()
Form_1.Restore
Form_1.Show
SetForegroundWindow(Form_1.Handle)
Form_1.Box1.SetFocus
SendData("MAINPROC",r2)
RETURN
FUNCTION FN2(n)
LOCAL i
N:=VAL(n)
HIDE WINDOW Form_1
ShowConsole()
CLEAR SCREEN
FOR i:=1 TO n
? "i= ",i
NEXT
WAIT
HideConsole()
Form_1.Restore
Form_1.Show
MsgBox('Box1 value is '+TRANSFORM(n,'99'),'Test')
RETURN
FUNCTION ConsoleInit(title)
SetConsoleTitle(title)
HideConsole()
RETURN
/*
* embeded C code
* can be put in separate .c file (without #pragma of course)
*/
#pragma BEGINDUMP
#define COMPILE_HMG_UNICODE
#include "HMG_UNICODE.h"
#include "hbapi.h"
#include "hbapiitm.h"
#include <windows.h>
HB_FUNC(HIDECONSOLE )
{
HWND hwnd;
hwnd = FindWindowA("ConsoleWindowClass",NULL);
ShowWindow((LONG) hwnd, SW_HIDE); // SW_MINIMIZE
}
HB_FUNC(SHOWCONSOLE )
{
HWND hwnd;
hwnd = FindWindowA("ConsoleWindowClass",NULL);
ShowWindow((LONG) hwnd, SW_RESTORE); // SW_HIDE
ShowWindow((LONG) hwnd, SW_SHOW); // because 1'st time console stays minimized
SetForegroundWindow ( hwnd );
}
HB_FUNC(SETCONSOLETITLE)
{ char * szTitle=HMG_parc(1);
SetConsoleTitle(szTitle);
}
#pragma ENDDUMP
Now is working in HMG and was clear out this question.
I hope you enjoy it !

Re: Senddata Getdata
Posted: Tue Feb 24, 2015 8:35 am
by bpd2000
+1
Re: Senddata Getdata
Posted: Tue Feb 24, 2015 12:00 pm
by danielmaximiliano
Gracias Pablo, como te decia antes deje de lado GET/Senddata y funciona con archivos de text para el intercambio de datos y no me genera problemas,
por cuestiones de tiempo no voy a implementar esas 2 funciones
igualmente gracias por el aporte a la comunidad.
Re: Senddata Getdata
Posted: Tue Feb 24, 2015 12:59 pm
by EduardoLuis
Hi Dany and Pablo:
Between developing a complex system with many separate modules (exes) i had the same problem; the solution i get simple but effective was creating a .MEM file with the variables & it's contents, where all vars have previously defined on any appe (same name and size); this *.mem files is allways upgraded by different modules, and is really quick.- As you implement .TXT, the result will be the same.-
IMHO SEND/GET data goes perfect inside the same app, but between different modules a .MEM files is more sure and also quick.- In some cases if .MEM contents it's critical, after been read by and specific app, the last app erase o rewrites .MEM whit a different contents.-
This solutionw works fine for me.- This could be a good option for you also.-
With regards. Eduardo
Hola Dany y Pablo:
Mientras desarrollaba un complejo sistema con muchos modulos (EXES) tuve el mismo inconveniente; la solución a la que llegué fue simple y efectiva, crear un archivo .MEM conteniendo variables y sus contenidos, donde todas esas variables fueron previamente definidas en cada aplicación (mismo nombre y tamaño); este archivo .MEM se actualiza automaticamente en cada modulo, y lo hace realmente rápido.- Como tu has implementado .TXT el resultado es el mismo.-
En mi opinión SEND/GET DATA se aplica mas dentro de una misma aplicción, pero entre diferentes módulos, el archivo .MEM me parece mas seguro y rapido.- En algunos casos si el archivo .MEM contendrá información crítica, despues de haber sido leido su contenido, la ultima aplicación lo borra o re-escribe con un diferente contenido.-
Esta solución ha funcionado perfectamente para mi. Esta podría ser una buena opción para ti.-
Cordialmente. Eduardo.-
Senddata Getdata
Posted: Tue Feb 24, 2015 4:33 pm
by Pablo César
Gracias Daniel y Eduardo por el interés y sus indicaciones.
Volví a este tema, porque estaba pendiente y antes no lograba hacerlo funcionar.
Pero está aqui, sirve como aprendizaje.
Re: Senddata Getdata
Posted: Wed Feb 25, 2015 9:36 pm
by Javier Tovar
Gracias por compartir!