Scicos context variables

40 views
Skip to first unread message

Oleksiy Bondarenko

unread,
Mar 28, 2020, 4:37:50 AM3/28/20
to tumbi
Hello,

I have a question about variables defined in the nsp workspace and availability in the scicos environment. I have a scicos model and a script which calculates parameters and initial conditions for simulation. In the script I define the hash variable, let say Constant, which holds all the necessary parameters, in the scicos model in the context, an additional set of hash variables is defined from particular keys of Constant variable. So, the question is why in the scicos environment only the variables defined in the context are available and not a variable defined in the script? Is it the typical behaviour of nsp? (different from the nsp predecessor)

jpc

unread,
Mar 28, 2020, 6:28:15 AM3/28/20
to tumbi
Hello,
Yes this is the typical behaviour in nsp. This is due to the fact that when the context is evaluated inside scicos the variables of the workspace can be hidden by local internal variables defined in the running scicos function and could clash.

But  indeed, you have the right to explicitely execute your script inside the context.

You can also set up a context before calling scicos()

-nsp->%scicos_context=hash(x=78);
-nsp->scicos() <------------------------------------- now, I can use x in my models

Regards
jpc

Oleksiy Bondarenko

unread,
Mar 29, 2020, 1:21:47 AM3/29/20
to tumbi
Hello,

Thank you for the prompt reply.

Now it becomes clear since I am migrating my projects from the Scicoslab where I actually execute the initialisation script from inside the context using exec() function; 

Another question related to context: It seems like context is evaluated 2-3 times - I use a function x-mdialog() to set-up various conditions and a dialog window appears repeatedly 2-3-times (after Ok button is being pressed), is it a bug?

Sincerely

суббота, 28 марта 2020 г., 19:28:15 UTC+9 пользователь jpc написал:

Oleksiy Bondarenko

unread,
Apr 3, 2020, 9:11:49 PM4/3/20
to tumbi
Any thoughts about multiple times of context execution?

воскресенье, 29 марта 2020 г., 14:21:47 UTC+9 пользователь Oleksiy Bondarenko написал:

Jean-Philippe Chancelier

unread,
Apr 4, 2020, 5:07:47 AM4/4/20
to tu...@googlegroups.com

Hello Oleksiy,

Context evaluation is a bit complex in scicos since you can have context in superblocks which are recurssively merged with the main context when evaluation of superblocks is done. Thus, I agree with you that 2-3 evaluations seems too much but it's not easy to track that.

I think it's good practice to avoid interactive code in context. You can call an interactive macros to build

%scicos_context and then call scicos.

Regards,

jpc

--
You received this message because you are subscribed to the Google Groups "tumbi" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tumbi+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/tumbi/d7115b99-961b-45f2-8aa1-d82f5bc7a185%40googlegroups.com.

Oleksiy Bondarenko

unread,
Apr 4, 2020, 6:16:27 AM4/4/20
to tumbi
Was the same logic used in the past Scicoslab? If so, I don't have any multiple evaluations in the Scicoslab for the same interactive context model.

суббота, 4 апреля 2020 г., 18:07:47 UTC+9 пользователь Jean-Philippe Chancelier написал:
To unsubscribe from this group and stop receiving emails from it, send an email to tu...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages