Transistor

How do we debug scripts in CX-Supervisor Developer?

4 posts in this topic

I'm modifying an existing application and need to expand some recipe arrays. Runtime is throwing an error on the last element of the original array (elements 0 to 137 and I have expanded to 199).

Is there any way to add a breakpoint into the code to see what's happening?
How does anyone else do it?

Many thanks.

Share this post


Link to post
Share on other sites

Hi,

No, VBScript does not have any debugger or step mode. The only method is old skool debug techniques:

- Use MsgBox to confirm variable values, and confirm execution and branch points

- Where performance is an issue or too many pop ups, use LogEvent to record messages in order into Error log

- You can also use the data logging or Audit trail to follow point values

Hope that helps,

BB

Share this post


Link to post
Share on other sites

Thanks for that. I was coming to the same conclusion.

Two problems:

  1. 1. Most of the scripting is done in CX rather than VB. How do I use MsgBox in CX? It seems to be a VB control. `@VBSCRIPT`?
  2. I can use LogEvent to output a string but I haven't figured out how to include a variable. (Again, this is CX scripting.)
FOR i = 0 TO 9
	LogEvent( Recipe[i] )                         'Works.
	LogEvent( i & Recipe[i] )                     'Doesn't work.
	LogEvent( ValueToText(i) & Recipe[i] )        'Doesn't work.
NEXT

I'm a bit unclear as to which functions can be used in CX-Supervisor Script.

Any ideas?

Share this post


Link to post
Share on other sites

Hi,

All functions can be used in both VBScript and CX-Supervisor script, but note these differences:

  1. VBScript ALSO supports hundreds of standard VBScript methods with examples on the web
  2. VBScript is generally loosely typed, so performs automatic conversion, whereas CX-Supervisor Script is strongly typed, so needs explicit type conversion
  3. In CX-Supervisor script most commands are NOT implemented as Functions. Check the "Functions" menu and you see only Sin, Cos etc. This means the rest are NOT functions and cannot be used 'inline' so that the return value is also the input parameter of another command.

For these reasons, my preference is ALWAYS for VBScript so I never select "CX-Supervisor Script" option.

More specifically, you are failing because of (3) above.  ValueToText can be used in CX-Supervisor Script but not 'inline' as a Function. To use it you would have to do something like following:

FOR i = 0 TO 9
	txtValue = ValueToText(i)
	txtMessage = txtValue + ": " + Recipe[i]
	LogEvent( txtMessage )
NEXT

So VBScript should work, but this should do what you want. Hope that helps,

Regards,

BB

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now