How do i call a procedure

Topic Specific Tutorials and Tips.

Moderator: Rathinagiri

Post Reply
ROBROS
Posts: 60
Joined: Thu May 25, 2017 6:30 pm
DBs Used: DBF
Has thanked: 32 times
Been thanked: 1 time

How do i call a procedure

Post by ROBROS » Wed Jul 19, 2017 12:33 pm

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

User avatar
bpd2000
Posts: 948
Joined: Sat Sep 10, 2011 4:07 am
Location: India
Has thanked: 118 times
Been thanked: 42 times

Post by bpd2000 » Wed Jul 19, 2017 12:43 pm

Add following code:

ITEM "E&xit" ACTION Win_1.Release
BPD
Convert Dream into Reality through HMG

edk
Posts: 164
Joined: Thu Oct 16, 2014 11:35 am
DBs Used: DBF
Location: Poland
Has thanked: 43 times
Been thanked: 96 times

Post by edk » Wed Jul 19, 2017 1:12 pm

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

ROBROS
Posts: 60
Joined: Thu May 25, 2017 6:30 pm
DBs Used: DBF
Has thanked: 32 times
Been thanked: 1 time

Post by ROBROS » Wed Jul 19, 2017 3:16 pm

@ BPD Thank you: ITEM "&EXIT" ... is very useful I tried "deactivate"

@ edk: I tried do procedure.

Many thanks
Robert

ROBROS
Posts: 60
Joined: Thu May 25, 2017 6:30 pm
DBs Used: DBF
Has thanked: 32 times
Been thanked: 1 time

Post by ROBROS » Wed Jul 19, 2017 6:50 pm

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

edk
Posts: 164
Joined: Thu Oct 16, 2014 11:35 am
DBs Used: DBF
Location: Poland
Has thanked: 43 times
Been thanked: 96 times

Post by edk » Wed Jul 19, 2017 8:29 pm

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\

ROBROS
Posts: 60
Joined: Thu May 25, 2017 6:30 pm
DBs Used: DBF
Has thanked: 32 times
Been thanked: 1 time

Post by ROBROS » Wed Jul 19, 2017 8:43 pm

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

ROBROS
Posts: 60
Joined: Thu May 25, 2017 6:30 pm
DBs Used: DBF
Has thanked: 32 times
Been thanked: 1 time

Post by ROBROS » Wed Jul 19, 2017 9:14 pm

@ 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

edk
Posts: 164
Joined: Thu Oct 16, 2014 11:35 am
DBs Used: DBF
Location: Poland
Has thanked: 43 times
Been thanked: 96 times

Post by edk » Wed Jul 19, 2017 10:57 pm

You can also add all .prg files references into .hbp project file and compile to one exe. All functions and procedures will be included.

ROBROS
Posts: 60
Joined: Thu May 25, 2017 6:30 pm
DBs Used: DBF
Has thanked: 32 times
Been thanked: 1 time

Post by ROBROS » Thu Jul 20, 2017 11:41 am

FEEDBACK:

I did how you told me, works just fine.

Thank you
Robert

Post Reply