Forms are interfaces (windows, including dialogs) that you design by adding controls to a form and writing the script code to handle events associated with each control.
Generally, scripts run and then exit immediately. They do not wait for events, unless you specifically program an event “handler” into them. If you want a particular subroutine to run in response to an event, you must include the appropriate script code as part of a form, or provide the appropriate code within your script.