| Select-Case Demo Sample Code
void SelectDemo( void )
{
char theExpression[ 128 ];
char szDemoFile[ 128 ];
long expLength;
bool keepLooping = true;
long lDefineOpResult = 0;
lzCreatePublicContext( "SelectContext" );
lzSetContext( "SelectContext", false );
sprintf( szDemoFile, "%s%s", TEST_FILE_PATH_PREFIX, "select.lzo" );
lDefineOpResult = lzReadExpOp( kGlobalScope,
"stepfunc",
"prefix",
"number",
"number x",
"sin",
szDemoFile );
if ( lDefineOpResult )
{
cout << "Failed to load STEPFUNC operator.\r\n";
cout << lzGetLastErrorText() << "\r\n\n";
}
while ( keepLooping )
{
GetInputString( theExpression, 128 );
expLength = strlen( theExpression );
if ( expLength == 0 )
keepLooping = false;
else if ( (expLength == 1) && (theExpression[ 0 ] == '\r') )
keepLooping = false;
else if (theExpression[ 0 ] == '\\')
keepLooping = false;
else
{
cout << " " << lzEvalExpStrToStr( theExpression ) << '\n';
if ( lzGetLastErrorID() )
cout << lzGetLastErrorText() << '\n';
cout.flush();
}
}
lzDestroyPublicContext( "SelectContext" );
}
|