| home products news downloads documentation support gallery online maps resellers search | ||
|
bonjour1.sml### bonjour1.sml
### Sample script for "Building Dialogs in SML"
### Illustrates the use of callbacks for dialog controls.
### Global variable declarations
numeric errXML, dlgreturn;
string xmlfile$;
# clear the console window
clear();
### create string with path and filename of XML file with the
### dialog specification (assumed to be in same directory as this script)
xmlfile$ = _context.ScriptDir + "/bonjour1.xml";
### read and parse XML file; returns an error code (number < 0 ) if there are syntax errors
class XMLDOC doc;
errXML = doc.Read(xmlfile$);
if (errXML < 0) {
PopupError(errXML); # Popup an error dialog. "Details" button shows syntax errors.
Exit();
}
### declare class instance for the dialog element in the XML structure
### and get the dialog handle from the XML structure.
### Pop up an error dialog and exit if the dialog ID can't be found in the XML.
class XMLNODE dlgnode;
dlgnode = doc.GetElementByID("hello");
if (dlgnode == 0) {
PopupMessage("Could not find dialog node in XML document");
Exit();
}
### declare class instance for the dialog window and set the XML structure
### in memory as the source for the dialog.
class GUI_DLG dlg;
dlg.SetXMLNode(dlgnode);
### open as a modal dialog; the DoModal() method doesn't return until the dialog is
### closed; it returns -1 if the user presses [Cancel], or 0 if the user presses [OK].
dlgreturn = dlg.DoModal();
if (dlgreturn == -1) { # exit script when Cancel button on dialog is pressed
Exit();
}
####### Callback procedure ########
proc SayHello () {
clear();
local string language$;
language$ = dlg.GetCtrlValueStr("listbox");
if ( language$ == "English" ) then
print("Hello!");
else if ( language$ == "French" ) then
print("Bonjour!");
else if ( language$ == "German" ) then
print("Hallo!");
else if ( language$ == "Spanish") then
print("Hola!");
}
11th Floor - Sharp Tower, 206 South 13th Street, Lincoln NE 68508-2010 USA Business & Sales: (402)477-9554 Support: (402)477-9562 Fax: (402)477-9559 Business info@microimages.com Support support@microimages.com Web webmaster@microimages.com | |