Download KoalaTerm Help

Transcript
4. MakeLower () (Available since version 3.15)
This method returns the string with all letters in lower case.
5. Find ( <substring>, <start position> ) (Available since version 3.15)
This method finds the "substring" in the string from the "start position"
(counting from zero for the first byte) and returns the first appearing position.
If not found, -1 is returned. The "start position" can be omitted, default is
zero.
KoalaScript Sample
The following example shows a file logging procedure.
The host first sends file header record starting with a tag, then unlimited
number of records in file, at last it transmits a file trailer record starting with
another tag, following the trailer tag there are fixed number (40) of characters
in the trailer record.
// First, we need a wait callback function to do the file logging
// during waiting for the trailer record tag
function OnRecv( char )
{
// write every character in file
file.Write( char );
}
// Start of script
// Wait for the file header tag first
str = term.Wait ( "[HEADER ]", 30 );
// Check if we actually get the header tag in 30 seconds or not
if ( str == "" ) {
sys.MessageBox ( "Cannot detect the file header." );
return;
}
// Open the file for writing
file = sys.OpenFile ( "MyLog.txt", "w" );
// Write the header tag into file since it’s also a part of the file
file.Write ( str );
// Wait for the file trailer tag, and log every character into file
term.Wait ( "[TRAILER]", 0, OnRecv );
// Finally, get fixed number of characters in the trailer record
88