How does labview distinguish between array size info and the array data?

StackOverflow https://stackoverflow.com/questions/21151866

  •  28-09-2022
  •  | 
  •  

سؤال

This isn't really a question about how to do something, more just to satisfy my curiosity.

According to this, Labview stores arrays in memory as a series of int32s describing the size of each dimension followed by the actual data. So, e.g., a 2-d array of size 3x5 would be stored as

0: 3
4: 5
8: data starts here

Now suppose you have an array of int32s. How would labview tell the difference between the actual data and the array size information? In the example above, for instance, how does labview know it's a 3x5 array and not a 1-d array of length 3 and then just ignore the remaining elements? Sorry if there is something obvious that I am missing.

هل كانت مفيدة؟

المحلول 2

When references to data are passed around in LabVIEW internally, the data type is always passed around, too. Data is passed around as void pointers and the type is passed along with them. So any time LabVIEW sees your array, it'll also see that the type is a 2d array of int32s. (I work on the LabVIEW team at National Instruments)

نصائح أخرى

If you look at the LabVIEW KB Article How LabVIEW stores data in memory, you'll see that every data-type is stored with type information. For an array it first stores an I32 for each dimension, followed by the flattenend data. The actual data-type is stored in it's type-descriptor, it consists of a list of the different contained type descriptors. For an array the minimum is two:

  1. The array
  2. The data in the array

The array's type descriptor is

<nn> xx40 <k> <k dims> <k elems> <element type descriptor>

where nn is the total data-packet size
xx40 is the array datatype
k is the total number of dimensions

For the contained I32 the type descriptor is:

0004 xx03 xx

0004 is the length of the type descriptor 03 is the I32 type identifier

However it's has been changed between LabVIEW 7 and 8. Relying on the type descriptor is something you shouldn't mess with yourself. Let LabVIEW handle this.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top