steveandrews Posted November 2, 2020 Share Posted November 2, 2020 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 Quote Link to comment Share on other sites More sharing options...
AzeoTech Posted November 2, 2020 Share Posted November 2, 2020 That is a little tricky, but doable. How often does table_array change? Quote Link to comment Share on other sites More sharing options...
steveandrews Posted November 2, 2020 Author Share Posted November 2, 2020 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 Quote Link to comment Share on other sites More sharing options...
AzeoTech Posted November 2, 2020 Share Posted November 2, 2020 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. Quote Link to comment Share on other sites More sharing options...
steveandrews Posted November 2, 2020 Author Share Posted November 2, 2020 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 Quote Link to comment Share on other sites More sharing options...
AzeoTech Posted November 2, 2020 Share Posted November 2, 2020 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. Quote Link to comment Share on other sites More sharing options...
steveandrews Posted November 2, 2020 Author Share Posted November 2, 2020 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 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.