Cancel
Showing results for 
Search instead for 
Did you mean: 

Referring to Attributes of Enities

Pioneer
Pioneer

When I want to add an attribute to a MU I normally just open the table in the attributes column of my initial tablefile and choose a name for the attribute, e.g. ProcTime, and type the wanted time in the time clomun of said table. Afterwards I can refer to that entry by writing "Name.ProcTime".

 

In this case though I wanted to add several attributes of different types to one attribute name. So for example under the name "G10" I want to add an integer "5" a time "1:00:00" and a boolean false. Which I can do theoretically, since I can type that data into the table. But how can I refer to the different datatypes later? If I use a method and try "print Name.G10" the console shows one of the entries. How do I refer to a specific one?

6 REPLIES 6

Re: Referring to Attributes of Enities

Gears Esteemed Contributor Gears Esteemed Contributor
Gears Esteemed Contributor
select table as data type of the attribute; you access a table attribute like the tableFile with [column,row] e.g.

name.G10[2,1] -- second column, first row
Steffen Bangsow
freelance simulation specialist  
web: www.bangsow.eu
mail: steffen@bangsow.net

Re: Referring to Attributes of Enities

Pioneer
Pioneer

I tried that and it didn't work. I do get the error messag "unknown identifier G10". I reduced the frame to the important objects and attached it.

 As you can see the method will print the boolean value in my attributes table when I refer to "@.G1". I'm also not able to refer to the table with "@.a[6,1]". I want to refer to the entries in the time column.

Re: Referring to Attributes of Enities

Gears Esteemed Contributor Gears Esteemed Contributor
Gears Esteemed Contributor
in the asttributes you need to define an attribute of type table. Enter only an x into the field and double click into the cell. In the sub table you need to format the columns and set the values.
You can also copy and past sub tables.
Steffen Bangsow
freelance simulation specialist  
web: www.bangsow.eu
mail: steffen@bangsow.net

Re: Referring to Attributes of Enities

Pioneer
Pioneer

Tried that before, too. Like you said I created the attribute as a table in the table and tried to refer to it as "G1[6,1]" but I still get the error unknown identifier.

 

EDIT: I checked again and I think I got what yoiu tried to say now. In the attributes table I have to create attributes with a table, as in write the name of the attribute and a x in the table column. Then add the attributes in the new table and refer to them by the initial attribute name. The problem is if I do that I get the value, followed by an immediate error "Addressing by index is only possible for lists, arrays or for objects with capacity > 1".

Re: Referring to Attributes of Enities

Gears Esteemed Contributor Gears Esteemed Contributor
Gears Esteemed Contributor

still wrong

 

in the attribute table each row definies one attribute; in the first column you define the name of the attribute (data type string), the initial value you write into the column with the right data type

I have adjusted your model.

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

Re: Referring to Attributes of Enities

Pioneer
Pioneer

I tried exactly that when I postet my "edit" (the model file was from before that) but I forgot to change the data type of the column that contains the attribute names back to "String".

 

Thanks so much for sticking with me until the end!