forums.silverfrost.com Forum Index forums.silverfrost.com
Welcome to the Silverfrost forums
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Passing parameters in Call Back function

 
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> ClearWin+
View previous topic :: View next topic  
Author Message
jcherw



Joined: 27 Sep 2018
Posts: 57
Location: Australia

PostPosted: Tue Apr 16, 2019 3:08 pm    Post subject: Passing parameters in Call Back function Reply with quote

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
View user's profile Send private message
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 7916
Location: Salford, UK

PostPosted: Tue Apr 16, 2019 5:24 pm    Post subject: Reply with quote

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
View user's profile Send private message AIM Address
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 7916
Location: Salford, UK

PostPosted: Wed Apr 17, 2019 7:36 am    Post subject: Reply with quote

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
View user's profile Send private message AIM Address
jcherw



Joined: 27 Sep 2018
Posts: 57
Location: Australia

PostPosted: Wed Apr 17, 2019 4:19 pm    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> ClearWin+ All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group