NI Home
Cart Cart | Help
Company Events Academic NI Developer Zone Support Solutions Products & Services Contact NI MyNI

Currently Being Moderated

Sort 2D String Array

VERSION 7

Created on: Sep 28, 2008 9:39 PM by Mark.Ridgley - Last Modified:  Nov 29, 2008 11:21 PM by Mark.Ridgley

REQUIREMENTS:
Application Software: LabVIEW Professional Development System 7.0
Driver Software: NI-VISA 8.7.2,8.7.1
Hardware Family: CompactDAQ, Multifunction DAQ (MIO)
Add-on Software: LabVIEW FPGA Module 8.6
Product Category: LabWindows/CVI
Development Topic: Mathematics
Industry: ATE/Instrumentation
Application Type: Resistance
Technology: Java

Readme file for Sort 2D String Array VI

Description



The Sort 2D String Array VI performs a multi-column sort on a 2D array of strings that contains both plain text strings and strings representing real numbers. The user can specify the column sort order.

Run the included example VI to see how you can use this functionality in your applications.

 

NOTE: To ensure that you are using the latest version of the Sort 2D String Array VI, please download the file with the most current date in the file name.



Usage Scenarios



You store test parameters in a file consisting of one record for each named test.

The records consist of the following elements represented as columns in the data:

  • Test Name

  • CurrentComp

  • CurrRange

  • SourceVoltage

  • VoltRange

  • Amplitude

  • Width

  • ActivePressure

  • Temperature


Your test requirements call for running various tests at different temperatures. Each time that the temperature is changed, a 20 minute ramp-up and temperature stabilization period is required .

To minimize test time, it is desirable to perform all of the tests with the same temperature requirement before moving to the next temperature set point.

The Sort 2D String Array VI enables you to accomplish this by providing the ability to sort a 2D array of strings that contains both plain text strings and strings representing real numbers. In this case, the Sort 2D String Array VI enables you to sort your test parameters first on the temperature and then on the test name.

 

For example, the Sort 2D String Array VI enables you to sort the data in the following table first by Amplitude and then by Test Name:

Test Name

CurrentComp

CurrRange

SourceVoltage

VoltRange

Amplitude

Width

ActivePressure

Temperature

Battery000

6.693E-1

2.06E+0

5.0

100.00

3.957118784

10.00

True

4.00

Battery001

1.950E+0

2.51E+0

9.5

5.00

0.934304207

40.00

False

26.00

Battery002

3.569E+0

6.40E-1

3.2

10.00

-2.327802279

30.00

True

22.00

Battery003

2.501E+0

2.51E+0

9.5

10.00

2.035078922

40.00

False

28.00

Battery004

1.180E+0

2.33E+0

5.0

20.00

3.257387404

20.00

True

11.00


The result of the sort is:

Amplitude

Test Name

CurrentComp

CurrRange

SourceVoltage

VoltRange

Width

ActivePressure

Temperature

-2.327802279

Battery002

3.569E+0

6.40E-1

3.2

10.00

30.00

True

22.00

0.934304207

Battery001

1.950E+0

2.51E+0

9.5

5.00

40.00

False

26.00

2.035078922

Battery003

2.501E+0

2.51E+0

9.5

10.00

40.00

False

28.00

3.257387404

Battery004

1.180E+0

2.33E+0

5.0

20.00

20.00

True

11.00

3.957118784

Battery000

6.693E-1

2.06E+0

5.0

100.00

10.00

True

4.00

 

Run the included example VI to see how it works.

 

 

Required Downloads



To use the Sort 2D String Array VI and the included example VI, you must download and install the following two VIs:
- Busy Indicator VI. Download the Show Busy Indicator VI.
- Selection Dialog VI. Download the  Selection Dialog VI.

 

 

Application Software



LabVIEW 7.x

 

 

 

Driver Software



None.

 

 

Concepts Illustrated



The Sort 2D String Array VI illustrates the following concepts:

  • A technique for sorting a 2D array of strings that contains both plain text strings and strings representing real numbers.

  • Using the Busy Indicator VI to provide an indication to the user that the system is busy.

  • Using the Selection Dialog VI to enable the user to select items from a list and manage the selected items.

 

 

Description of Operation



The Sort 2D String Array VI performs a multi-column sort on a 2D array of strings that contains both plain text strings and strings representing real numbers. The user can specify the column sort order.

 

 

Extracting the files



The Sort 2D String Array VI is supplied as a zip archive containing all required items. The zip archive contains full path information.

When extracting the items, set the path to C:\. Since the zip archive includes full path information, the included items will be extracted to the following path:

C:\Program Files\National Instruments\LabVIEW 7.0\user.lib

Extracting the items to the user.lib directory makes the Sort 2D String Array and usage example VI available on the LabVIEW Functions palette.

 

 

Additional Information



Additional information related to the use and operation of the Sort 2D String Array VI may be accessed via:

  • The block diagrams of all included VIs

  • The documentation within all included VIs

 

 

Change Control


 

11-11-2008
Modified the Sort 2D String Array.vi so that the output array is always the same size as the input array.

 

11-10-2008
Modified the Sort 2D String Array - String or Number.vi to scan for dates formatted as: nn<separator>nn<separator>nnnn or nnnn<separator>nn<separator>nn.

 

Modified the Sort 2D String Array - Sort Data.vi so that no rows are dropped when the "Input Array Contains Header Row? (T)" input is false.

 

Modified the Sort 2D String Array.vi so that the input array is passed to the output array unchanged if the user cancels the sort operation.

 

Modified the Sort 2D String Array.vi so that the array without headers is passed to the output when the "Input Array Contains Header Row? (T)" input is false.

 

 

Developed by



Mark Ridgley
mark.ridgley@logicpd.com

 

Downloads:
Tags: labview
Average User Rating
(0 ratings)




Ancle Ancle  says:

When I try this vi, I found there is a bug. Please see the attached image. Thank you!

 

Mark.Ridgley Mark.Ridgley  says in response to Ancle:

Hello, Ancle

 

The behavior that you are observing is by design.

 

The Sort 2D Array - String or Number VI examines each character in "Input String" individually and determines if that character is a hex digit ranging from 0 through 9, A through F, or a through f.

 

If all characters in "Input String" are hex digits ranging from 0 through 9, A through F, or a through f, then the "Is Num" output is True as shown in the image that you posted.

 

In the test case that you posted, each character in the string "ABCDEF" is a hex digit ranging from A through F, so "Is Num" is True. If you add a "G" anywhere within that string, then "Is Num" will be False.

 

In your usage of this VI, does the data that you are trying to sort normally contain strings where all of the characters in the string range from 0 through 9, A through F, or a through f that should not be interpreted as hex numbers?

 

Thanks for posting.

Ancle Ancle  says in response to Mark.Ridgley:

Hello Mark,

 

Sorry, I should say " I am not sure it's bug or not?"

In my application, I have a column, strings are"A,B,C,D". When I sort the 2D array. This column shows all "0". How can I solve this problem(can show "A,B,C,D")? Thank you!

 

Best Regards

Ancle

More Like This

  • Retrieving data ...