Persistant value

Persistant value - Messages

#1 Posted: 7/30/2010 5:24:50 PM
Edward Ulle

Edward Ulle

20 likes in 182 posts.

Group: Moderator

From a plug in, is there a way to make a variable value persistant.

As I see it now, when a SMath file is loaded the worksheet is processed from top to bottom and any variable would be defined in the worksheet. The "store" is recreated.

I want a variable value to be stored with the worksheet file, so that when the file is loaded the variable value is already defined.

I have been working on a plug in that uses the Windows Open File Dialog box to get a filename. That filename is then used in subsequent functions to perform some action. However, every time the worksheet file is open the open file dialog box is displayed. Instead I would like the results of the first time the file name is captured to be stored with the file so the next time its opened the dialog box will not display.

I know a simple work around is to use the open function to get the filename, cut and past the filename to a variable and then discard the open function. I was thinking of something more elegant.

The process would be something like this.

fn:=getFileName(fn)

x:=getFileData(fn,key)

In the getFileName function test for value of fn. If not defined then open the dialog box. If defined then return the value of fn, provided its a valid filename.
Ed
#2 Posted: 7/31/2010 6:10:23 AM
Radovan Omorjan

Radovan Omorjan

325 likes in 2052 posts.

Group: Moderator

Hello TheWizEd,

I do not quite understand what are your intentions, sorry.
Could you please take a look at this thread http://en.smath.info/forum/default.aspx?g=posts&t=370.
If there are no connections between your ideas and the comments in the thread, never mind - just ignore my question.

Regards,
Radovan


When Sisyphus climbed to the top of a hill, they said: "Wrong boulder!"
#3 Posted: 7/31/2010 8:52:36 AM
Edward Ulle

Edward Ulle

20 likes in 182 posts.

Group: Moderator

I was thinking more like a constant that traveles with the SMath file.

When the file is first created the user enters the function.

fn:=getFileName(fn)

At this point fn is not defined so the program presents the user with the Open File dialog box.

The user finishes, saves their file and exits SMath. The user comes back to that file and opens it. This time fn is defined and the function simply returns the filename without presenting the dialog box.

If the user ever wanted to change the file add the line before the getFileName line.

fn:=0
fn:=getFileName(fn)

And then delete the fn:=0 line. Or leave it there if they want to see the dialog box everytime they open the SMath file.

I'm lazy. I don't want to type in the full path name and file name. And with Windows 7 they've made it more difficult to cut and paste the full name.

Ed
  • New Posts New Posts
  • No New Posts No New Posts