Example Code

MathScript Node Input Parse String Array

Code and Documents

Attachment

Overview
LabVIEW makes it very easy to append or concantenate an array of strings, but the MathScript node implements this functionality differently. This example demonstrates how to concanentate arrays of strings, removing some of the blanks.


Description

The code in the MathScript node works as follows:

Line number:

1: Declaring a variable which uses the size function built into the node to get the size of the input array (in this case first names)

2: Doing the same thing on the second input array (last names)

4: Creating a final output variable

6: Comparing sizes of the array to look for issues in sizes

7: Starting the search of array lengths

8: Building string1

9: Building string2

10: Concantenating the strings together using the strconcat function.

11: End

12: End

Additional functions which could be added:

deblank to get rid of the additional spaces


Requirements

  • LabVIEW 2012 (or compatible)
  • MathScript 12.0 (or compatible)


Steps to Implement or Execute Code

  1. Download and open Mathscript String.vi
  2. Type in several first names to Array
  3. Type in several last names to Array 2
  4. Press the run button - the VI will populate the final array with the first name/last name combinations

 

Additional Information or References
VI Snippet

 Block Diagram.png

 

 **This document has been updated to meet the current required format for the NI Code Exchange.**

Sam S
Applications Engineer
National Instruments

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.