Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
29276 Discussions

Dialogs - "Callback type subroutines" with arguments variables

eduardo_antunes
Beginner
557 Views
Hi there, I'm a portuguese student and I started to used in college Visual Fortran recently. So I started to learn it, but i already knew fortran programing

In the example "Celsius" they maded the callback routine UpdateTemp(dlg,control_name,callbacktype). Our problem is that we need to import other variables from the main program and we tried UpdateTemp(dlg,control_name,callbacktype,variable), this does give a compiling error, however the program crashs while executing.

My question is how can we import this variable from the main program to this callback soubroutine.

The other question is related with the menus in the toolbar. If I do this : result = APPENDMENUQQ(1, $MENUENABLE, '&Temp aplication'C, Do_dialog)

(Do_Dialog is the dialog subroutine that generates an controls de dialog box) this calls the subroutine...however this does work when the dialog subroutine has arguments...I tried to do

result = APPENDMENUQQ(1, $MENUENABLE, '&Temp aplication'C, Do_dialog(variable) )

My other question is how to call a subroutine using a menu.

Thank you for help... Eduardo Antunes
0 Kudos
2 Replies
Jugoslav_Dujic
Valued Contributor II
557 Views
Prototypes (number and types of arguments) of callback routines must exactly match the one stated in documentations, i.e, for dialogs (TYPE(Dialog), INTEGER, INTEGER) and for menus (LOGICAL). Elsewhere, even if you manage to compile it, you'll get run-time crashes. If you want to "import" other variables, you'll have to either

- Place these variables in a MODULE and USE that module in both main program and the callback
- Place them in a COMMON block declared in main and in callback.
There are other ways, but these are the most simple.

Similarly, menu callbacks must have a single LOGICAL argument; if you want to share some variables, you'll have to use a MODULE (or a COMMON).

Jugoslav
0 Kudos
eduardo_antunes
Beginner
557 Views
Thanks for your help! It worked just fine!
0 Kudos
Reply