Table expression

Recommended Posts

I'm retrieving from a CSV file a 2D array where the fields are a mix of strings, numbers, booleans (encoded as "TRUE" and "FALSE") and one field containing a number that's a list index.

So I'm displaying the array in a table where all the column definitions are MyArray[][FieldNumber], and they all work fine.    The list index doesn't work.    I tried the following expressions




but what I get instead is a list of TypeList[0..n], even though ConfigurationArray has all "5"s in the 10th column.

Link to comment
Share on other sites

First, you should only use () for function calls, and [] for subsetting.  StrToDouble() is a function.  The fact it works now does not guarantee it will work in future releases.

So, my understanding is that TypeList is a lookup table?  That you are trying to display a particular element of TypeList based on the value in ConfigurationArray[][10]?  If so, you can't do that on an array like this.  First, remember that configurationArray[][10] is actually a two dimensional array, with 1 row and x columns and you can't a subset only looks at the rows.  But the real problem is that the subsetting of typelist is only going to look at the first element of that array.  You couldn't, for example, do:

global indices = {2,1,5,4}
global string typeList = {'a','b','c','d','e','f'}
? typeList[indices]

This will just print 'c' because it only looks at the 2 of indices and ignores the rest.  DAQFactory doesn't understand what you are trying to do, and for good reason.  

This is, unfortunately, one of the few examples where you can't use built in functions to achieve what you are doing and instead have to resort to a loop.  That said, I've added a feature request to our list for a lookup() function that would work for this.  It is actually a very easy function to implement internally so we can probably squeeze it in real quick.  Email us direct if you'd like a beta.

Link to comment
Share on other sites

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.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.