Discussion:
What is the difference between an array and a table
(too old to reply)
Tesser
2008-08-12 09:10:10 UTC
Permalink
Hi everybody, I am developping a test appliction based on a framework provided by our customer.The provided VIs are using references in order to pass string tables/arrays, used to create the test report.Unfortunately some VIs require a reference to a table of string, and other ones require a reference to an array of strings. Interconnecting those two data types results in a broken wire.After my reserach done of the forum, an array should be equivalent to a table, but apparently it isn't. So I would like to understand whcih are the differences between an array and a table and how can I transform references so they will be accepted by the VIs.Thanks a lot!!
Wiebe@CARYA
2008-08-12 10:20:49 UTC
Permalink
I don't know where you've read that an array is the same as a table, but the
facts are a bit different.

From a value point of view, a table is a 2D array of strings. An array can
also be 1d, 3d or xd, making it different from a table. An array can also
contain numerics, enums, or basically an data type. If an array is 2D, and
it contains strings, the data type is the same as a table.

From a reference point of view, a 2D array and a table are two entirly
different things. They share some properties, basically the properties all
controls have, and perhaps a few more. If you cast the references to a
"control" refererence, you'll notice you can still set the value property.
But, the value is a variant. This is because a control can have any data
type. If you wire a table, you can put a 2d array of strings into the value.
If you have an array control, you can also do this, but it will only succeed
if the array is a 2D array of strings.

Hope this clear it up a little...

Wiebe.
MikeS81
2008-08-12 09:40:08 UTC
Permalink
Hi Tesser,
arrays and tables are different controls. An array can have all dimesions and data types, while a table contains data in a 2D array of string. If you need a table refnum, create a table on your fp, tranform your data to 2d array of string and write it to your table. create a refnum and pass it to your subvi.
Hope it helps.Mike
Tesser
2008-08-12 10:10:07 UTC
Permalink
Hi thanks a lot for this clarification. I found I way by extrating the value from the table (using a property node) and feeding it into a 2D string array indicator. (1) I then passed a reference to this indicator the VI that requires a 2D string array reference. (2)I then extracted the value of the array and feeded it onto a property node of the initial table reference.(3)To make sure the execution order is respected I packed this three operations into an sequence. The sequence numbers are in brackets. I will try to see if the behaviour is as I expect it to be.This kind of code does not seem very clean to me, though. If there is a better way to do this, let me know!ThanksRamin
Wiebe@CARYA
2008-08-12 11:38:41 UTC
Permalink
When you have some VI's that use references as input, it's often better to
give all VI's a reference as input, in stead of mixing values and
references.

If you change all the VI's with 2D string arrays as input, so they use
references (and inside get the value from this reference) the code will
probably get cleaner. Mixing value and references can also cause hard to
find race conditions.

Of course, if you have a library of 2d string manipulating VI's, it's a
mistake to change then so they use a table reference as input. This would
make them less generic. In this case, I'd consider making a wrapper around
it that gets the value and then calls the VI. These kind of choises are hard
to explain how and why to make them...

Regards,

Wiebe.

parthabe
2008-08-12 10:10:07 UTC
Permalink
The main difference between an array(2D)  and a table is that the Table is the decorative form of a 2D Str array. :smileywink:
Continue reading on narkive:
Loading...