Am Sonntag, den 08.02.2015, 21:39 +0100 schrieb Fabien Bodard: > Dim ccol As Collection = ["Nr": 2, "Page_2": 8] > > Print Eval(Eval("\"Page_\" & Nr", ccol), ccol) > > This work for me ... > > My feature request is for use in case like spreadheet, report fields, > but also user small exten script. WIth this abilities they will > be able to interact on the application work in a restricted space. > > 2015-02-08 21:15 GMT+01:00 Charlie Reinl <karl.re...@fen-net.de>: > > Am Sonntag, den 08.02.2015, 14:46 +0100 schrieb Fabien Bodard: > >> oups i missed for the first one : > >> iResult = MyCol[eval("Sum_of_Value_page_" & CStr(Page_Nr), myCol)] > >> > >> 2015-02-08 14:45 GMT+01:00 Fabien Bodard <gambas...@gmail.com>: > >> > ??? > >> > If I summarize what i see I can answer : > >> > > >> > iResult = MyCol[eval(eval("Sum_of_Value_page_" & CStr(Page_Nr), myCol)] > >> > > >> > or simply > >> > > >> > iResult = MyCol["Sum_of_Value_page_" & CStr(MyCol["Page_Nr"])] > >> > > >> > Well if you have a point where you fill myCol so no need to store : > >> > > >> > iResult = MyCol["Sum_of_Value_page_" & iPage] > >> > > >> > > >> > BUT ... I'm not sure it was the goal of your query, so please be more > >> > precise or give an example. :-) > >> > > >> > 2015-02-07 22:41 GMT+01:00 Charlie Reinl <karl.re...@fen-net.de>: > >> >> Am Montag, den 05.01.2015, 22:16 +0100 schrieb Fabien Bodard: > >> >>> 2015-01-05 22:02 GMT+01:00 Benoît Minisini > >> >>> <gam...@users.sourceforge.net>: > >> >>> > Le 05/01/2015 21:46, Fabien Bodard a écrit : > >> >>> >>> What do you mean? > >> >>> >>> > >> >>> >>> -- > >> >>> >>> Benoît Minisini > >> >>> >> > >> >>> >> I think about a tool that will be able to interpret inline formulas > >> >>> >> like in a spreedsheet. > >> >>> >> > >> >>> >> i have done something like that for playing myself but i'm not a > >> >>> >> specialist of interpreters like you. > >> >>> >> > >> >>> >> for example : > >> >>> >> > >> >>> >> =Myvar1 + 3 *(3*myvar2) > >> >>> >> =MYFUNCTION(myvar1; myvar2) + MyVar3 > >> >>> >> > >> >>> >> the function can be initialised for example like > >> >>> >> > >> >>> >> Interpret.Function.Add("MYFunction", nbreArgs, typeRetVal) > >> >>> >> > >> >>> >> And will call Public Sub Interpret_MyFunction(Arg1 as variant, arg2 > >> >>> >> as > >> >>> >> variant,...) as variant > >> >>> >> > >> >>> >> A Special Event will query the vars values : Public Sub > >> >>> >> Interpret_GetVar(sVarName as string) as Variant > >> >>> >> > >> >>> >> All the stuff of the interpreter will be to manage conditionnal > >> >>> >> requirement and calculate values or concatenate strings. So this > >> >>> >> tool > >> >>> >> will be usefull for user level programmation. > >> >>> >> Like in spreadsheet or in reports formulas. It can be extended near > >> >>> >> to > >> >>> >> unlimited. Some functions can be hardcoded like mathematical ones. > >> >>> >> Others are depend of the context so must be implemented for each > >> >>> >> widget or component. It's not the fastest way to make compute but > >> >>> >> the > >> >>> >> most flexible. > >> >>> >> > >> >>> >> I hope my english is not inapprehensible > >> >>> >> > >> >>> > > >> >>> > If I understand well, you need some sort of custom Eval(). > >> >>> > > >> >>> > More precisely, I think what you need is a Gambas hook inside the > >> >>> > reader > >> >>> > part of Eval() (the first part of its internal compiler) where you > >> >>> > tell > >> >>> > how to translate any symbol into a Gambas function or a call to a > >> >>> > method > >> >>> > into one of your classes, everything else being forbidden. > >> >>> > > >> >>> > That way, you keep the Gambas syntax, except that all function names > >> >>> > are > >> >>> > redefined, and every interpreter class is forbidden except the one > >> >>> > you > >> >>> > allow explicitly. > >> >>> > >> >>> Yes it can be the idea. But can it be compatible with 'STANDARD' > >> >>> formulas style too ? were separtors are ';'... > >> >>> > >> >>> But your idea will be a great step too and i think you have understand > >> >>> the back of my mind. > >> >>> > >> >>> > >> >>> > >> >>> > > >> >>> > Just an idea... > >> >>> > > >> >>> > -- > >> >>> > Benoît Minisini > >> >> > >> >> Salut Benoît, > >> >> > >> >> searching something for my problem, I found this mail. What I need is > >> >> something you describe as "Gambas hook inside the reader part of > >> >> Eval()". > >> >> In my Collection passed to eval, I have "Sum_of_Value_page_1" to > >> >> "Sum_of_Value_page_35" and the "Page_Nr". Now for picking the right > >> >> value I need the eval("Sum_of_Value_page_" & CStr(Page_Nr), myCol). > >> >> Done like that, I get "Sum_of_Value_page_1" to "Sum_of_Value_page_35" as > >> >> return. That is nice, but I want the result of that, stored in myCol. > >> >> > >> >> Thought I could resolve that with a public function called by eval > >> >> failed also. > >> >> "Public Function Sum(sFiledName as string) as Variant" isn't cal Salut Fabien,
ok, so we have both the same problem. Because if I code that I do not need two Eval. The string going to Eval comes from outside But, using your example, that could look like that: doit("Eval(\"\"Page_\" & Nr \", ccol)") sub doit(sAM As String) Dim ccol As Collection = ["Nr": 2, "Page_2": 8] Print Eval(sAM, ccol) end 1. the user do not know anything about ccol, and will have to enter the String, which is here set to sAM. And I'm d'accore with you, what you wrote about your feature request. I need that for the same case "user small extended scripts" > led. > >> >> > >> >> So I need that what you call "Gambas hook inside the reader part of > >> >> Eval()".... Or something that works like I know from Clipper, called > >> >> Code-Blocks. Search I-net for "clipper code blocks" > >> >> > >> >> > >> >> > >> >> > >> >> -- > >> >> Amicalement > >> >> Charlie > > > > Salut Fabien, > > > > thanks for your responding, but my problem is not, to get any results > > out of a collection or I can't create the key out of a String + page. > > My problem is that I can't do that with 'Eval' like it is actually. > > To explain, I use eval for my 'computed fields'. Till now no problems > > with. In the Collection, I use with Eval all what I need is stored. > > So when I call Eval("Page_Nr", myCol) , I get a number. With > > Eval("Sum_of_Value_page_2", myCol) I get the value stored behind that > > key. > > But with Eval("Sum_of_Value_page_" & CStr("Page_Nr"), myCol) I get only > > "Sum_of_Value_page_" & CStr("Page_Nr"). I'v tried varies things, > > included evals etc, no way, for that I stepped into your feature > > request. > > -- > > Amicalement > > Charlie > > Salut Fabien, ok, so we have both the same problem. Because if I code that I do not need two Eval. The string going to Eval comes from outside But, using your example, that could look like that: doMyJob("Eval(\"\"Page_\" & Nr \", ccol)") sub doMyJob(sAM As String) Dim ccol As Collection = ["Nr": 2, "Page_2": 8] Print Eval(sAM, ccol) end 1. the user do not know anything about ccol, and will have to enter the String, which is here passed to doMyJob And I'm d'accore with you, what you wrote about your feature request. I need that for the same case "user small extended scripts" Did not find a French "clipper code blocks" version. But have a look at these pages. http://www.itlnet.net/programming/program/Reference/c53g01c/ng418f5.html https://vivaclipper.files.wordpress.com/2012/12/code-block-basics.pdf or google : clipper code blocks Those anonymous methods is what we need. -- Amicalement Charlie ------------------------------------------------------------------------------ Dive into the World of Parallel Programming. The Go Parallel Website, sponsored by Intel and developed in partnership with Slashdot Media, is your hub for all things parallel software development, from weekly thought leadership blogs to news, videos, case studies, tutorials and more. Take a look and join the conversation now. http://goparallel.sourceforge.net/ _______________________________________________ Gambas-user mailing list Gambas-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gambas-user