| Multiple Context Demo Sample Code
void ContextDemo( void )
{
char theExpression[ 128 ];
long expLength;
bool keepLooping = true;
bool useFirstContext = true;
// Make way...
lzClearContext();
// Set up the first context...
lzSetAllowImpliedMult( false );
lzSetOutputBase( kBase10 );
lzCreatePrivateContext( "FirstContext" );
// Make way...
lzClearContext();
// Set up the second context...
lzSetAllowImpliedMult( true );
lzSetOutputBase( kBase16 );
lzCreatePrivateContext( "SecondContext" );
while ( keepLooping )
{
if ( useFirstContext )
{
lzSetContext( "FirstContext", false );
useFirstContext = false;
}
else
{
lzSetContext( "SecondContext", false );
useFirstContext = true;
}
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();
}
}
lzDestroyPrivateContext( "FirstContext" );
lzDestroyPrivateContext( "SecondContext" );
}
|