Group Abstract Group Abstract

Message Boards Message Boards

0
|
7.4K Views
|
4 Replies
|
0 Total Likes
View groups...
Share
Share this post:

Persist a module variable value between two calls to a function?

Posted 7 years ago

Hi I have just started using Mathematica, I am trying to plot a bar graph with two data sets, resulting graph has two bar graphs with one appearing on top of the other.

We have a custom Mathematica package to do this job. which has a function, with a module variable say (x) this function gets called twice for the two data sets, and each time (x) is getting set to a different value by some calculation in this function. is it possible to retain the value of (x) which gets set first time until it gets set to a different value second time

say in first time call x =1, I would like to some how persist this value of x when I call this function second time, so I can use it then

I have been going through Mathematica Language documentation online, and came to know about PERSISTVALUE, which I understand is like a session variable, is this something I can use,

I did try to use PERSISTVALUE in our Mathematica code but I am unable to get it working,

when I first set PersistValue['myvar'] = 1, and then try to read it back in the same call it doesn't show the value, with this problem I cannot even expect it to be retained until the next call.

Firstly can you let me know if I can use PersistValue for retaining variable values between calls to a function.

If not then is there any other way I can do this.

Thanks for your help in advance Nalina

POSTED BY: Nalina Vemparala
4 Replies

Hi Mitch Thanks a lot for taking time to reply to my query.

I will try your suggestion,

Thanks Nalina

POSTED BY: Nalina Vemparala
POSTED BY: Nalina Vemparala
POSTED BY: Henrik Schachner
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard