User definable function

We are trying to build a self-serve tool for form-building.
We are starting with the Forms project from the Exchange.
We want the person who is the form-designer to be able to create a list of questions, and then for each question, pick from a variety of ways of giving answers (pick from a drop-down, pick a radio-button, multi-check checkboxes, attach a picture of damage, etc.)

The Forms project in the Exchange is a great start.

However, one of the things we keep getting asked for is "allow me to add a custom formula". For example, they might want to show how many "No" answers there were.

In commercial toolkits, there is often a "code-behind scripting language" that the users can use to type their "code lines" into the text box, and specify the return the value to be displayed on the form. Like "% questions completed", "% questions that are Y", etc.

I don't think there's anything like that in Ignition, where someone types in python into a text box, and then, when the app gets to that spot where it is expected to show the results of the custom formula, executes the python code and displays the returned value.

Is there?

There is something like that possible with both Python and also the Expression language (although that’s potentially a bit more complex).

I’m not at my computer at the moment so can’t provide any workable example, but it is possible.

One-liners with python's eval() are fairly straightforward--you simply have to supply a dictionary with the predetermined variables you with the expression to be able to access. (You have to be careful to avoid exposing exploitable variables.)

Thanks for the nudge ... I looked at putting complicated functions in the textbox, running that through exec to create the function ... and then using eval ... I think we will then agree, internally, to always pass in the "questions/responses" dictionary for processing by the function ... and that'll give us the flexibility we are looking for.