Jump to content

Using Python as a "dynamic" formula node


Recommended Posts

A post on NI's forum asked:

QUOTE

I want to put a formula node on the front panel of a LabVIEW execution file, so that user can type their own code in the formula node and get their own output. I tried this but it seems only feasible before I build the source code to an execution file.

Is there anyone can help me? I appreciate your help.

I posted a solution using the OpenG Python tools (a few solutions, actually, as I kept playing) but I wonder how I can improve what I finally came up with. I use a Case structure in a For loop to get the data from the Python session, but I've had to put a case for each data type. Is there a way to get this dynamically?

Thanks,

Jim

post-7534-1239112284.jpg?width=400

Download File:post-7534-1239112361.vi

Link to comment

QUOTE (jcarmody @ Apr 7 2009, 09:54 AM)

How would you want to do that? LabVIEW is strongly typed and the only way to do what you want to do is using variants, but the internal C interface to them is not documented anywhere (though I have to admit I never inquired if it could be gotten in some semi official way anyhow such as what we got for the old scripting API that is also used in the script node interface of LabPython).

But even using variants you usually have to convert the data back to some datatype in the end although you could of course go for strings if it is only about displaying them.

If you only want to convert to strings I believe you should be able to do so already since the used Python API should actually be able to return string format for all its datatypes but it's a long time ago that I have played with this and it could be that there is somewhere a problem that makes this fail.

Rolf Kalbermatter

Link to comment

Join the conversation

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

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
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.

×
×
  • Create New...

Important Information

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