Showing results for 
Search instead for 
Did you mean: 

Simple C code scripting environment in LabVIEW



I'd like to create a simple C code scripting control in GUI and convert those text to LabVIEW code.

I have been thinking how to make a most effective structure for that but is not easy to design.

So, kindly ask is there any idea or experience about this from you globally?

Users want to typing some conditions and logic based on C style text scripting.


Thanks in advance!!


Best Regards,

Best Regards,

0 Kudos
Message 1 of 6

You could look at the Formula Parsing Vis which come together with LabVIEW. They "only" implement mathematical formulas in text form and are already fairly complex. Mathematical formulas are in many ways a subset of the C programming language, so you can safely assume that a proper C like parser is going to be considerably more complex to implement.


This is doubtlessly a very fun and interesting project to attempt to do, but do you even remotely comprehend what you are trying to do here? Do you have the preseverence to do this for real AND the time to spend for that? A reasonably C like parser will quickly require weeks if not months of development time, even if you don't implement all the different C syntax features.

Rolf Kalbermatter
Averna BV
0 Kudos
Message 2 of 6


It's probably a lot easier to make some sort of interpreter of a simple c-like text if you want the text-based script functionality. But sure, you can interpret text and use scripting to create items on a VI. As mentioned, if you want to make it a true parser it's a pretty big job.

There's examples of how to create items on a block diagram through scripting, that's actually the easy part.

Connecting them to each other and in the right hierarchy is the next hurdle.

There should be plenty of external parsers that can check the validity of the text, i'd use that as a shortcut to know i don't have to handle all syntax checks myself.

And so on.

What have you tried?

G# - Award winning reference based OOP for LV, for free! ADDQ VIPM Now on GitHub
"Only dead fish swim downstream" - "My life for Kudos!" - "Dumb people repeat old mistakes - smart ones create new ones."
0 Kudos
Message 3 of 6

Maybe it'd be worth exploring LabVIEW's Python nodes.   That might make for a more straightforward path forward overall.



-Kevin P

0 Kudos
Message 4 of 6



Thanks for your comments. Unfortunately, I'm using LV 2017 now. 😞

Best Regards,

0 Kudos
Message 5 of 6

Rather than parsing text input and generating/running LabVIEW code, would using a string control to populate a temporary text file and then actually compiling it with a C compiler into a DLL, then calling the DLL with Call Library Function Node be a possible workaround?


Making it 'interactive' might be tricky, since you'll have to have some 'update' function that causes the compilation and then wait, but for simple enough programs it might be possible.

You could consider always wrapping the input in a suitable template, such that the function name and parameters/return type were known and the appropriate declarations were in place, perhaps something like:


#if defined(_MSC_VER)
#define EXPORT __declspec(dllexport)
#elif defined(__GNUC__)
#define EXPORT __attribute__((visibility("default")))

<separate string control for includes here. Maybe a string array and some nice parsing?>

EXPORT char* myFunction() {
    <fill in the text input here, e.g. return "Hello World"; >


GCentralI'm attending the GLA Summit!
Message 6 of 6