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


ARRAY.sml


# ARRAY.SML
#
# Sample script for tuturial "Writing Scripts with SML" 
# Use of arrays, matrices, and stringlists.

clear();

### Declare a one-dimensional array with 5 items.
array numeric testarray[5];
numeric i;
numeric x = 100;

### Loop through array to set values and print to console.
### NOTE: Array indices begin with 1.
print( "Array Status:" );
for i = 1 to 5 {
	testarray[i] = x;
	x += 100;
	printf( "Array index %d = %d\n", i, testarray[i] );
	}

### Create a matrix with 1 row and 5 columns.
class MATRIX testmatrix;
testmatrix = CreateMatrix( 1, 5 );

### Loop through row 1, set column value, then get value to print to console.
### NOTE: Matrix row/column indices begin with 0.
printf( "\nMatrix Row 0 Status:\n");
for i = 0 to 4 {
	SetMatrixItem( testmatrix, 0, i, testarray[i + 1] ); 
	printf( "Column %d= %d\n", i, GetMatrixItem( testmatrix, 0, i ) );
	}

### Declare a STRINGLIST 
class STRINGLIST stringlist;
string str1$, str2$, str3$;

str1$ = "ten";
str2$ = "twenty";
str3$ = "thirty"; 

### Add strings to end of stringlist.  You can also add
### strings to the front of the list.
stringlist.AddToEnd(str1$);
stringlist.AddToEnd(str2$);
stringlist.AddToEnd(str3$);

printf( "\nStringlist Status:\n" );
printf( "Number of items = %d\n", stringlist.GetNumItems() );

### Loop through stringlist and use GetString() method to
### get string values and print to console.
### NOTE: stringlist indices begin with 0.

for i = 0 to 2 {
	printf( "Index %d = %s\n", i, stringlist.GetString( i ) );
	}

### You can also use array subscripts on a STRINGLIST.
### Repeat above loop using array subscripts:

printf( "\nStringlist Status Again:\n" );

for i = 0 to 2 {
	printf( "Index %d = %s\n", i, stringlist[i] );
	}


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