In fact internally it use two process. the first one when you set the formula. It compile it... understand reorganize and traduce the formula into interpreter readable sequences. The second one when you call Execute, the interpreter read the stored sequence. During this process if some variables are used the interpreter raise the data event and give the required var name. So you can give it throuth the .data property.
Internally the interpreter have bridges to every math and string common functions of Gambas. You can extent the functions by inheriting the simpleEval and adding your own function. example : Export Inherits SimpleEval Public Sub _New() SimpleEval.Functions.Add("Message") SimpleEval.FunctionsArgsCount.Add(1) End ''Show a windowed message Public Sub _MESSAGE(Val1 As CResult) As CResult Message(Val1.Value) Return New CResult(Null, CResult.TypeValue) End Void not exist, you must return a null result on a void function. Simple eval does what i need... a simple extendable formula interpreter like the one we can se on spreadsheet. I use it now on report too. So i can say now "='Page ' & page & ' on ' & pages" I forgot " and ' are accepted for string delemiter 2015-12-30 7:21 GMT+01:00 Fabien Bodard <gambas...@gmail.com>: > you can get the error and the error pos too, > > i've updated the class on the farm to remove the compilation warnings > > 2015-12-30 7:21 GMT+01:00 Fabien Bodard <gambas...@gmail.com>: >> From the Main Module in the Farm example : >> >> >> Public Sub Main() >> Dim hEval As New SimpleEval As "Eval" >> Dim hEx As New EvalEx As "Eval" >> >> 'Test with an unknown variable >> hEval.Formula = "IF(Test=1;'TROUVE';'PERDU')" >> hEval.Execute >> If Not hEval.Error Then >> Print hEval.Value >> Else >> Print hEval.ErrorText >> Endif >> >> >> 'Test extention >> hEx.Formula = "Message('coucou')" >> hEx.Execute >> >> 'Test Both >> hEx.Formula = "Message(If(Test=1;'TROUVE ' & prenom;'PERDU'))" >> hEx.Execute >> >> 'Test Calculation >> hEx.Formula = "Cos(1)+pi()*2^mypower" >> hEx.Execute >> Print hEx.Value >> >> End >> >> >> Public Sub Eval_Data(Value As String) >> >> If Value = "Test" Then >> Last.data = 1 >> Endif >> If Value = "mypower" Then >> Last.data = 3 >> Endif >> If Value = "prenom" Then Last.Data = "Fabien" >> >> >> End >> >> 2015-12-30 7:10 GMT+01:00 Fabien Bodard <gambas...@gmail.com>: >>> You get the class from where ? >>> >>> >>> 2015-12-29 15:18 GMT+01:00 Charlie <char...@cogier.com>: >>>> Hi Fabian, >>>> I presume that you wrote the code in SimpleEval. I can't work out how to >>>> use >>>> it. I thought it might work with my gbCalculator (see Gmabas Farm). There >>>> are quite a few compile warning errors. >>>> <http://gambas.8142.n7.nabble.com/file/n55114/CompileErrors.png> >>>> *The main thing is some examples on how to use it please.* >>>> Thanks. >>>> >>>> >>>> >>>> -- >>>> View this message in context: >>>> http://gambas.8142.n7.nabble.com/SimpleEval-tp55114.html >>>> Sent from the gambas-user mailing list archive at Nabble.com. >>>> ------------------------------------------------------------------------------ >>>> _______________________________________________ >>>> Gambas-user mailing list >>>> Gambas-user@lists.sourceforge.net >>>> https://lists.sourceforge.net/lists/listinfo/gambas-user >>> >>> >>> >>> -- >>> Fabien Bodard >> >> >> >> -- >> Fabien Bodard > > > > -- > Fabien Bodard -- Fabien Bodard ------------------------------------------------------------------------------ _______________________________________________ Gambas-user mailing list Gambas-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gambas-user