Example Code

Evaluate String/Numeric Expression

Code and Documents

Attachment

Overview

 An expression evaluator which has been written in LabVIEW.

 

Description

The included VIs allow an expression to be evaluated, including numeric expressions such as "5+6", plus string expressions. Brackets can be nested to any level, and a number of functions can also be used. Numeric operators include +-*/, and strings can be concatenated using "&".

 

The main expression is evaluated using the "Eval - Main" VI. Expressions can contain variables which can be set/read using the "Eval - Variable" VI. New functions can easily be added by editing the case statement in "Eval - Main".

 

An example front end has been included, "Front Panel.vi", to allow experimentation by entering a number of expressions and displaying their output.

 

Front Panel.png

 

Hardware and Software Requirements

LabVIEW 2010 or later

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

Contributors