---
title: "Lectora Basics: Using User-Defined Variables"
description: Wendy Miller of Trivantis explains how to use and create user-defined variables that will work in your Lectora eLearning course.
image: https://blog.elblearning.com/hubfs/Imported_Blog_Media/blog_basics_definedv.png
---

[![ELB-Learning_Logo_ColorRGB-white-text-1](https://blog.elblearning.com/hubfs/ELB-Learning_Logo_ColorRGB-white-text-1.png) ](https://elblearning.com/)

![Lectora Basics: Using User-Defined Variables](https://blog.elblearning.com/hubfs/Imported_Blog_Media/blog_basics_definedv.png)

# Lectora Basics: Using User-Defined Variables

 by [Wendy Miller](https://blog.elblearning.com/author/lectorawendy) | Sep 22, 2015

![Lectora Basics: Using User-Defined Variables](https://blog.elblearning.com/hs-fs/hubfs/Imported_Blog_Media/blog_basics_definedv.png?width=640&height=193&name=blog_basics_definedv.png)

In my last blog, I described what a variable is. It’s just a named container in which you can store a value. But why would you ever want to create your own user-defined variables? The simple answer is when you need to store a value for later use and there is currently nowhere else to store it. You can create your own storage unit out of thin air! [Lectora® eLearning software](https://www.elearningbrothers.com/create-learning/lectora) provides a ton of useful variables for you to use automatically, but the Lectora programmers can’t possibly anticipate everything you might ever want to create.

**Here is a simple example of an instance where you would want to create your own user-defined variable. **

Let’s say you want to make an interactive slideshow that lets the user click ‘next’ and ‘back’ buttons to navigate forwards and backwards through a set of 10 images. Think a little bit about how this would need to work. You’ll need to know which image to show when the buttons are clicked and also keep track of which image is currently being shown so that you know when to enable and disable the navigation buttons when the first and last images are shown. DING! You need to make a user-defined variable for this because one doesn’t already exist. So, let’s make a variable!

Making your own variables in Lectora is super easy. Open the Variable Manager from the Tools ribbon. The User-Defined tab is active by default. Click the Add button at the bottom of the tab. This creates a new variable and enables the Variable Information options on the right. By default, the new variable is named *Variable1*. But that’s not very descriptive, so you’ll want to change the name to something that describes what the variable will contain. Let’s call the variable _*CurrentImage*. (Tip: I like to start my variable names with an underscore so that they are placed at the top of the list in the Lectora variable selection menus.) Type that name into the Variable Name field. Now type the number 1 into the Initial Value field and click the OK button. TA-DA! You have magically created a new variable in which you can store a value and from which you can retrieve a value!

![variable manager](https://blog.elblearning.com/hs-fs/hubfs/Imported_Blog_Media/wendybasics2_1.png?width=581&height=607&name=wendybasics2_1.png)

Ok, so we have set an initial value of 1 for the _*CurrentImage* variable because we are going to show the first of our 10 images by default when the slideshow starts. So, the number 1 represents the first image. But as the user uses the slideshow we are going to change the value of _*CurrentImage* every time the user clicks the ‘next’ and ‘back’ buttons, so we know which image to show. To do this we will add actions to the ‘next’ and ‘back’ buttons that add 1 and subtract 1 from the _*CurrentImage* variable respectively.

![actions on buttons](https://blog.elblearning.com/hs-fs/hubfs/Imported_Blog_Media/wendybasics2_2.png?width=403&height=92&name=wendybasics2_2.png)

With these actions, we are both retrieving a value from and putting a new value into the *_CurrentImage* variable. The ‘*IF’* condition retrieves the current value of *_CurrentImage* first. Then, if the condition is met, the actions then store a new value in the variable by adding 1 to it or subtracting 1 from it.

The **Modify Variable** action is the primary method of putting a value into a variable or changing its current value. But you can also initialize the variable with a value when you create it in the Variable Manager as we did earlier.

As for retrieving a variable’s value, you do this every time you use a condition with an action because all conditions are based on some variable’s value, whether it’s a Lectora variable or one that you created. You are also retrieving a variable value when you use a variable in the Value field of a **Modify Variable** action or when you use one in the Text field of a **Change Contents** action.

![modify variable and change contents action](https://blog.elblearning.com/hs-fs/hubfs/Imported_Blog_Media/wendybasic2_3.png?width=269&height=192&name=wendybasic2_3.png)

But back to our slideshow…  Oh, looky here! It’s the slideshow we’ve been talking about! Playing with it is a lot more fun than talking about it! Give it a whirl and watch what happens to the *_CurrentImage* variable value when you click the buttons. Also notice how the ‘back’ and ‘next’ buttons disable when the value of *_CurrentImage* reaches 1 or 10.

[![TRY LECTORA](https://no-cache.hubspot.com/cta/default/5108583/861df2d2-342d-4450-945a-58379f834ec3.png)](https://cta-redirect.hubspot.com/cta/redirect/5108583/861df2d2-342d-4450-945a-58379f834ec3)

[instructional design-](https://blog.elblearning.com/tag/instructional-design), [Lectora Resources-](https://blog.elblearning.com/tag/lectora-tips), [how to-](https://blog.elblearning.com/tag/how-to), [eLearning Development Tips-](https://blog.elblearning.com/tag/elearning-development-tips)

### Related Posts

[![Learning Lab LIVE: Building Faster with Lectora Library Objects](https://blog.elblearning.com/hs-fs/hubfs/Recap%201-27-26_Learning%20Lab%20LIVE-Building%20Faster%20with%20Lectora%20Library%20Objects_Blog%20Featured%20Image%20800x500.png?width=388&name=Recap%201-27-26_Learning%20Lab%20LIVE-Building%20Faster%20with%20Lectora%20Library%20Objects_Blog%20Featured%20Image%20800x500.png) ](https://blog.elblearning.com/learning-lab-live-building-faster-with-lectora-library-objects)

[Learning Lab LIVE: Building Faster with Lectora Library Objects](https://blog.elblearning.com/learning-lab-live-building-faster-with-lectora-library-objects)

[![The Secret to Humanized Instructional Story Design (with No Fluff)](https://blog.elblearning.com/hs-fs/hubfs/Recap%207-31-2025_Blog%20Featured%20Image%20800x500.png?width=388&name=Recap%207-31-2025_Blog%20Featured%20Image%20800x500.png) ](https://blog.elblearning.com/how-story-based-learning-transforms-training-insights-from-instructional-story-design)

[The Secret to Humanized Instructional Story Design (with No Fluff)](https://blog.elblearning.com/how-story-based-learning-transforms-training-insights-from-instructional-story-design)

[![Meet Your Learning Design Assistant: Lectora Library Objects](https://blog.elblearning.com/hs-fs/hubfs/Meet%20Your%20Learning%20Design%20Assistant%20Recap%207-17-25_Blog%20Featured%20Image%20800x500.png?width=388&name=Meet%20Your%20Learning%20Design%20Assistant%20Recap%207-17-25_Blog%20Featured%20Image%20800x500.png) ](https://blog.elblearning.com/meet-your-learning-design-assistant-lectora-library-objects)

[Meet Your Learning Design Assistant: Lectora Library Objects](https://blog.elblearning.com/meet-your-learning-design-assistant-lectora-library-objects)

[![Transform PowerPoint and Video into Trackable eLearning with Lectora](https://blog.elblearning.com/hs-fs/hubfs/Recap%206-26-25_Blog%20Featured%20Image%20800x500.png?width=388&name=Recap%206-26-25_Blog%20Featured%20Image%20800x500.png) ](https://blog.elblearning.com/transform-powerpoint-and-video-into-trackable-elearning-with-lectora)

[Transform PowerPoint and Video into Trackable eLearning with Lectora](https://blog.elblearning.com/transform-powerpoint-and-video-into-trackable-elearning-with-lectora)

[![What are ARIA Tags and Why Should I Care?](https://blog.elblearning.com/hs-fs/hubfs/Recap%20blog_5-15-25_What%20are%20ARIA%20Tags_Blog%20Featured%20Image%20800x500-1.png?width=388&name=Recap%20blog_5-15-25_What%20are%20ARIA%20Tags_Blog%20Featured%20Image%20800x500-1.png) ](https://blog.elblearning.com/what-are-aria-tags-and-why-should-i-care)

[What are ARIA Tags and Why Should I Care?](https://blog.elblearning.com/what-are-aria-tags-and-why-should-i-care)

[![Beyond Engagement: Designing for Action, Not Just Awareness](https://blog.elblearning.com/hs-fs/hubfs/4-10-25_BeyondDesigning_Blog%20Featured%20Image%20800x500.png?width=388&name=4-10-25_BeyondDesigning_Blog%20Featured%20Image%20800x500.png) ](https://blog.elblearning.com/beyond-engagement-designing-for-action-not-just-awareness)

[Beyond Engagement: Designing for Action, Not Just Awareness](https://blog.elblearning.com/beyond-engagement-designing-for-action-not-just-awareness)

- [**
  
  Facebook
  
  
  
  ](http://www.facebook.com/sharer.php?u=https://blog.elblearning.com/lectora-basics-using-user-defined-variables%2F&t=Lectora%20Basics:%20Using%20User-Defined%20Variables)
- [**
  
  Twitter
  
  
  
  ](http://twitter.com/share?text=Lectora%20Basics:%20Using%20User-Defined%20Variables&url=https://blog.elblearning.com/lectora-basics-using-user-defined-variables)
- [**
  
  Pinterest
  
  
  
  ](http://pinterest.com/pin/create/button/?url=https://blog.elblearning.com/lectora-basics-using-user-defined-variables&media=https://f.hubspotusercontent30.net/hubfs/5108583/Imported_Blog_Media/blog_basics_definedv.png&description=Lectora%20Basics:%20Using%20User-Defined%20Variables)
- [**
  
  LinkedIn
  
  
  
  ](http://www.linkedin.com/shareArticle?mini=true&url=https://blog.elblearning.com/lectora-basics-using-user-defined-variables%2F&title=Lectora%20Basics:%20Using%20User-Defined%20Variables)
- [**
  
  Gmail
  
  
  
  ](https://mail.google.com/mail/u/0/?view=cm&fs=1&su=Lectora%20Basics:%20Using%20User-Defined%20Variables&body=https://blog.elblearning.com/lectora-basics-using-user-defined-variables%2F&ui=2&tf=1)
- [**
  
  reddit
  
  
  
  ](http://www.reddit.com/submit?url=https://blog.elblearning.com/lectora-basics-using-user-defined-variables%2F&title=Lectora%20Basics:%20Using%20User-Defined%20Variables)

© 2025 ELB Learning. All rights reserved.  | [ Terms of Use](https://www.elblearning.com/legal/terms-of-use)  |  [Privacy Policy ](https://www.elblearning.com/legal/privacy-policy)|  [Legal Notices](https://www.elblearning.com/legal/legal-notices)