rathinagiri wrote:Hi
I have attached the Interest(ing) Calculator source after removing calls to hmg3 related hfcl/c pragma.
I have added hmg3(.t.) and -DHMG3 as well.
Can you guide me how to go with porting?
The first things to do are adding:
-DHMG3 as a compile switch in hbmk.hbm or where you want...
adding as first instructions of main:
hbqt_errorsys() // otherwise no error is shown on screen
hmg3( .T. ) // to enable
Then compile, get compilation errors, investigate and correct. Then when it compiles, run the program and get the errors, investigate and correct....
Thanks to your code I found some errors in hmg.ch, in missing keyboard defines, conflicting definitions of MAXIMIZE for windows, missing begin/end ini, execute file, setfocus as a function, events that should be fired later.... but MORE IMPORTANT I found a really dangerous situation: hmg4 uses objects to store its widgets and accesses them (quite) directly, expecially WINDOWs...
Now you have the main window called INTEREST... in loans.prg you... I just paste some lines of code:
Code: Select all
counter := counter + 1
interest := 0 // <======== THE PROBLEM IS HERE
endif
enddo
interest.loanaccount.deleteallitems()
interest.loanaccount.header(1) := head1
Using interest as a temporary variable you destroy the object stored previously in "interest"...
This is also a side-effect on how 3 and 4 use preprocessors:
Code: Select all
// original hmg3 code
interest.loanaccount.deleteallitems()
interest.loanaccount.header(1) := head1
// the same code after hmg3 preprocessor
doMethod( "interest", "loanaccount", "deleteallitems" )
setProperty("interest", "loanaccount", "header", 1, head1 )
// the same code after hmg3 preprocessor
interest:loanaccount:deleteallitems()
interest:loanaccount:header(1, head1 )
As you can see HMG4 uses the object directly (and so it is quick... as Carlos demostrated) while HMG3 needs to use functions... and no, I won't change HMG4 to use functions...
Another issue I found in your code is about setFocus... you always use
BUT not in product.prg where you use a function setfocus( widget, window )... setFocus and I imagine a lot other similar functions are not present in HMG4... how many such functions are in HMG3 ? Can we try to use preprocessor on them ???
I'm now able to compile and run... gui is not perfect

, there are missing images and pressing some buttons gives error due to reset "interest" object variable... but it is a starting point... !
I had to remove from your code the begin/end ini sections (I don't know if they are important for testing the software) and execute file. I think that both can be ported easily from hmg3.
I attach a screenshot...
Can you please tell me what I should do in the program to test it ?
I will commit the changes in the next days since there are a couple that needs to be tested agains existing code and possible sideeffects.
Probably I will write a short doc on porting from hmg3 to 4... in the meanwhile I need more info on _setValue and _getValue...