steveandrews

table display via lookup

Recommended Posts

Hi,

I have a table displaying selected contents of a 3d array (table_array). It's all numerical and if possible id like not to modify this array, just display it.

For one of the table columns, i would like the table to take the numerical value, say 0,1,2..  and display text from a look-up string array corresponding to those integers. Forother columns just display the numerical value as it is.

I initially thought just expression:  lookup_array[table_array[]]   but this obviously only displays one value in the table, i need to display all the rows of table_array but substituting the numerical value of each row for that column, with a string from the lookup array.

Any ideas? Cheers

Share this post


Link to post
Share on other sites

not often, it's a data history received from polled slave devices and gets updated when a user manually requests it or closes a pop-up that has recorded a few actions 

Share this post


Link to post
Share on other sites

Then just create a little sequence that runs at low priority that fills a string array.  Something like:

global string labels

for (private i = 0, i < numrows(table_array), i++)
   labels = lookup_array[table_array]
endfor

Run it at priority 0 whenever you want to update and have the actual table display use the labels variable for that column.

Share this post


Link to post
Share on other sites

Yeah, I was hoping there might be a more elegant way to 'convert' the value dynamically with some fancy syntax in the expression because the table switches between displaying multiple depths of the array. I can make a separate 3d string array for display I suppose, it can just be generated when the array changes as it changes with a function call

 

Share this post


Link to post
Share on other sites

No, because you are asking it to subset an array based on an array of indices.  It would work fine for a single element, but not an array of elements.  I don't know your app, but I would consider just maintaining another string array parallel to the index array that is automatically updated whenever the index element changes.

Share this post


Link to post
Share on other sites

Yeah you're right. It's always array subsetting that I get stuck on, I guess what's in my head often doesn't translate and I need to realise that a loop is still fast and the easiest way to do it. 

Thanks for the help

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now