Page 1 of 8

How do i call a procedure

Posted: Wed Jul 19, 2017 12:33 pm
by ROBROS
Hi to all,

my first small programs run in hmg with very few modifications. I created a main procedure with main window as shown in the samples, I can call procedures from procedure main. When all procedures are done, main window shows up and I have do terminate the program by clickin on "x" in the upper right corner.

Is there a way to call procedures from a popup like shown below, and what are the appropriate commands?

#include "hmg.ch"

Function Main

DEFINE WINDOW Win_1 ;
AT 0,0 ;
WIDTH 400 ;
HEIGHT 200 ;
TITLE 'Tutor 02 - Property Test' ;
MAIN

DEFINE MAIN MENU
POPUP "First Popup"
ITEM 'Change Window Title' ACTION Win_1.Title := 'New Title' &&on select this do proc1
ITEM 'Retrieve Window Title' ACTION MsgInfo ( Win_1.Title ) &&on select this do proc2
END POPUP
END MENU

END WINDOW

ACTIVATE WINDOW Win_1

Return

I couldn't find a suiting sample so far and hope you can help.

Thank you
Robert

Re: How do i call a procedure

Posted: Wed Jul 19, 2017 12:43 pm
by bpd2000
Add following code:

ITEM "E&xit" ACTION Win_1.Release

Re: How do i call a procedure

Posted: Wed Jul 19, 2017 1:12 pm
by edk
You can "do procedure" in the same way as call function.

Code: Select all

ITEM 'Change Window Title' ACTION proc1() &&on select this do proc1
ITEM 'Retrieve Window Title' ACTION proc2() &&on select this do proc2

Re: How do i call a procedure

Posted: Wed Jul 19, 2017 3:16 pm
by ROBROS
@ BPD Thank you: ITEM "&EXIT" ... is very useful I tried "deactivate"

@ edk: I tried do procedure.

Many thanks
Robert

Re: How do i call a procedure

Posted: Wed Jul 19, 2017 6:50 pm
by ROBROS
Here I am back again.
@ edk: your suggestion doesn't work. Are there any settings to be done to make it work?

But another question: maybe 2 weeks ago I stumbled across a fully featured demo-program with checkbox, datepicker, calendar function and on and on, but I can't find the site again. Anybody an idea?

Regards
Robert

Re: How do i call a procedure

Posted: Wed Jul 19, 2017 8:29 pm
by edk
ROBROS wrote:
Wed Jul 19, 2017 6:50 pm
@ edk: your suggestion doesn't work. Are there any settings to be done to make it work?
Strange, this code work like a charm:

Code: Select all

#include "hmg.ch"

Function Main

DEFINE WINDOW Win_1 ;
AT 0,0 ;
WIDTH 400 ;
HEIGHT 200 ;
TITLE 'Tutor 02 - Property Test' ;
MAIN

DEFINE MAIN MENU
POPUP "First Popup"
ITEM 'DO proc1' ACTION proc1() &&on select this do proc1
ITEM 'DO proc2' ACTION proc2() &&on select this do proc2
ITEM "E&xit" ACTION ThisWindow.Release
END POPUP
END MENU

END WINDOW

ACTIVATE WINDOW Win_1

Return
*********************************
PROCEDURE proc1
Local i

FOR i=1 TO 100
   i:=i*i
Next i
MsgInfo('Result: '+hb_ValToStr(i), 'proc1')
RETURN 

*********************************
PROCEDURE proc2
Local i

FOR i=1 TO 100
    i:=i+i 
Next i
MsgInfo('Result: '+hb_ValToStr(i), 'proc2')
RETURN
Unless I misunderstood your question. My English is not very good. :(
But another question: maybe 2 weeks ago I stumbled across a fully featured demo-program with checkbox, datepicker, calendar function and on and on, but I can't find the site again.
There may be helpful samples from the HMG installation:
c:\hmg.3.4.4\SAMPLES\Basics\MAIN_DEMO\
c:\hmg.3.4.4\SAMPLES\Controls\MonthCalendar\

Re: How do i call a procedure

Posted: Wed Jul 19, 2017 8:43 pm
by ROBROS
Thank you very much, MAIN_DEMO is, what I was looking for, I searched the web for it, and it is part of HMG-distribution, by Roberto Lopez.

Regards
Robert

Re: How do i call a procedure

Posted: Wed Jul 19, 2017 9:14 pm
by ROBROS
@ edk: Sorry, absolutely my fault.
Up to now I used xbase++ in text mode, compiled the single prg-files and called them sequently via command line *.bat.

Robert

Re: How do i call a procedure

Posted: Wed Jul 19, 2017 10:57 pm
by edk
You can also add all .prg files references into .hbp project file and compile to one exe. All functions and procedures will be included.

Re: How do i call a procedure

Posted: Thu Jul 20, 2017 11:41 am
by ROBROS
FEEDBACK:

I did how you told me, works just fine.

Thank you
Robert