Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Popup callback in Simulink masks

266 views
Skip to first unread message

Claude

unread,
Sep 20, 2006, 11:32:24 AM9/20/06
to
Hi,
I want to use a masked subsystem in Simulink. There is a popup which
should enable or disable some edit fields. The variable associated
with the popup is "popchoice".
My question may sound dumb: how do I access the value of this
variable in the popup callback?
I would like the numeric value of this variable. If I just use the
name of the variable, I get an error; and if I use the instructions
> get_param(gcb,'Mask','popchoice')
I always get the string instead of the index (even when the
"evaluate" checkbox is checked, i.e. when the "popchoice" is supposed
to contain the index of the choice instead of the corresponding
string).
What am I missing?
Thanks,
Claude

Praetorian

unread,
Sep 20, 2006, 1:09:31 PM9/20/06
to

Calude, AFAIK you cannot access the index of a popup within the
callback function. You could use the following to figure out the index:

Let's say 'popchoice' has the following options: 'choice 1' and 'choice
2'
Create a cell array:
choices = {'choice 1','choice 2'}
Now:
index = find(strcmp(get_param(gcb,'Mask','popchoice'),choices));

HTH,
Ashish.

Claude

unread,
Sep 20, 2006, 1:41:57 PM9/20/06
to

Thank you Ashish.
Yes, I could use this method, but it would be equivalent to using
directly the strings in my "switch" cycle in the callback.
The reason for which I did not want to do this is that it requires me
to manually type twice the same string, which may be more error-prone
(especially in case of future modifications to the mask).
I thought there was an easy way to access mask variables from the
callbacks; if this is not the case, I'll have to live with it, I
guess...
Claude

Praetorian

unread,
Sep 25, 2006, 3:26:32 PM9/25/06
to

> Thank you Ashish.
> Yes, I could use this method, but it would be equivalent to using
> directly the strings in my "switch" cycle in the callback.
> The reason for which I did not want to do this is that it requires me
> to manually type twice the same string, which may be more error-prone
> (especially in case of future modifications to the mask).
> I thought there was an easy way to access mask variables from the
> callbacks; if this is not the case, I'll have to live with it, I
> guess...
> Claude

Claude, if you don't want to type in the different strings in your
popup menu there is another thing you can do. Look at the output of

get_param(blockName,'MaskStyles')

You can then get the row corresponding to your popup and use regular
expressions to get the popup strings from this list of all popup
values.

HTH,
Ashish.

Matthew

unread,
Nov 18, 2016, 4:18:11 PM11/18/16
to
It is over a decade later, and this is still a frustratingly non-intuitive task. Here's a solution.

% Get the handle to the blocks object
blockObject=get_param(gcb,'object');
% Get the handle to the dialog
blockDialog= DAStudio.Dialog(blockObject.getDialogSource);
% Get the current index of the popup.
% NOTE: The input argument is the PROMPT to the mask variable,
% not the mask variable itself.
popupIndex = blockDialog.getWidgetValue('My Popup Prompt:');
0 new messages