fn: exprtk
[contents]

Contents

Syntax

The syntax for exprtk calls is:

f++:  
$`expression`
exprtk{options}(expression)
exprtk{f, options}(file-path)
exprtk{options}
{
	//block of ExprTk code
}

n++:  
$`expression`
@exprtk{options}(expression)
@exprtk{f, options}(file-path)
@exprtk{options}
{
	//block of ExprTk code
}

Description

The exprtk function is for compiling and evaluating ExprTk expressions, it takes zero parameters with the call followed by a block of ExprTk code to compile and evaluate otherwise a single parameter that should be a file-path to ExprTk code to compile and run (you need to specify the option to use a file). See here for more information about ExprTk.

Note: The preceding $ has only been added since v2.3.13, primarily so that functionstein works better as an extension language, in particular with FLASHELL working as a shell extension.

Options

The following options are available for exprtk calls:

option description
f/file param specifies file-path
f++ use f++ if parsing block
n++ use n++ if parsing block
!o do not return output
o return output
pb parse block with language call is made from before compiling and evaluating with ExprTk
!round do not round value of ExprTk expression
option description

f++ example

Examples of exprtk being used with f++:

  1. $`var x:=0; nsm_write(console, x, endl)`
  2. exprtk
  3. {
  4. var x:=0;
  5. nsm_write(console, x, endl);
  6. }
  7. exprtk("./path.exptk")
  8. exprtk.add_package(basicio_package)
  9. exprtk
  10. {
  11. for(var i:=0; i<10; i+=1)
  12. {
  13. println('i: ', i);
  14. }
  15. }
  16. int x = $`2^2 + 3*8 + 4`
  17. console(x)

n++ example

Example of exprtk being used with n++:

  1. $`var x:=0; nsm_write(console, x, endl)`
  2. @exprtk
  3. {
  4. var x:=0;
  5. nsm_write(console, x, endl);
  6. }
  7. @exprtk("./path.exprtk")
  8. @exprtk.add_package(basicio_package)
  9. @exprtk
  10. {
  11. for(var i:=0; i<10; i+=1)
  12. {
  13. println('i: ', i);
  14. }
  15. }
  16. @int(x = $`2^2 + 3*8 + 4`)
  17. @console(x)