Kepler/SIL/JJUPIN script initialize array of structures

RVal
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 8, 2017

Is it possible to initialize array of structures in bulk in SIL script ?

For example

struct Subtask_struct {
string summary;
string description;
string reporter;
string assignee;
};

Subtask_struct[] subtasks = {
{"summary1", "description1", "reporter1", "assignee1"},
{"summary2", "description2", "reporter2", "assignee2"}
};

The code above returns me error saying it is not possible to convert string[][] to Subtask_struct[]

1 answer

0 votes
Jonathan Muse _Appfire_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 9, 2018

@RVal, you can defiantly do something like this:

 

struct Subtask_struct {
string summary;
string description;
string reporter;
string assignee;
};

Subtask_struct issue1 = {"summary1", "description1", "reporter1", "assignee1"};
Subtask_struct issue2 = {"summary2", "description2", "reporter2", "assignee2"};
Subtask_struct issue3 = {"summary3", "description3", "reporter3", "assignee3"};

Subtask_struct[] subtasks = {issue1, issue2, issue3};

 

Does that help? 

RVal
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 9, 2018

Yes I ended up doing doing something like that but it seams very verbose with lots of code repetitions and does not look good when you need 100th elements in the list.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events