Hi Roger
You're absolutely correct that making use of objects and functions is a great way to reuse code around your panel and keep things better organized.
You have also correctly identified the issue with creating them inside of a parameter's task. The scope is limited to that parameter (consider variables and functions declared here to be inside of a private function).
The <api/> tag is intended as a place for you to put all of your global variables and functions. If you put an <api/> tag near the top-level of your custom panel (they also follow a hierarchy), you will be able to see all of your objects and functions inside of your other <ogscript/> blocks and parameter/button tasks. One trick that can sometimes be helpful with using these is to check the "execute immediately" box to have its ogScript evaluated as soon as the processor hits that tag instead of waiting until the rest of the panel is loaded.
Another option you have available to access things outside of scope in a parameter or button task is to use ogscript.putObject(KEY, VALUE) and ogscript.getObject(KEY) to pass things around. This map is scoped at the panel-level as opposed to the task level.
Hope this helps you get going.
Cheers
James
#DashBoard