How To: Get graphical input from within a script [SCRIPT]


This document shows you how to get user input from within a script.


The example below demonstrates how to pause for the interactive entry of some
coordinates (e.g. draw a circle) and then finish the rest of the tasks.

Since all interactive type activity runs from an apply event in a tool, two
scripts are needed. In this example the script called "Master" uses a global
variable called "_counter" to determine what part to run. The script called
"Apply" is attached to the tool and performs a task before calling "Master"

What actually happens is:

1. You set a global variable called _counter and set it to 1.
2. You run the master script - which reads the variable and runs the first half
of the script. Just prior to selecting the tool, set the _counter to 2.
3. After the apply script does what you need done, call the master script
again. This time it will process the second half of the script. (don't forget
to reset the counter!)

'--- set the counter
_counter = 1

'------ Master Script: master.scr

if (_counter = 1) then
'--- Get the list of controls
theGUIlist = av.getProject.getGUIs
'--- Get the GUI
theGUI = theGUIList.Get(0)
'--- Get the selected controlset
theCtrlSet = theGUI.GetToolBar
'--- Get the controls
theControls = theCtrlSet.GetControls
'--- Get the second tool
thetool = theControls.Get(1)
msgbox.info("selecting a tool","")
'--- Activate the control
_counter = 2
msgbox.info("processing the rest... ","")
_counter = 1

'------ End Of Script
'------ Apply Script

msgbox.info("Applied the script","")
'-- Call the master script

'------ End Of Script