Possible to execute a sub function from another dialog?

Creating complex macros, dialogs, solving complex tasks, programming.

Possible to execute a sub function from another dialog?

Postby r0n on Wed Sep 06, 2017 5:09 am

If I have 2 dialogs:

Dialog 1:
Has button a button labeled "start", button has id 7.

Dialog 2:
Has an editfield with text "123" in it.
And it has an subfunction "sub.displaytext" which outputs the contents of the inputfield of Dialog 2.
The moment Dialog 2 runs, I put it's dialog-ID in thread global variable:
int- dlg2_id


Question:
Is it possible to execute "sub.displaytext" from Dialog 1 when button "start" is pressed?
The "sub.displaytext" only interacts with Dialog 2 and only outputs content of Dialog 2

So in the code of Dialog 1:

Code: Select all

...
case 7
   ...... code that executes "sub.displaytext" of Dialog 2
...

Warning: The code possibly is invalid because some important characters (tabs, spaces) disappeared. Read more.

The help states
When you cannot use sub-function:
- The function is used by more than one macro/function/etc.
- ...


But I hope my case might be a bit different because the sub-function stays and executes within it's own
Dialog 2 scope. Dialog 1 only calls it and the sub-function only interacts with it's own Dialog 2.
r0n
Active Member
 
Posts: 488
Joined: Tue Jul 24, 2012 5:47 am

Re: Possible to execute a sub function from another dialog?

Postby Gintaras on Wed Sep 06, 2017 5:26 am

Both dialogs can be in single macro.

Dialog1 code

#sub Dialog2

Dialog2 code

#sub displaytext



Also it's possible to use shared subfunctions, but in this case probably it is not a good idea.
Gintaras
Site Admin
 
Posts: 10324
Joined: Thu Dec 19, 2002 7:36 pm
Location: Lithuania

Re: Possible to execute a sub function from another dialog?

Postby r0n on Wed Sep 06, 2017 6:10 am

Thank you!
r0n
Active Member
 
Posts: 488
Joined: Tue Jul 24, 2012 5:47 am


Return to Programming

Who is online

Users browsing this forum: No registered users and 2 guests

cron