I’ve created a button, added an onClick event, added a Script action. The action body is just system.gui.messageBox(“foo”). In my client, clicking the button does nothing. I’ve also tried with onChange and onMouseDown. I’ve also tried just having the script add 1 to a numeric field.
Ignition 8.0.0-beta0 (b2018120302), Chrome and also iOS 11.3/iPhone 7.
While scripting in Perspective or Vision, if you use the Ctrl-Space shortcut to view available functions, you’ll be able to see what is available in your current context. Since you are in Perspective, then system.gui.* is not available. If you were encountering this in Vision, then we would sound an alarm.
As has been explained to me, if you examine the documentation and look into individual functions, if the “Scope” is declared as “Gateway”, then it can be used in Perspective OR Vision. If the “Scope” is “Client”, then it can only be used in Vision.
We actually recently changed the manual to hopefully be a little more clear. Each function now lists where it can be used out of the Gateway, a Vision Client, or a Perspective Session.
Also keep in mind that shared and project script modules can be called from all of these scopes, and therefore (are supposed to) show all script functions. Some functions won’t be present based on the caller’s scope.
In restrospect, it makes some sense that messageBox() might not be available in Perspective. And I got my other test script working after realizing I was trying to use props.text when I should have been using props.value. I also just noticed that a Perspective script that his an error like this puts an error in the log on the gateway, which is nice.
It would be nice if a message would display in the Designer if a script does not compile, as currently happens in 7.x.
I don’t get any response to Ctl-space in Perspective event or script windows. So is there a list of Perspective script functions available? I did not see that in the manual. Thanks…
You can find any of the functions in the reference section at the end. Remember that both the software and manual are still in beta, so things may be missing and/or incomplete. I know there are more perspective functions that we haven’t had a chance to add.
To be honest, I was just trying to get some kind of feedback from Perspective action scripts on what info it was returning. In Vision I might have thrown a system.gui.messageBox(str(returnthing)), or did a print to console. How do I get even this basic function in Perspective?
Even I am facing the same problem with the onclick event configuration.
The script perfectly works fine when applied on a Button component but not for a Numeric Filed.