Is it possible to pass in a parameter into runScript() function?

I have created a script where I have defined the method for converting a string into date. Now, I want to use this script in an expression binding for a label using "runScript()" function. I want to pass the text of this particular label into this runScript as an input, but I am getting an "Error_ExpressionEval" error. Attached below is the screenshot. Can anyone help in solving this?

Hover over the error?

Hi, thanks for the reply. If I hover over the error, I am not getting any error message

Look at your gateway log to see if anything shows there. If not, consider adding a try: -- except: block in your called function to capture and log any errors in the script itself.

It might be too late now, but I'd also suggest to have a look at the Python naming conventions PEP 8 – Style Guide for Python Code | peps.python.org
Generally:

  • classes use PascalCase
  • functions, variables, and library names use snake_case
  • constants defined at the top of script libraries should use ALL_CAPS (and should never be modified from their init value)

jython is so dominated by the JVM it sits in that I prefer java's camelCase for functions, methods, variables, and libraries.

1 Like

Wouldn't this create an infinite loop since you're passing the text value of this binding into itself as a parameter of your runScript? Are you intending to use a different value from some other component to pass into your script instead?

3 Likes

@Visveswaran_Dharmara the answer to your question is yes you can pass in parameters

as a test, I made this quick function:

image

Then in a perspective view custom property binding I did this:

image

I would suggest you look at your actual function definition and make sure the issue is not there.

RE: style

I'm in full agreement with @pturmel there is so much in Ignition that is built on java that you cannot control so camelCase is the way to go to avoid having a messy mix.

Cheers,

Nick