Searches of a list and other tricks using [ ] notation and eval() or evalf() for performance

Alan Davey david.a.davey at gmail.com
Wed Jan 4 13:20:59 UTC 2023


Hi Doug,

We found out last year (Studio 10.2), and confirmed by Studio Support, that
evalf() no longer tokenizes a string in a character variable.  Only a
binary variable (with your text string) will get tokenized.  The character
variable will still work, but you will no longer get the speed improvement
unless you switch to using a binary variable.

Alan

On Tue, Jan 3, 2023 at 11:12 AM Doug Easterbrook via omnisdev-en <
omnisdev-en at lists.omnis-dev.com> wrote:

> in addition to what kelly mentions, if you can make a statement, you can
> put that in an eval() and do just about anything.  so the trick has wide
> applicabliltiy
>
> eg
>
> calculate text as ‘list.$sort($ref.Field,1)’
> do eval(text)
>
> or
>
> calculate fieldNameString as ‘Myfield1,Myfield2,MyFleid3’
> calculate text as con(‘max(‘,fieldnamestring,’)’)
> do eval(text)
>
> or
>
> calculate text as con(‘list.$search(',mySearchString,')’)
> do eval(text)
>
> or
>
> calculate fieldNameString as ‘Myfield1,Myfield2,MyFleid3’
> calculate text as con(‘list.$loadcols(‘,fieldnamestring,’)’)
> do eval(text)
>
> it really doesn’t matter how you get omnis to evaluate the command that yo
> build into a text string,  it can be using eval() or proper use of square
> bracket notation
>
>
> one advantage of using eval().   is that you can just as easlily use
> evalf() which tokenizes the text string to speed up oerformance
>
> eg
>
>
> calculate fieldNameString as ‘Myfield1,Myfield2,MyFleid3’
> calculate text as con(‘list.$loadcols(‘,fieldnamestring,’)’)
>
> for list.$line from 1 to list.$linecount
>   do EVALF(text)
>
> end for
>
>
> the EVALF is tokenized the first time in the loop… then it gets much
> faster for second and subsequent uses.    WE’ve done things like this to
> speed up loading certain columns from a list (but not all) when we need to
> do it.
>
>
> anyway..   food for thought.    a very handy use of omnis to make  a
> dynamic statement inline withour writing something to build a procedure
> line.
>
>
>
>
>
> Doug Easterbrook
> Arts Management Systems Ltd.
> mailto:doug at artsman.com
> http://www.artsman.com
> Phone (403) 650-1978
>
> > On Jan 2, 2023, at 10:30 PM, Kelly Burgess <kellyb at montana.com> wrote:
> >
> > Das wrote:
> >> From Kelly I received the thing that really made it work, that is, how
> to square bracket the search.
> >>
> >> Instead of
> >>
> >> myList.$search([mySearchString])
> >>
> >> Use instead
> >>
> >> Calculate myString as con('$Search.',mySearchString)
> >> Do myList.[myString]
> >>
> >> It’s just a twist on how you do the square bracket, but it WORKED and
> that’s what matters.
> >
> > That was slightly misquoted.  The Calculate myString con() is wrong.  It
> should be:
> >
> >  Calculate myString as con('$search(',mySearchString,')')
> >
> > The point is to wrap the search string with $search().  It's the same
> 'trick' that I use to define a list with a user-selected set of columns.  I
> found that
> >
> >  Do list.$define([colString])
> >
> > does not work, but the same approach of wrapping the columns string with
> $define() does work.
> >
> >  Calculate define as con('$define(',colString,')')
> >  Do list.[define]
> >
> > It's just something about the way the Omnis parser works.
> >
> > Kelly
> > _____________________________________________________________
> > Manage your list subscriptions at https://lists.omnis-dev.com
> > Start a new message -> mailto:omnisdev-en at lists.omnis-dev.com
>
> _____________________________________________________________
> Manage your list subscriptions at https://lists.omnis-dev.com
> Start a new message -> mailto:omnisdev-en at lists.omnis-dev.com
>


More information about the omnisdev-en mailing list