KRASCHE
&
BYRNE
         ELZED  HOME       NEWS       DOCS       DOWNLOADS       LICENSING       SUPPORT       FAQ       ABOUT  US

What's An Elzed?
Features
Licensing
Downloads
Documentation
Elzed News
    ELZED 
 Documentation 
 Examples 
 Sample Code 

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" );
}


  Copyright  ©  MMXXV  by  R R Le Cropane   •   All Rights Reserved   •   Terms of Use   •   Privacy Policy