Objective
The objective of this practice problem is for the user to demonstrate an understanding of the Variable commands discussed in the previous section by creating an automation that utilizes those commands. The commands covered in the previous section were the Set Variable. In the future, these commands may be implemented into other practice problems.
Scenario
A Station Master is asked to portray the current time after every 3 seconds
Prerequisites
None as of now
Practice Problem Requirements
The user must create an automation that performs the following tasks:
  • Create new variables (Name of the variable and its value must be specified)
  • Set a variable (Name of the variable and its value must be specified)

Problem Difficulty: Easy
Solution will be provided on the next page with a brief explanation.

Solution
The code for the solution has been provided below.

As a quick summary:

Step 1: The Set Variable command allows user to provide a variable with a new value. The name of the variable needs to be provided when being created using the Variables Manager window and its value needs to be assigned. In this practice problem, a new variable is created with the name vCount and given the value 3

Step 2: The Set Variable command is again used to assign a value to a different variable. Now, a new variable is created with the name vTime and the input assigned to this variable is the current hour and minute

Step 3: Do While command is used to start a loop. The condition of the loop must be specified from the dropdown menu and the necessary parameters must be added based on the requirement. In this practice problem, a loop is started and set to the condition that vCount is greater than 0.

Step 4: The Show Message command will show the current time by using the vTime variable.

Step 5: The Set Variable command is used change the value of vCount from 3 to 2 to 1, etc. Please refer to the Using an Iterative Variable Guide for more information on how to use iterative variables.

Newsletter Bot

Lets stay in touch!

Join our weekly newsletter and follow us on social media.

Contact Sales
Call Our Experts!