radiogroup.sml

  Download

More scripts: Dialog

Syntax Highlighing:

comments, key words, predefined symbols, class members & methods, functions & classes
            
# radiogroup.sml
# creates sample dialog with radiogroup of three buttons
# using an XML dialog specification.  The radiogroup value
# is printed to the console as an example of how to get
# control settings from the dialog.
# Declarations
string xml$;
numeric err, ret;
clear();
# XML string containing the dialog specification
xml$='<?xml version="1.0"?>
	<root>
		<dialog id="select" title="Select Process" OnOK="OnOK()">
			<groupbox Name=" Process: " ExtraBorder="4">
				<radiogroup id="processgp" Default="entire">
					<item Value="entire" Name="Entire Scene"/>
					<item Value="polygon" Name="AOI Polygon"/>
					<item Value="manual" Name="Manual Selection"/>
				</radiogroup>
			</groupbox>
		</dialog>
	</root>';
### parse XML text into memory; returns an error code (number < 0 ) if there are syntax errors
class XMLDOC dlgdoc;
err = dlgdoc.Parse(xml$);
if (err < 0) {
	PopupError(err); # Popup an error dialog. "Details" button shows syntax errors.
	Exit();
	}
# get the dialog element from the parsed XML document and
# show error message if the dialog element can't be found
class XMLNODE dlgnode;
dlgnode = dlgdoc.GetElementByID("select");
if (dlgnode == 0) {
	PopupMessage("Could not find dialog node in XML document");
	Exit();
	}
# Set the XML dialog element as the source for the GUI_DLG class instance
# we are using for the dialog window.
class GUI_DLG dlgwin;
dlgwin.SetXMLNode(dlgnode);
ret = dlgwin.DoModal();
proc OnOK () {
	class GUI_FORM_RADIOGROUP radio;
	local string value$;
	radio = dlgwin.GetCtrlByID("processgp");
	value$ = radio.GetSelected();
	if ( value$ == "entire" ) then PopupMessage("You selected 'Entire Scene'");
	else if ( value$ == "polygon" ) then PopupMessage("You selected 'AOI Polygon'");
	else if ( value$ == "manual" ) then PopupMessage("You selected 'Manual Selection'");
	printf("\nRadio Value = %s", value$);
	}