Cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted

How to write an array from tablefile

Creator
Creator

Hello community,

 

In SimTalk 2.0 I meet the following, as it woud seem rather simple issue:

 

From a Tablefile (Schedule) I created, I want to write one of its rows (3rd one, only integer values) into an one {1}x{*} -dimensional array, as I dont know how many rows there might be put into the Schedule in the future. So my idea was this:

 

var Array : integer[]
Array := makeArray(Schedule[3,{1}..{*})

 

But now the console tells me that the index is unknown. I figure I am just not using the right syntax in order to select the range of the Tablefile somehow. Or maybe it is just not that easy as I expected at this point?

Help will be highly appreciated!

 

Thanks in advance!

 

Timbo

5 REPLIES 5

Betreff: How to write an array from tablefile

Siemens Phenom Siemens Phenom
Siemens Phenom

Hello Timbo47,

 

you can use the command copyFromTable to copy a column or row from a table into an array.

 

Hope this helps.

 

Regards

GG

Regards
GG

------------------------------------------------------------------------------------------------------
Did you like the answer? Then click the Thumbs Up button.
Did the answer solve your problem? Then accept the answer as solution

Re: How to write an array from tablefile

Gears Esteemed Contributor Gears Esteemed Contributor
Gears Esteemed Contributor

copyFromTable works in connection with a one dimensional arrays only, if a row contains the values.

 

In your case this should work:

 

var arr:integer[]
for var i:=1 to schedule.getColumnYDim(3) loop
 arr.insert(i,schedule[1,i])
next

Steffen Bangsow
freelance simulation specialist  
web: www.bangsow.eu
mail: steffen@bangsow.net

Betreff: How to write an array from tablefile

Siemens Phenom Siemens Phenom
Siemens Phenom

Hello Timbo 47,

 

you can use the following code:

var YD : integer := Schedule.getColumnYDim(3)
var Arr : integer[YD]
arr .copyFromTable({3,1}..{3,YD}, schedule)

Hope this helps

 

Regards

GG

Regards
GG

------------------------------------------------------------------------------------------------------
Did you like the answer? Then click the Thumbs Up button.
Did the answer solve your problem? Then accept the answer as solution

Re: How to write an array from tablefile

Creator
Creator
Thanks Steffen!
That worked perfectly fine.

Betreff: How to write an array from tablefile

Creator
Creator

Hi GG,

 

I have some problem with your solution as a syntax error occurs in line

 

var Arr : integer[YD]

 

Any assumption why that is?

Thanks