/* Do block, ignore result, and show any error in QMessageBox. */ void boron_doBlockQt( UThread* ut, const UCell* blkC ) { if( ! boron_doVoid( ut, blkC ) ) { UCell* ex = boron_exception( ut ); if( ur_is(ex, UT_ERROR) ) { QString msg; cellToQString( ex, msg ); QMessageBox::warning( 0, "Script Error", msg, QMessageBox::Ok, QMessageBox::NoButton ); ur_blkPop( ur_errorBlock(ut) ); //boron_reset( ut ); } else if( ur_is(ex, UT_WORD) ) { if( ur_atom(ex) == UR_ATOM_QUIT ) qApp->quit(); } } }
int main( int argc, char** argv ) { UThread* ut; char cmd[ 2048 ]; double result; (void) argc; (void) argv; printf( "Urlan Calculator Example %s (%s)\n", UR_VERSION_STR, __DATE__ ); ut = ur_makeEnv( 256, 0, 0, 0, 0 ); if( ! ut ) { printf( "ur_makeEnv failed\n" ); return 255; } defineWords( ut ); while( 1 ) { printf( ")> " ); fflush( stdout ); /* Required on Windows. */ fgets( cmd, sizeof(cmd), stdin ); if( cmd[0] < ' ' ) { printf( "\n" ); } else if( cmd[0] == 'q' ) { break; } else { if( calc_evalCStr( ut, cmd, &result ) ) { printf( "= %f\n", result ); } else { UBuffer* blk = ur_errorBlock(ut); if( blk->used ) { UBuffer str; ur_strInit( &str, UR_ENC_UTF8, 0 ); ur_toStr( ut, blk->ptr.cell, &str, 0 ); ur_strTermNull( &str ); printf( "%s\n", str.ptr.c ); ur_strFree( &str ); blk->used = 0; } else break; } } } ur_freeEnv( ut ); return 0; }