Jump to content
twols

Evaluate boolean expression stored in a string

Recommended Posts

Hello guys!

 

Is it possible to parse and evaluate a boolean expression stored in a string with standard LV VIs? I can't find anything..

 

Expression like this one: 1==2 && (2!=5 || 2 > 5)

 

I'm building a configuration xml-file with if-attributes for conditions:

 

<item name="xyz" if="{namespace:variable} == 3" />

The first step is replacing the variables within {} with actual values. This is the easy part. The hard part is to evaluate the results...

Share this post


Link to post
Share on other sites

I'm not sure there is something that will evaluate that exactly, however look in the Mathematics->Scripts & Formulas->1D & 2D Evaluation pallet.

Share this post


Link to post
Share on other sites

Here's a post on Lava that mentions how to do it in Python (never tried it)

 

http://lavag.org/topic/15304-calculating-dynamic-formulas-with-boolean-operations/

 

Also it links to an NI site where another method can be used.

 

https://decibel.ni.com/content/docs/DOC-13186

  • Like 1

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Similar Content

    • By Porter
      View File LV muParser
      LV-muParser provides a simple LabVIEW API for muParser fast math expression parser.
      A modified version of muParser v2.2.5 is included. It will be installed to your "<LabVIEW>\resource" directory. I have added support for the "!" (not) operator as well as added ":" as a valid character for variable names.
      You will find the muParser API in the functions palette under "Addons > LAVA > muParser"
      muParser: http://beltoforion.de/article.php?a=muparser
      LV-muParser source on github: https://github.com/rfporter/LV-muParser
      Submitter Porter Submitted 08/25/2017 Category General LabVIEW Version 2015 License Type BSD (Most common)  
    • By Aishwarya Saravanan
      My project involves designing a front end for a synchronous generator using LabVIEW.   It is actually data acquisition and display of signals in a file.   The problem I face when building a program is that:   1)the sampling rate is set to 100 samples with 1 kHz sampling frequency.These signals are generated by daq assistant and i have used merge signals to merge these signals from daq assistant as well  as signals from other radio buttons and Boolean as well. The problem is that when written on a file I am able to see only one instance of Boolean status for every 100 samples daq assistant creates.   2) now iam able to write only 0/1 as status of Boolean in the file.How will I write on /off into file?

    • By Porter
      LV-muParser provides a simple LabVIEW API for muParser fast math expression parser.
      A modified version of muParser v2.2.5 is included. It will be installed to your "<LabVIEW>\resource" directory. I have added support for the "!" (not) operator as well as added ":" as a valid character for variable names.
      You will find the muParser API in the functions palette under "Addons > LAVA > muParser"
      muParser: http://beltoforion.de/article.php?a=muparser
      LV-muParser source on github: https://github.com/rfporter/LV-muParser
    • By Randy_S
      Good morning,
      I have a DLL I created (in Labview)  that takes in string information, does some magic crunching on it to create a password that is passed out as a string.  This DLL will be called from CVI and probably from a C# application.
      This should be so simple, however I cannot figure out how to pass the string in and get the modified string out of my DLL.
      I've had no luck at all getting this DLL to work by trying many different things.  It crashes LV, returns and error, or simply passes nothing out during my trials.
      I've included the project (its small) in zipped format.  Can one of you kind souls take a look at my code and tell me what I'm doing wrong, or what I need to do correctly to both, configure the DLL and then call it from LabVIEW?
       
      Thank you!
       
      Randy
      Password Generator.7z
    • By pkeny
      Hey all,
       
      I am trying to create a fairly large program.
       
      What I want to do is for someone to upload a text file, customized so I can create statements for it, and then labVIEW will read the the text file and perform actions.
       
      Specifically, the text will contain pin numbers, on/off status, wait delay, and another on/off status. The pin numbers correspond to a Boolean indicator array. The on/off status tell the Boolean indicator array to turn on/off. The wait delay tells the program to wait how long before changing the indicator array value again, and the second on/off status turns the Boolean array on/off after the wait delay.
       
      I cannot get the part where I want the Boolean array to change status after the wait delay. I am thinking the method of doing this would be a local variable, or a property value node. But, when I tried it, it would not even let the original status to turn on/off the indicator Boolean array, let alone changing the status after the wait delay.
       
      I have attached my code and text file (tab delimited) for another method of explanation.
      Altenbach wrote a big portion of the code for educational purposes
       
      If you delete the local variable, you will notice that the boolean array changes based on the first text column, versus it being constantly Gray if you have the local variable. 
      ExcelTest.txt
      Text Boolean.vi
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.