top of page
Search

Declaring arrays in the SCL editor

  • Writer: Ivaylo Fiziev
    Ivaylo Fiziev
  • Sep 5
  • 2 min read
ree

For quite long time we were missing the ability to declare arrays in the SCL editor. Although arrays are not widely used in Process Simulate there are cases where they come in handy. The intention is that they will be used by the logic inside the script. Use cases like sorting, searching, queueing, truth tables etc. all require an array. However if you think of doing I/O based on arrays, you should rethink the approach. Process Simulate is very limited when it comes to signal types. Only primitive types for now. Sorry.


Q: So how do we declare an array in the SCL editor?

A:To do so we are introducing two new columns (Array & Bounds) in the variables table. It looks like this:

ree

It is pretty straight forward but still needs some explanation:


When you check the array box next to the variable's type, the variable will be declared as an array of this type. The array's dimensions and size are then provided in the 'Bounds' column. You can have up to three dimensions, each containing different number of elements. For each dimension you provide the lower/upper element index separated by two dots. Dimensions are separated by a comma.

Example: 0..9,1..7 - a two dimensional array.

The first dimension has 10 elements. The first one is at index 0.The last one is at index 9.

The second dimension has 7 elements. The first one is at index 1. The last one is at index 7.

Think of it like a table with 10 rows and 7 columns. Overall it contains 70 elements.


Going back to the Array initialization list post, default values can be applied as a list of literals. Each literal represents an element of the array. Literals are separated by a comma. As with the primitive data types, default values for arrays are optional.

Special types (like TX_OBJECT) use an object picker for setting the default value. In the case of TX_OBJECT array the object picker is missing. The array works but you need to set the default values manually. This should be improved in the future.

// object external ids	
objects : Array [1..2] of TX_OBJECT := [ '7577DA01-E7CF-4A0F-947C-7F94BE09ADE9', 'E10E84A4-2D7A-4B2A-94D1-C4A9CA990236' ];

In case of a syntax error you'll get the usual error message when you run the code. Code validation / code completion will not work if the declaration is wrong!


Signals cannot be connected to variables of type array!


Version 2512 will have the updated user interface.

Previously you had to declare the array manually in the code of the script and paste it in the SCL editor. This is still an option but I believe the UI will be the preferred choice for the majority of the customers.

Hope you like it!


 
 
 

Comments

Rated 0 out of 5 stars.
No ratings yet

Add a rating

Subscribe Form

Thanks for submitting!

bottom of page