Working with variables

Aug 04, 2020

I was wondering if anyone has any tips on getting variables to 'click.' 

I do fine with creating the variable (name/type) and adjusting the variable, but often find myself stuck or making mistakes with using the variable. 

Does anyone have any tips on what helped them? 

7 Replies
Tom Kuhlmann

It's essentially a three step process:

  1. Create a variable (which is just a bucket to hold a value)
  2. Trigger to adjust variable (user does something in the course that we want to track)
  3. Use that value to do something (user clicks on something three times so we want to show a warning)

I recommend watching the variable webinars to become more familiar with how to use them. Then, it's really a matter of having some use cases and thinking through them.

I find it's better to write out what you want to do on paper and think through it a bit before building and messing around with triggers that may or may not work or may lead us down a hole.

Jodi M. Sansone

Hi Katelin, I was looking in the community for some help on something  else today and I came across your question.  When I started learning storyline I did everything possible to avoid using variables because the concept was not clicking with me either.  I attended all the webinars Tom recommended (and I still do as much as I can).  One thing I did was to look at the weekly challenges and find the ones that had variables as a topic.  The first one I did was #188 on random numbers--wow, was it terrible and it took me for ever! Afterward I would search the entries and try to replicate others' projects.  Sometimes people post files and I would download them and dissect them to see if I could recreate them.  Some of the recent challenges that had variables were 278, 280 or 292.  I always share a file if someone wants to see how I did something, so just ask and I'm sure you'll find the help you need. 

Walt Hamilton

I got home last night, and the cat insisted he had not been fed all day, and was STARVING. I hadn't been there all day, so I didn't know, and my wife was off to her quilting party, so I couldn't ask her. Fortunately, she left a note on the counter that said "I fed the cat", so I knew not to feed him again.
The note she left me is the variable. I couldn't see her feed the cat, but I could see the note and know what went on while I was gone. Storyline is just like I was. One slide has no way of knowing what happens on another slide, but it can read a message left for it in a variable, and know what the learner did while on another slide, provided you (the creator) used the learner's actions on that other slide to change the contents of a variable.
The cat got pretty insistent, so I gave him a snack, crossed out her message, and wrote, "He's also had a bedtime snack.", and went to my meeting.
The note is the variable. Everybody can see it, and it never changes unless you, the creator, create a trigger to change it.
My wife is getting older (I'm not, just she), and takes a bunch of medicines. She puts them in one of those little plastic gadgets with seven boxes. Every night, (if she remembers:) ) she looks in the box for that day. If it is empty, she knows she has taken her pills that day.
The pill box is the variable. She can't always remember everything, but if the box has pills in it, she knows to take them. SL's memory is much worse. If you click a button, it executes all the buttons associated with that click, and forgets you clicked it, unless the creator used that click to adjust a value in a variable.
So that's the purpose and use of variables; they transfer data from one spot in the project to another, whether separated from the spot of the creation of the data by time or distance (being on another slide). They are almost always used in the On Condition part of a trigger. For example, "Feed the cat When you come home if wife didn't" or Say "Happy Father's Day" When timeline on slide starts On Condition user clicked "I'm a father". They also are used as references to display information. For example, if the user has entered information in a variable (using a text input), you can tell them hi: "Hi there %UserName%".
The most important thing you will ever learn about variables is how to name them. Most beginners name them things like "var1", because they think they can save so much time and effort compared to using names like "UserName". Three weeks from now, they will have lost over 100 times that much time and effort trying to figure out what the difference is between "var15" and "var6". Give them name that instantly identify their purpose.
Variables are containers you can use to pass information from one part of your project to another. There are no limits to what you do with it.

This discussion is closed. You can start a new discussion or contact Articulate Support.