fn: exprtk.compile
[contents]

Contents

Syntax

The syntax for exprtk.compile calls is:

f++:  
exprtk.compile{options}(expression)
exprtk.compile{options}
{
	//block of ExprTk code
}
exprtk.compile{options}(name, expression)
exprtk.compile{block, options}(name)
{
	//block of ExprTk code
}

n++:  
@exprtk.compile{options}(expression)
@exprtk.compile{options}
{
	//block of ExprTk code
}
@exprtk.compile{options}(name, expression)
@exprtk.compile{block, options}(name)
{
	//block of ExprTk code
}

Description

The exprtk.compile function is for compiling ExprTk expressions, it takes:

  • zero parameters with the call followed by a block of ExprTk code to compile;
  • a single parameter that should either be the expression to be compiled or for the b/block option a name to assign to the following block of ExprTk code to compile; or
  • two parameters, the first being the name to assign to the second parameter which should be the ExprTk expression to compile.
See here for more information about ExprTk, and see the f/file option on this page.

Note: An expression will need to be recompiled if another variable/symbol with the same name has been in-scope since the expression was compiled. See also exprtk.add_variable.

Options

The following options are available for exprtk.compile calls:

option description
b or block call is followed by a block of ExprTk code
f or file file param instead of expression param, named by path if no name specified
f++ use f++ if parsing block
n++ use n++ if parsing block
pb parse block with language call is made from before compiling with ExprTk
option description

f++ example

Examples of exprtk.compile being used with f++:

int i=0
exprtk.compile(nsm_write(console, 'i: ', i, endl))
for(; i<10; i+=1)
	exprtk.eval

exprtk.add_package(basicio_package)
exprtk.compile(world, println('hello, world!'))
exprtk.compile(mars, println('hello, mars!'))
exprtk.eval(world)

exprtk.add_package(basicio_package)
exprtk.compile{block}(eg)
{
	for(var i:=0; i<10; i+=1)
	{
		println('i: ', i)
	}
}
exprtk.eval(eg)

n++ example

Example of exprtk.compile being used with n++:

@int(i=0)
@exprtk.compile(nsm_write(console, 'i: ', i, endl))
@for(; i<10; i+=1)
	@exprtk.eval

@exprtk.add_package(basicio_package)
@exprtk.compile(world, println('hello, world!'))
@exprtk.compile(mars, println('hello, mars!'))
@exprtk.eval(world)

@exprtk.add_package(basicio_package)
@exprtk.compile{block}(eg)
{
	for(var i:=0; i<10; i+=1)
	{
		println('i: ', i)
	}
}
@exprtk.eval(eg)