- Notifications
You must be signed in to change notification settings - Fork 0
Getting started
amomra edited this page Apr 20, 2015
·
2 revisions
The first thing to do is to download and install the muParserNET library into your project. This can be done through NuGet by right-clicking the project and selecting the option "Manage NuGet Packages..." in Visual Studion 2013.
Using muParserNET is pretty straightforward as you can see in the following example. The sample defines a parser variables ("a") and adds a user defined functions named "MyFunc". When using the parser make sure that you don't forget to catch possible exceptions of type ParserError.
usingmuParserNET;publicclassExample{// Function callbackpublicstaticdoubleMySqr(doubleval){returnval*val;}publicstaticvoidMain(String[]args){try{Parserp=newParser();ParserVariablea=p.DefineVar("a",1);p.DefineFun("MySqr",MySqr,true);p.Expr="MySqr(a)*_pi+min(10,a)";for(inti=0;i<100;++i){a.Value=i;// Change value of variable aConsole.WriteLine(p.Eval());}}catch(ParserErrore){Console.WriteLine(e.Message);}}}- Getting started
- Setting and evaluating an expression
- Setting the expression
- Single return expression evaluation
- Multiple return expression evaluation
- Bulk mode evaluations
- Error handling
- Defining identifier charsets
- Defining parser variables
- Explicitely defining variables
- Implicit creation of new variables
- Querying parser variables
- Removing variables
- Defining constants
- Defining parser constants
- Querying parser constants
- Removing constants
- Setting custom value recognition callbacks
- Defining functions
- Defining parser functions
- Bulk mode functions
- Defining parser operators
- Unary operators
- Binary operators
- Disable built-in operators
- Localization