Variables

Variables Overview

Fuga stores pieces of information in the flow using things called variables. The information inside a variable can be used and changed easily during the flow. A variable can store any type of information, be it a string (i.e., normal text), a number, or a date. The piece of information a variable stores is called its value.

Think about variables as storage lockers. Inside the flow, you can tell Fuga to put in or change the information inside the locker, and you can also tell Fuga to check the locker, get the information inside it, and use it.

Variables are important because they allow you to write flexible flows, with actions that apply to multiple situations. This is because instead of having to enter information directly into the action, you enter the variable name, which is then replaced with the real information when the flow is performed. For example, you can use the Ask action to ask the user how much they would like to move an object by, and tell Fuga to store that information in a variable. Then, in the Move action you put in the name of the variable, and Fuga replaces the variable with whatever their answer was.

Fuga checks the variable MyObjectName, sees that it's value is Box, and selects objects named Box.

Variables Basics

Maybe you’re already familiar with variables from math class? Remember:

if x=2 then what’s x+1?

The answer is 3. To get that we checked what x was, saw it was 2, and then substituted 2 for x in the equation.

Variables in Fuga work in a similar way. If x is our Fuga variable, we can use an action to tell Fuga to make it equal to 2. Then, if we use x in an action’s parameters, it’s like telling Fuga to use 2, since Fuga checks what x is equal to, and substitutes it for x.

Fuga stores the information inside x throughout the flow. So, if you tell Fuga that x is equal to 2, Fuga remembers it, and you can use x in as many actions as you want and Fuga will still use 2.

You can also change what x is equal to inside the flow. You can use an action to tell Fuga that x is equal to 2, and use x in an action and Fuga will use 2. Then, later in the flow, you can tell Fuga to change x to 4, and use x in an action and Fuga will use 4.

You can apply the same logic to variables that store any type of information. For example, you can have the variable Name, with the value John Doe, and when you enter Name in an action’s parameters Fuga inserts John Doe when the flow is performed.

Values

The value of a variable is what the variable is equal to at a certain point. While the variable is like the container, the value is like what’s inside the container. As you run or step through the flow, the Value column of the Variables list updates with the current value of the variable, so you can always tell what it is at any given point.

Variable Types

In Fuga, the value of a variable can be a text string (i.e., normal text), a number, or a date. You specify which type of variable you’re using from the Variable Type drop down menu when you create a variable. For more on the different content types, see the article Content Types.

How to Use Variables

a new variable in the Variables list of the Fuga Workshop panel

How to Create a Variable

To create a variable:

  1. Click in the Variable column in the bottom half of the Fuga Workshop Panel to create the variable.
  2. Click the text once more to rename your variable.
  3. If you would like to set a default value for the variable:
    1. Insert the default value of the variable in the value column. Insert strings without quotes.
  4. In the menu in the Type column, select what type of variable the new variable is (if it’s a string, a number, or a date).
  5. You can now use the variable in your flow by simply typing the name of the variable into an action’s parameters. Fuga will know it’s not normal text (a string) since it doesn’t have quotes around it.

How to Delete a Variable

To delete a variable:

  1. Hover over the variable name in the Variables column.
  2. Click the “x” button that appears on the right side of the name column.

How to Set the Default Value of a Variable

To set the default value of a variable:

  1. Single click in the Value column next to the variable name.
  2. Insert the value. This value must correspond with the variable type. See the article on Content Types for more information.

How to Use the Value of a Variable in an Action

In an action’s parameters, instead of using static values (i.e. information that’s not a variable), simply type in the name of the variable without quotes, so that Fuga can tell it apart from a string. For how to combine variable and strings or numbers, see the article on Expressions.

How to Set the Value of Variables Within a Flow

More frequently than not, you’ll probably find that you don’t need to give variables default values in the Variables list, since they’ll be set inside the flow. There are many different ways to do this.

The Set Action

The Set Action allows you to change the value of a variable directly. For example, using the set action you tell Fuga to set the value of the variable Color as “Blue”. You can also use an expression here to combine or do math with variables. For example, you can tell Fuga to set the value of FullName as FirstName + ” ” + LastName (” ” is for the space between words). You can also tell Fuga to set the value of Width to Width + 10.

The Get Value Action

The Get Value action allows you to get information from the document, and set it as the value of a variable. For example, you can get the name or the width of the selected object and set it as a variable.

The Get Text Action

The Get Text action sets the value of a variable to text from a text frame in the document.

The Ask Action

The Ask action allows you to ask the person performing the flow for a value, and then assigns the value to a variable.

The Loop Action

Most loops use loop variables, which changes the value of the variable each time the loop repeats. For more information, see the article on Loops.

Examples of When to Use Variables

Making Flows Easy To Manage

A good time to use a variable is when there’s a piece of information that you use in multiple actions and you also want to be able to update easily, without having to go through every action and updating each one.

One example of this is the location of a file. In a long flow you might have to specify the location of a CSV file in five different actions, and chances are that the location of the CSV is going to change depending upon which computer you’re running the flow from. If you create a variable called CSVLocation, and use this variable instead of actually specifying the file path each time, you can simply change the value of CSVLocation when you want to use a different path. You can even use the Ask action to prompt the user to specify the location of the CSV, and have the flow automatically set it as the value of CSVLocation.

Loops and Variables

Loops are also great examples of when to use variables inside a flow. Loops are used to tell Fuga to repeat a set of the same actions over and over again. Often times when using a loop though, you’ll want to make these actions apply to slightly different situations, and this is when using a variable is helpful.

Variables as Counters

Often times in a loop, you’ll want to duplicate an object and give each duplication a unique name. An easy way to do this is by naming each object with a number. To do this you can create a numeric loop with a Duplicate action inside it and a variable to serve as the loop counter. Then you use the loop counter variable in the Duplicate action’s rename parameters. The loop counter updates each time the loop is performed, and so does the object’s name, so you send up with objects named “1″, “2″, “3″ and so on.

You could also combine a variable with normal text to give your boxes names like “Box1,” “Box2,” “Box3.” For more information on combining variables and strings, see the article on Expressions.

Variables in Conditionals

One of the most powerful uses of variables is in combination with the If action. You can take a piece of information from a CSV, or another source, load it into a variable using the Load Vars action, and the flow can perform certain actions based on what it’s value is. For more on this topic, see the article on Conditionals.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>