IBM Support

ObjectGEODE: How can I initialize all elements of an array?

Question & Answer


Question

ObjectGEODE: How can I initialize all elements of an array?

Answer

SDL Standard

In SDL standard there is no constructor to initialize all elements of an array with a different value. You can only initialize with the same value or initialize each element one by one. For instance:

SYNONYM Max = 2;

SYNTYPE index = NATURAL 
CONSTANTS 1 : Max
ENDSYNTYPE ;

NEWTYPE A
     Array (index , integer)
ENDNEWTYPE A ;

/* All elements are initialized with the same value */

DCL TA A := (. 7 .);

/* Each element is initialized with a different value

*/

DCL TA A ;

TASK TA(1) := 1 ;

TASK TA(2) := 2 ;

ObjectGeode Simulator extension

The ObjectGeode simulator supports another constructor operator for "ordinary arrays". It is defined as follows :

mk<array sort> : <element sort>, ... -> <array sort>

This operator can only be used in an MSC description or in the command language.

For more information look in section "SDL Extensions-Array constructor" of the ObjectGeode SDL Simulator reference manual.

 For instance in the MSC description you have

signal B ( mkA(1,2), 3, 4.0)

ObjectGeodeFAQ1277AnswerProduct versionPartner ContentInternal ContentCategoryReference ID

[{"Product":{"code":"SSYQGX","label":"Rational Tau"},"Business Unit":{"code":"BU053","label":"Cloud & Data Platform"},"Component":"General Information","Platform":[{"code":"PF025","label":"Platform Independent"}],"Version":"Version Independent","Edition":"","Line of Business":{"code":"LOB45","label":"Automation"}}]

Historical Number

KB1277

Document Information

Modified date:
16 June 2018

UID

swg21325147