View previous topic :: View next topic |
Author |
Message |
jcherw
Joined: 27 Sep 2018 Posts: 57 Location: Australia
|
Posted: Tue Apr 16, 2019 3:08 pm Post subject: Passing parameters in Call Back function |
|
|
I am porting an old fashioned question and answer program to Windows. The original would display a text menu (via a main program) and for each menu option a subroutine is called. Relevant parameters are transferred as subroutine arguments.
When I am using a clearwin menu, the subroutines associated with the previous text menu options are replaced by callback functions . However callback functions do not allow for passing arguments.
A way around is to use (labelled) common blocks. This, however, requires substantial reprogramming.
Is there another method to pass arguments into a callback function (or subroutines called by the callback function)? |
|
Back to top |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 7932 Location: Salford, UK
|
Posted: Tue Apr 16, 2019 5:24 pm Post subject: |
|
|
There are various approaches that you could use but perhaps the best place to start is to look at the function clearwin_string@ with CURRENT_MENU_ITEM. |
|
Back to top |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 7932 Location: Salford, UK
|
Posted: Wed Apr 17, 2019 7:36 am Post subject: |
|
|
My apologies for the previous post which was probably misleading.
In most cases you should use modules (or the older common blocks) as an alternative to passing arguments. Set up the data via module variables and USE the module in the callback function.
The information functions clearwin_info@, clearwin_float@ and clearwin_string@ are often useful for obtaining specific items of data. A call to clearwin_string@("CURRENT_MENU_ITEM") can be used when one callback is used for all menu items and it allows you to distinguish which item was selected. |
|
Back to top |
|
|
jcherw
Joined: 27 Sep 2018 Posts: 57 Location: Australia
|
Posted: Wed Apr 17, 2019 4:19 pm Post subject: |
|
|
Thanks Paul.
Will probably use common blocks (a known entity for me) and look into modules ('new' for me after a 20 year Fortran break). |
|
Back to top |
|
|
|