Program with many function and form

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

Post Reply
User avatar
l3whmg
Posts: 694
Joined: Mon Feb 23, 2009 8:46 pm
Location: Italy
Contact:

Program with many function and form

Post by l3whmg »

Hi guys,
I need your help.

I want develop a program with many form: ok, HMG can do it :D ! But I’m little confused :?: : I’ve read some topics but I don’t find (perhaps I don’t understand :oops: ) information about my problem.
I’ve difficult with English :roll: and for this reason, I’ve included a little image that shows the situation; I refer my questions to this image.

Prologue: all tables are open (and close) inside “Main” function; every function can do something with its form (call other function/form for example); sometime sub function/form can return value to the previous function/form.

Mine problems are:
A) If I close “Function3”/“Form3” when “Function88” /“Form88” are running, the program crash
B) If two functions call the same “Function99”/“Form99”, the program crash (because “Form99” it’s already defined; if I use IsDefined no very good).

This is a normal situation (I think) with a “complex” program (I think about ERP, etc. :mrgreen: ); I’ve tried combinations: std-form, child-form but without a solution :x . The only way is with modal-form, but I can’t execute “Function1” and “Function…” at the same time. Yes, I can do: “Action3”--->“Function3/Form3” --->”Function88/Form88” and then rollback.

It’s only a mine problem? There is a solution?
Or
I have not understood the logic of HMG?

Thanks a lot
Best regards.
Attachments
ScreenShot.jpg
ScreenShot.jpg (37.84 KiB) Viewed 3645 times
Luigi from Italy
www.L3W.it
User avatar
dhaine_adp
Posts: 457
Joined: Wed Aug 06, 2008 12:22 pm
Location: Manila, Philippines

Re: Program with many function and form

Post by dhaine_adp »

Hi l3whmg,

I don't know if I really understand your problem but it looks to me that your problems letter "A" and "B" exhibit the same root cause.

There are many ways of how a program crash but with HMG, as programmer you should take care of how you define the windows and how are you going to close it. HMG has one main application window. So from the Main Window if you started Function3/Form3 with Function88/Form88 are running it means that there some dependencies involve in there, perhaps a database or table which is closed by Function3/Form3. So when the control returns to Function88 that table is no longer there.

With regards to that closing, you have to make sure that when the function terminates or return control the routine or event that triggers the method it should find the control, table or private variables declared on that routine.

