From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
07-08-2013 01:37 PM
Hi,
how i can insert different data types into array, (e.g. numeric and string) in the same index of an array.
example:
index0 car 10 green
index1 11 car red
index2 car blue 12
where car green, car red and car blue as string and 10, 11 and 12 as numeric.
then i will extract 10, 11 and 12 to a numeric array
and, car green, car red, car blue to a string array
Help!
Solved! Go to Solution.
07-08-2013 01:42 PM
All elements on an array must have the same datatype.
Please tell us a little more what you are actually trying to achieve with all this.
07-08-2013 01:42 PM
An Array is of a single data type and must always be so. You can not do as you ask but there are ways to accomplish something similar. For instance, the array can be strings and simply convert the numeric portion to a numeric data type later as you construct the separate array.
So you would have "car red 10" and then later extract the "10" and convert it to a number.
Another option, is to use an array of Clusters. Clusters group objects of any data type together but they must all be of the same design (data types must always be in the same order). The data you provided seems to indicate the order of the number and car color will be random ( i have absolutely no idea why you want this as it only causes additional problems).
07-08-2013 01:46 PM
"So you would have "car red 10" and then later extract the "10" and convert it to a number."
this way how it can be done ?
07-08-2013 01:54 PM
Use "Scan from String" like in the attached image. This will extract both the number and color which you can add to arrays later.
07-08-2013 09:14 PM
thanx alot pjr1121 🙂