question

Jason Merschat avatar image
1 Like"
Jason Merschat asked Matthew Gillespie commented

How to look up a Table Value using Headers?

I am trying to use token labels to find a value in a table. The token has the correct row label but it is being used as a number and not a string to find the value. See the picture attached please. You can see that the Row Header has the sought row value available and the label produced the correct value based on the error in the system console. The prescripted module for using the table converts it to a string type so I wonder what the issue can be?

FlexSim 18.0.1
global tablelookuprow header
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

1 Answer

·
Matthew Gillespie avatar image
3 Likes"
Matthew Gillespie answered Matthew Gillespie commented

Oh, your row headers are numbers! It's getting confused because you can specify a specific row using either the row number or the row header name. If you pass it a number it will look for that row number, whereas passing it a text value will cause it to look for that row header. However you're passing it a number and wanting it to look for a header that has the text value of that number. You need to use the string.fromNum() method to convert your number into a string:

string.fromNum(token.lbl_Material)
· 4
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Jason Merschat avatar image Jason Merschat commented ·

I know I was looking for some way to "stringify" that number... thanks for the help!

0 Likes 0 ·
Jason Merschat avatar image Jason Merschat commented ·

is there also a "string from Pointer" function? I have another case where I am looking to use the value of an acquired resource as the method to look up in a Global Table. The pointer would be a Row value in a table.

0 Likes 0 ·
Jason Merschat avatar image Jason Merschat Jason Merschat commented ·

found it... token.<Resource>.name

0 Likes 0 ·
Matthew Gillespie avatar image Matthew Gillespie ♦♦ Jason Merschat commented ·

There isn't really a "string to pointer" function, but a treenode has a property and a method that return strings that are commonly used.

The first is the name property which returns the name of the node.

node.name	// Processor1

The second is the getPath method which returns a string of the path to the node.

node.getPath()  // MODEL:/Processor1
0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.