March 6, 2017 at 2:18 pm #348349
All well and good except that now MyVariable is being saved between sessions (to Session Storage under “Lectora2:mytitlename”) even though I have not turned on the save between sessions property. This is not good as I want it to be initialized newly at the start of each session.
Does anyone have insights into either or both of these problems? Point me to documentation or to another post if easiest.
March 6, 2017 at 2:28 pm #348373
- This topic was modified 3 weeks ago by Andrew Corbett. Reason: clarify question
Ooops, take away my “Advanced” badge! They are supposed to be in Session Storage to access between pages. So ignore that part of my question …. it is not a problem.March 6, 2017 at 2:31 pm #348379
Tim KMember168 pts@timk
It has always been like that: if you don’t use a (user-defined) variable in a Lectora action it’s not initialized. The easiest way to use all variables is by adding an action group on title level with only one action: Reset all variables
It’s new to me that variables used in any way are saved between sessions independent of the setting in the variable manager… Mind, the browser saves values by itself.
TimThis post has received 1 vote up.March 6, 2017 at 2:39 pm #348381
Thank you Tim! I see that action and now understand what it is for.
(Re other issue, see my update above. I did seem to be having an odd problem with variables unintentionally saving across sessions, but Session Storage is clearly not involved, and I’m still trying to reproduce).
andrewMarch 6, 2017 at 5:30 pm #348405
Some additional info here for those who may stumble on this question later:
- I have found the following trick works for me to make sure the variables I want in custom JS are available:
- I create an OnShowModVar action on each separate screen of the title
- I include every variable I want to have access to in the details of the “Value” field for the ModVar action
- Notice that this is simply using these variables as inputs and not changing their values
- If I put this action in front of all other actions on the screen, then the variables are defined when I want to use them in custom JS calls
- I have NOT been successful in using the “Reset All Variables” action. When I use this function the variables ARE defined, but they also appear to truly be reset to their initial values (as specified in the Variable Manager). In my case, I want them simply to have the same value as they had on exiting whatever the previous screen was.
- Lectora variables are NOT being unintentionally saved between sessions as I had suggested above. That was a mistaken observation on my part resulting from odd behavior which I can’t reproduce (thankfully).
andrewMarch 7, 2017 at 7:14 am #348453
Math NotermansMember47 pts@mnotermans5114
Interesting topic 🙂 Especially Tim’s trick on using ‘Reset All Variables’ to ensure all custom variables in your project are defined is nice i think. Gonna try that one next time… didnot think of it before.
Wondering though why Andrew is not succesfull in using this as he states on point 4…. ?
If you add a ‘Reset All Variables’ on your first screen, then all custom vars are defined as needed right ?
Offcourse you might need to add a condition that this action only gets triggered the first time you visit the page, else all vars get reset everytime you come there.
MathMarch 7, 2017 at 11:30 am #348515
Tim KMember168 pts@timk
The trick is to put the reset action into a group on title level. It will be available on all pages and as long as you don’t Run the group nothing should be reset.This post has received 2 votes up.March 7, 2017 at 11:57 am #348522
Thanks Tim. I understand now: putting Reset All Variables in a group at title level causes all the variables to be declared, but prevents the reset from actually being run.March 9, 2017 at 5:30 am #348901
Sergey SnegirevMember336 pts@ssneg
I initialize Lectora variables by mentioning them in a CONDITION of a single action (that does nothing) on the Title level. So my title is more compact.
Also, if you use Lectora Online, you don’t have to do it. In LO, all variables are always initialized.
You must be logged in to reply to this topic.