I have a script that uses a window with checkboxes, combo boxes, number edit, and text edit boxes to take user input and then uses the input to perform analysis of the data (see the attached picture for what the box looks like). For ease of use with different sets of options I incuded a Reset button which closes all open data tables and reports and clears all entered options. Usually the button works correctly, but sometimes it gives an error when trying to reset either the check box for Individual Date Range or the first text edit box under Enter NC Codes. The error alert says "Send Expects Scriptable Object in access or evaluation of 'Send'". I included a picture of the alert box and the options I selected when the error occurred. The attached script is only the portion in question so it's set up to establish the data entry box then get the inputted options and can reset and close. I'm not sure what's going to with the one checkbox and data entry box as the rest of them seem to reset correctly so any help would be appreciated.


Please note that, any other script or procedure that uses one of those variables or any table that might have a column name like one of those variables even if it were open for just a few seconds can conflict with the display object name.
I will definitely look into namespaces. If the script was being run twice when the error occurs then I think what you're proposing would solve it, but when the reset button is pressed a new entry window is not generated. Only the values of the boxes to take the data are reset to the defaults. That and the fact that the error only occurs sometimes and only with some of the checkboxes leads me to think there might be more going on.
This type of error will occur when the object no longer exists, or there is scoping problem, a name conflict. I expect the sometimes might be caused by this.
I can reproduce this error:
- Run your script , set some values
- Run your script again
- Close the 2nd dialog window
- Go to the first window, and select Reset, the error will occur. This is because all the d1, d2, etc display boxes have been assigned to the 2nd dialog window. Reset is trying to access an object that no longer exists.
Programming with a reference to this << Top parent then finding the object or using the window namescape. window:d1, window:d2, etc. will fix this.
A big benefit of creating an application is that each instance has its own namespace and makes it easier to script.
Another approach is to add to the top of your script Names Default to Here(1); and save it.
Close all instances of your dialog window.
Now run this script (changing the path if needed)
Names Default to Here(1);
Include ("c:\temp\Reset Boxes Question Script.jsl", <<NEW context=""></NEW>Change some values in the first dialog window, then close the 2nd dialog window. Now return to the first window (just repeating the steps that caused the error) and press Reset. No issues.
Using a single Include() with new context creates an anonymous namespace for the diaolog and its named objects, and the scoping probelm is resolved.
You should read about namespaces.