Silverfrost Forums

Welcome to our forums

Passing parameters in Call Back function

16 Apr 2019 2:08 #23509

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)?

16 Apr 2019 4:24 #23511

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.

17 Apr 2019 6:36 #23516

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.

17 Apr 2019 3:19 #23520

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).

Please login to reply.