I think the best thing for you is to examine the ErrorLog.HTM and lookup the line number that triggers the error. Use crimson editor located at (http://www.emeraldeditor.com or at http://www.crimsoneditor.com) if your source editor doest not have line number so that you go to that specific line stated by errorlog.htm.

On your letter "B" problem, it is due to redefinition of control. You should do something like this:


function CallMoreThanOnce()

if IsWindowsDefined(Form99)
**--> do some control refresh here if you wish or call that refresh routine
** from another UDF, really it does not matter as long as on termination you can restore
** all variables, record number, alias to it current state before this function is called
** and the same is true with your other routines.
return nil
endif

define window Form99;
blah;
blah;
on release nil; // refocus your control from here and make sure to use DECLARE WINDOW ; // STATEMENT whenever necessary
on interactiveClose // prevent closing from here by returning logical .f. from UDF if you wish
end window
Form99.Center
Form99.Activate
return nil


Another thing is that, look at those HMG samples, particularly ON INIT, ON RELEASE, ON INTERACTIVECLOSE, IsWindowsDefined(), RELEASE WINDOW ALL command, Errorlog.Htm (this will be your guide to debug your code).

And remember, Harbour is not Clipper, its a 100% clipper compatible compiler and HMG is windows library. So when you program in windows, your programming approach should switch from modal approach (for dos and or console application and or command window applications) to event driven (windows).

And finally if you can post your small prototype code to mirror your problem post it in the forum so that everyone can examine your code and provide assistance if possible so that you can go ahead with your project.

Ciao,

Danny


By Google:

Hi l3whmg,

Non so se ho davvero capito il tuo problema, ma sembra a me che i vostri problemi lettera "A" e "B" mostra la stessa causa principale.

Ci sono molti modi di come un crash del programma, ma con HMG, come programmatore si dovrebbe prendere cura di come si definiscono le finestre e come hai intenzione di chiuderlo. HMG ha una finestra dell'applicazione principale. Così dalla finestra principale se hai iniziato Function3/Form3 con Function88/Form88 sono in esecuzione, ciò significa che c'è qualche dipendenze coinvolgere in là, magari un database o una tabella che è chiuso da Function3/Form3. Così, quando il controllo torna a Function88 quel tavolo non c'è più.

Per quanto riguarda che la chiusura, dovete fare in modo che quando la funzione termina o restituire il controllo di routine o di un evento che fa scattare il metodo si dovrebbe trovare il controllo, da tavola o variabili private dichiarato che la routine.

Penso che la cosa migliore per voi è quello di esaminare la ErrorLog.HTM e di ricerca il numero di riga che genera l'errore. Editor Usa cremisi trova (http://www.emeraldeditor.com o http://www.crimsoneditor.com) se fai il tuo editor di origine non hanno il numero di riga in modo che si vada in quella specifica linea dichiarata dal errorlog.htm.

Sulla vostra lettera "B" problema, è dovuto alla ridefinizione di controllo. Si dovrebbe fare qualcosa di simile a questa:

function CallMoreThanOnce()

if IsWindowsDefined(Form99)
**--> Fare qualche refresh di controllo qui se si desidera o chiamare la routine di aggiornamento
** Da un altro UDF, davvero non importa, purché al termine è possibile ripristinare
** Tutte le variabili, il numero di record, alias lo stato attuale prima di questa funzione è ** chiamata E lo
return nil
endif

define window Form99;
blah;
blah;
on release nil; // reimpostare il controllo da qui e assicurarsi di utilizzare DECLARE
; // finestra DICHIARAZIONE ogniqualvolta sia necessario
on interactiveclose nil // o impedire la chiusura da qui con il ritorno logica. f. da UDF se si desidera
end window
Form99.Center
Form99.Activate
return nil

Un'altra cosa è che, guarda a quei campioni HMG, in particolare su INIT, SU STAMPA, ON INTERACTIVECLOSE, IsWindowsDefined (), RELEASE finestra di comando TUTTI, Errorlog.Htm (questa sarà la vostra guida per eseguire il debug del codice).

E ricordate, Porto non è Clipper, il suo un compilatore clipper 100% compatibile e HMG è Windows biblioteca. Quindi, quando si programma in Windows, il vostro approccio di programmazione dovrebbe passare dal approccio modale (per DOS e / o applicazione di console e / o applicazioni finestra di comando) di event-driven (Windows).

E, infine, se è possibile pubblicare il tuo codice prototipo piccolo specchio il tuo problema post nel forum in modo che tutti possano esaminare il codice e fornire assistenza, se possibile, in modo che si possa andare avanti con il progetto.

Ciao,

Danny
Regards,

Danny
Manila, Philippines
User avatar
Roberto Lopez
HMG Founder
Posts: 4023
Joined: Wed Jul 30, 2008 6:43 pm

Re: Program with many function and form

Post by Roberto Lopez »

l3whmg wrote: Prologue: all tables are open (and close) inside “Main” function; every function can do something with its form (call other function/form for example); sometime sub function/form can return value to the previous function/form.
<...>
I'm not absolutely sure about to understand your problem, but I guess that I have a solution :)

There is two ways to work with forms in HMG:

1. Mimics 'SAY...GET...READ' Clipper behavior. You define thw window and its controls, then ACTIVATE WINDOW command creates a 'wait state' until the window is closed (as READ does in Clipper).

2. Mimics VB style. You define all your windows at application start and activate all of them in that moment, creating only one 'wait state' for the whole application. Then you show or hide windows as you need. In this scheme you will not code any define window or activate window commands in your functions (Only show and hide methods).

Look at \hmg\samples\noautorelease.

Please note that when you use 'NoAutoRelease' style clicking [X] do will not release the window from memory, it is only 'hidden'.

Regards,

Roberto.
Regards/Saludos,

Roberto


(Veritas Filia Temporis)
User avatar
l3whmg
Posts: 694
Joined: Mon Feb 23, 2009 8:46 pm
Location: Italy
Contact:

Re: Program with many function and form

Post by l3whmg »

Ciao Roberto, ciao Danny.
grazie per le vostre risposte in così breve tempo.
Prima di tutto, io ritengo che sia un problema di logica dei miei programmi e non di MiniGui; infatti, esso assolve bene il suo compito. La dimostrazione è data proprio dall’uso dei formati video “modal”: quando chiudo la finestra (e nel mio caso coincide con la funzione), i problemi non derivano da MiniGui, perché una ad una (in sequenza) le funzioni/finestre vengono chiuse.
Infatti, entrambe vi riferite alla logica di programmazione: “from modal approach (for dos and or console application and or command window applications) to event driven (windows)”.
Quindi, è meglio che io impari (oppure che io studi) una logica differente per i miei programmi.
Ad ogni modo, io includo un esempio di quello che io intendevo. nota bene: le funzioni/variabili che iniziano con "l3w" sono di utilità nei miei programmi per recuperare dei valori o impostare l'ambiente; non influisco sul problema descritto.
Seguirò il suggerimento di Roberto, ma se c'è qualcuno che ha ulteriori esempi...
A presto, grazie ancora!

Translated with google
Hello Robert, hello Danny.
Thanks for your answers so quickly :) .
First of all, I think it is a problem of logic in my :oops: programs and not MiniGui; In fact, it performs its job well. The proof is given precisely by the use of video formats "modal": when I close the form (and in my case coincides with the function), the problems do not arise from MiniGui, because one by one (in sequence) the functions / windows are closed.
In fact, both of you (in different way) refer to the logic programming: “from modal approach (for dos and or console application and or command window applications) to event driven (windows)”.
Therefore, it is better that I learn (or I studies), a different logic for my programs.
Anyway, I include an example of what I mean. Note: the functions / variables that begin with "l3w" are useful in my programs to retrieve values or set the environment; does not affect the behavior described.
I will follow the suggestion of Robert, but if anybody has more examples ...
Thanks a lot, best regards
Attachments
PrgExample.zip
(3.87 KiB) Downloaded 360 times
Luigi from Italy
www.L3W.it
Post Reply