How do I start working with variables?

Jun 13, 2018

Hi! I'd like to know everything about working with variables and how they can be useful for course design. I cannot find any training materials on that topic. Any suggestions? Big thanks!

7 Replies
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 you did while you were on another slide, provided the developer used your 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 developer, 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 is much worse. If you click a button, it executes all the triggers associated with that click, and forgets you clicked it, unless the developer 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 look at how much time and effort they can save over 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 names that instantly identify their purpose.

Variables are containers you can use to pass information around your project. There are no limits to what you do with it.

Montserrat Vega

Walt, you rock! You are such an amazing narrator! And a funny one, too! My God! You don't know me at all, but I learn effectively through metaphors and analogies, and yours were just perfect!!!! :) How amazing!!! I'm fairly new to this community, but I am very pleased to be part of it.

THANK YOU from Mexico!

 

p.s. I cracked when you mentioned that your wife is getting old (but not you). I laughed so hard. Stay safe, sir.

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