<SERVER>
// This example shows how to create a LassoSession, set it up for a search, then print out the results.
// This example uses the Employees.fp3 FileMaker Pro database which ships with Lasso.
// write out the HTML opening
write( '<HTML><HEAD><TITLE>JavaScript Example 1</TITLE></HEAD><BODY BGCOLOR="#FFFFFF">' );
// send it to the user
flush();
var mySession = new LassoSession();
// get the InputParameters object for easy reference
var myInput = mySession.getInputParameters();
// set the database and layout (table) we will use
myInput.databaseName = "Employees.fp3";
myInput.tableName = "Detail";
// set the action we want
myInput.action = "search";
// set the logical op to OR
myInput.logicalOperator = "OR";
// let's find all the engineers
myInput.searchColumns.push( new SearchColumn( "Group", "Engineering", lasso.opEquals ) );
// we'll also include those in operations
myInput.searchColumns.push( new SearchColumn( "Group", "Operations", lasso.opEquals ) );
write( myInput.toSource() );
// execute the session
mySession.execute();
// check the result code
if ( mySession.getResultCode() == 0 ) // no error
{
// get the result set
var mySet = mySession.getResultSet();
// print out the column names
write( "<table><tr>" );
var numCols = mySet.columns();
for ( var count = 0; count < numCols; ++count )
{
write( "<th>", mySet.columnName( count ), "</th>" );
}
write( "</tr>" );
// write out the result data
while ( mySet.next() )
{
write( "<tr>" );
for ( var count = 0; count < numCols; ++count )
{
write( "<td>", mySet[ mySet.columnName( count ) ], "</td>" );
}
write( "</tr>" );
}
write( "</table>" );
}
else // an error occured, tell the client
{
write( "An error occurred: ", mySession.getResultCode(), "; ", mySession.getResultMessage() );
}
// write out the HTML closing
write( '</BODY></HTML>' );
</SERVER>
[Next Example]