Let's see if I can elaborate...
The following outlines the relevant characters in simio file "table_selection_by_name.spfx."
Model->Definitions:
Properties:
OptionId (Entity Property, default=null)
_SelectedTable (Table Property, default=tableOption1)
States:
RowId (integer, default=1)
maxEntities (integer, default=2)
ModelEntity->Definitions:
States:
_id (Integer, default=0)
row_num (integer, default=0)
temp (integer, default=0)
Model->Facility:
ModelEntity Types: Option1, Option2
Source1, Server1, Sink1
Source1->Entity Arrival Logic:
Entity Type = OptionId (Reference Property)
InterarrivalTime = 1 second
Source1->Stopping Conditions->Maximum Arrivals = maxEntities
Source1->Add-On Process Triggers->Created Entity = Source1_CreatedEntity
Sink1->Add-On Process Triggers->Entered=Input_Sink1_Entered
Model->Facility->Controls->General:
OptionId = Option1
_SelectedTable = tableOption1
Model->Processes:
Input@Sink1 Add-On Processes
Input_Sink1_Entered:
[Begin->
Tally(temp = ModelEntity.temp)
End]
Source1 Add-on Processes:
Source1_CreatedEntity:
*************************
[Begin->Decide1(IsOption1 = True)->
Assign(maxEntities = tableOption1.AvailableRowCount)->
SetRow(tableOption1, RowId)->
Assign(ModelEntity._id = tableOption1.id, ModelEntity.row_num = tableOption1.row_num, ModelEntity.temp = tableOption1.temp)->
Assign(RowId = RowId + 1)->End
Decide1(IsOption1 = False)->
Decide2(IsOption2 = True)->
Assign(maxEntities = tableOption2.AvailableRowCount)->
SetRow(tableOption2, RowId)->
Assign(ModelEntity._id = tableOption2.id, ModelEntity.row_num = tableOption2.row_num, ModelEntity.temp = tableOption2.temp)->
Assign(RowId = RowId + 1)->End
Decide2(IsOption2 = False)->
End]
*************************
It is here that I could like to simply the logic using something like _SelectedTable instead of tableOption1 and tableOption2. I would like to know how to replace Source1_CreatedEntity's above step definitions with something like:
[Begin->
Assign(maxEntities = _SelectedTable.AvailableRowCount)->
SetRow(_SelectedTable, RowId)
Assign(ModelEntity._id = _SelectedTable.id, ModelEntity.row_num = _SelectedTable.row_num, ModelEntity.temp = _SelectedTable.temp)->
Assign(RowId = RowId + 1)->
End]
But this replacement does not work.
The following works, but I'm searching for a way to do this without replacing the column name with an indexed value:
[Begin->
Assign(maxEntities = _SelectedTable.AvailableRowCount)->
Assign(ModelEntity._id = _SelectedTable.id[RowId, 1], ModelEntity.row_num = _SelectedTable[RowId, 2], ModelEntity.temp = _SelectedTable[RowId, 3] )->
Assign(RowId = RowId + 1)->
End]