Testing your custom activity
Once you have the activity type (.ini) file, the activity main script and client script (.txt) files setup and have also created the device .custom file containing the device specific code for your custom activity; you simply create a new activity in CatTools, selecting your custom activity from the activity 'Type' drop-down list field, then in the 'Devices' tab you select the device which you created the .custom file for.
Info Log messages
Within the Info Log pane you see messages appear while an activity is running. The level of messages that appear can be filtered by the drop-down list near the bottom of the Info Log window. By selecting level "4. Show Debug events and above
" you get to see all the cl.log messages being displayed during the running of an activity.
All the Info Log messages are logged to a file called InfoLog.txt in the root CatTools folder. This file can get very large very quickly. Purge by selecting the File| Delete | Delete lnfolog.txt file menu item from the CatTools File menu.
The client script function cl.Log
4,"message"
is found throughout device scripts to display level 4 messages which help assist in troubleshooting device specific issues.
The most likely Level 1 - Error
Info Log message encountered when testing your new custom activity script is:
Client script error: Type Mismatch: [activity name] on line: [line number]
This error occurs if:
- the device you have selected to run your custom activity against does not have a .custom file defined for it
- the .custom file for the device does not contain a function which has been defined in your custom activity client script
- a function defined in the .custom file contains an error within the code.
If CatTools finds an associated .custom file for the device, you should see a Level 4 - Debug
Info Log message:
Loading custom activities for device
If you do not see this message for your device, then CatTools was unable to find a .custom
file because:
- The file does not exist.
- The file cannot be opened.
Verify the file permissions.
- A typo error has been made when naming the
.custom
file.
You must have set your Info Log pane to "4. Show Debug events and above
"
If you see the debug message above, then check the contents of the .custom file to ensure:
- The custom activity function exists.
- The custom activity has been spelled correctly.
- The code does not contain errors.
Add additional
cl.log 4, "..."
Info Log debug messages at strategic points in your code to determine where the script is failing.
Device does not support the custom activity
If the selected device does not support the custom activity, either deselect the device in the activity setup Devices tab, or add the following code to the custom activity Function within the .custom file for the device:
Function [YourCustomActivityFunctionName]()
Call cl.CatToolsNoSupport
End Function
Now, when you run this activity, the function is called, but the cl.CatToolsNoSupport internal CatTools function returns a Level 2 - Warning
Info Log message:
Device type: [SCRIPT_NAME constant] has not had this functionality added yet. Skipping this device
Other Info Log message errors
Other errors you may encounter are:
Variable is undefined
Client script error: Variable is undefined: '[variable name]' on line: [line number]
This error occurs if:
- Your code contains a variable which has not been declared. Ensure you Dim or Redim.
- You variables correctly (check for typo errors in your variable declarations).
- Your code contains a call or reference to an internal CatTools variable or function (cl. or ct.), or to a class or type you have defined, but you mistyped 'cl.' or 'ct.' or the class name.
Object doesn't support this property or method
Client script error: Object doesn't support this property or method: '[property or method]' on line: [line number]
This error occurs if:
- You are making a Function call or Sub routine call within the .custom file, but the Function or Sub routine does not exist. (check for typo errors in your code)
Wrong number of arguments or invalid property assignment
Client script error: Wrong number of arguments or invalid property assignment: '[Function or Sub name]' on line: [line number]
This error occurs if:
- You are making a Function call or Sub routine call within the .custom file, but have supplied an incorrect number of arguments to the Function or Sub routine.
Debug log
Under the File menu of CatTools there is an entry Enable Capture Mode. This turns on the logging of the conversation between CatTools and the end device and creates a disk file in the \Debug
sub folder of the communications.
This can be extremely useful when the script does not appear to be communicating correctly with the device after making its initial connection. The scripting mechanism waits for known prompts and issues commands to the device at these points. It eventually times out if an expected prompt fails to appear.
The debug log capture file shows what the device is actually sending to CatTools, so you can adjust your code accordingly.