Contact Us

If you still have questions or prefer to get help directly from an agent, please submit a request.
We’ll get back to you as soon as possible.

Please fill out the contact form below and we will reply as soon as possible.

  • Contact Us
  • Home
  • Products
  • Software
  • Sysmac Studio

How to use Enumerators in Sysmac Studio

Written by Nick Lim

Updated at March 12th, 2025

Contact Us

If you still have questions or prefer to get help directly from an agent, please submit a request.
We’ll get back to you as soon as possible.

Please fill out the contact form below and we will reply as soon as possible.

  • Products
    Automation Systems Control Components Motion & Drives Quality control & Inspection Robotics Safety Sensing Services Software Switching Components
  • Amplify e-Store
    e-Store public
  • Public CSC
+ More

Enumerators are a custom data structure of named constants for integers. These assist in making your code more readable and is typically used when a list of predefined inputs/outputs are needed.

Creating Enumerators

To create an enumerator perform the following steps:

  1. In the Multiview Explorer tab go to Programming → Data → Data Types
  2. Click Enumerated on the left side of the main Edit Pane
  3. Right click the main edit pane area and select create New Data Type
  4. After giving your enumerator a name right click and select create New Member
  5. Name and give an enumerator value to the member
  6. Repeat steps 4 and 5 as necessary
 
 

How to Assign Enumerators

There are two methods to set an enumerator manually if needed.

Converting an Int

The first method would be to use the NumToEnum function.

As can be seen by applying the correct integer value we can select our desired value of the enumerator.

Directly Assigning the Enumerator

You can also directly assign the enumerated value using the following syntax:

<Name of enumerator data type>#<Enumerated value>

 
 

Comparing Enumerators

Occasionally you may find that you need to compare the data in an enumerator to determine its state. 

A good example of this would be interpreting the output of the GetDayOfWeek Function. As we can see from the documentation the output is an enumerated data type

Since we cannot directly compare this to a string or Integer as there would be a mismatched we would either need to directly compare the enumerated value or convert the enumerated value  to be compared.

Converting the Enumerator

The first method we could do is use the EnumToNum function to convert the enumerator into a double Int. From our example above Tuesday is 2 on the enumerator table so therefor would be converted to 2.

Directly Comparing the Enumerator

We can also directly compare to the enumerated value using the following syntax: 
<Name of enumerator data type>#<Enumerated value>

This is demonstrated in the example below.

 
 

 

sysmac studio enumerators comparison

Was this article helpful?

Yes
No
Give feedback about this article

Related Articles

  • How to determine the route path for NX/NJ PLCs
  • Step by Step Guide - CP1L-E connection to an NS Screen via Ethernet/FINS
  • How to Use Special Characters in Sysmac

Definition by Author

0
0
Expand