home products news downloads documentation support gallery online maps resellers search
TNTmips Downloads Menu

HOME

CONTACT US

CURRENT RELEASE
  TNT 2013

DEVELOPMENT VERSION
  TNT 2014

TNTmips Pro
PRIOR RELEASES
  TNT 2012

FREE SOFTWARE
  TNTmips Free
  TNTatlas
  TNTsdk

MORE DOWNLOADS
  HASP Key Driver
  Screen Recorder
  TNT Language Kits
  Sample Geodata
  TNT Scripts

DOCUMENTATION
  TNTmips Tutorials
  Tutorial Datasets
  Technical Guides
  Scripts
  Quick Guides

MORE INFO
  Download FAQs
  FTP
  Download Managers
  Find Reseller

SITE MAP


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!");
	}


Back Home ©MicroImages, Inc. 2013 Published in the United States of America
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

25 March 2009

page update: 26 May 11