Custom Instrument Code - Hooking the Script up to the Instrument
Writing script event handling procedures and functions is literally 'half the battle'. You could have the most elegant and functionally smart code there is, and it will still remain dormant unless it is correctly linked, or hooked-up, to the relevant components and controls defined for the instrument's customized GUI.
Having read through the previous sections of this document, you will be aware that each component/control has a number of events associated with it. These are the events which the component/control can 'react' to. The script code that gets used when an event is 'fired' is that event's handling code. The parent procedure or function written in the script is therefore the 'event handler'. The logical place then, to link event to event handler, is the value of the event – defined on the Events panel, when the Design tab of the Custom Instrument Configuration dialog is active.
There are two ways by which the event handling code can be linked to an event of a component/control, depending on your preferred method of working:
- Write the event handling procedure or function first then, for the component/control in question, assign it to the desired event by clicking in the value field for that event and choosing the name of the procedure or function from the drop-down list of all currently written procedures and functions.
- For the component/control in question, identify the event on which you wish something to happen, then simply double-click inside the value field for that event. The Code tab of the dialog will be made active, and a shell event handling procedure added, ready for you to define the required functionality. The name of the procedure is automatically entered as the value for the event.