Permanent Variables Thread last updated on 2003-10-30 01:48:03

Posted by member 18600 on 2003-10-29 20:02:50

Some changes to themes (location of the bar, etc) are benefited by or neccesitate "permanent variables", or variables that stay between recycles or even restarts of the computer. One way this seems to be done is by self modifying code. Works for some cases, but it is a bit cumbersome, especially for quick things, and I don't even know how to do the self modifying code trick anyway. What I think would be a great feature is if you could have a module (I bet this would be very easy to make) that reads and writes variables to and from a file.

things would start out as such:

PermaVarFile $LitestepDir$/permaVars.txt
*PermaVar BarLoc 0
PermaVarWriteChangesImediately

On load of litestep the variables would load from the file. There should be an "initial value" which would be set only if there was no entry as of then in the file. This should only be the case the first time LS is run after a change in code. In case of crash, the variables should be written to file whenever they change rather than during recycle or quit. This might cause speed problems, so just in case this should be made optional as indicated above.

Now, I see two possibilities here. Maybe these variables could correspond to LS evars, so the *PermaVar would just indicate which evars are to be written and read. This would be nice, because we could use normal LS If statements instead of custom if-bangs and mzscript for a handful of things. The problem I see is that evars don't seem to be completely volitile and "realtime", though I would be happily corrected on this fact, and I would like to know how to dynamically change evars.

Otherwise the variables would have to be made for this new module. That means that there would have to be bangs to set and test for them.

!PermaVarSet Var Val
!PermaVarIfEq Var Val Action ElseAction
!PermaVarIfGt Var Val Action ElseAction
!PermaVarIfLt Var Val Action ElseAction

And so on. Probably would be most useful in conjunction with mzscript.

Now if evars are already permanent in this fashion, could someone show me how? And thus I would appologize for being a n00b.

Posted by member 7 on 2003-10-30 01:35:35 link

Umm... if you use mzscript 0.9 and "include" the "*mzVarFile(s)" you will get exactly what you want.

Alternatively use textedit.

Posted by member 18600 on 2003-10-30 01:48:03 link

thanks, I will look into mzscript