But it just returns one result for 2 variables O_o which var is it then?utopiomania wrote:Daniel, it handles any number of variables up to #MAXVARS, and you can use long variable
names if you like.
Expression evaluator
-
- Addict
- Posts: 2344
- Joined: Mon Jun 02, 2003 9:16 am
- Location: Germany
- Contact:
- utopiomania
- Addict
- Posts: 1655
- Joined: Tue May 10, 2005 10:00 pm
- Location: Norway
Very cool. maybe this could be used for this?,
in an ADO recordset there is a filter property that accepts an expression, but the syntax is limited, from the docs:
so the function would take a complex expression like the first one and translate it to the second one, handling all nesting levels. How difficult would be?
Here's the complete description for the filter property,
in an ADO recordset there is a filter property that accepts an expression, but the syntax is limited, from the docs:
Code: Select all
There is no precedence between AND and OR. Clauses can be grouped within parentheses. However, you cannot group clauses joined by an OR and then join the group to another clause with an AND, like this:
(LastName = 'Smith' OR LastName = 'Jones') AND FirstName = 'John'
Instead, you would construct this filter as
(LastName = 'Smith' AND FirstName = 'John') OR (LastName = 'Jones' AND FirstName = 'John')
Here's the complete description for the filter property,
Code: Select all
Use the Filter property to selectively screen out records in a Recordset object. The filtered Recordset becomes the current cursor. Other properties that return values based on the current cursor are affected, such as AbsolutePosition, AbsolutePage, RecordCount, and PageCount. This is because setting the Filter property to a specific value will move the current record to the first record that satisfies the new value.
The criteria string is made up of clauses in the form FieldName-Operator-Value (for example, "LastName = 'Smith'"). You can create compound clauses by concatenating individual clauses with AND (for example, "LastName = 'Smith' AND FirstName = 'John'") or OR (for example, "LastName = 'Smith' OR LastName = 'Jones'"). Use the following guidelines for criteria strings:
FieldName must be a valid field name from the Recordset. If the field name contains spaces, you must enclose the name in square brackets.
Operator must be one of the following: <, >, <=, >=, <>, =, or LIKE.
Value is the value with which you will compare the field values (for example, 'Smith', #8/24/95#, 12.345, or $50.00). Use single quotes with strings and pound signs (#) with dates. For numbers, you can use decimal points, dollar signs, and scientific notation. If Operator is LIKE, Value can use wildcards. Only the asterisk (*) and percent sign (%) wild cards are allowed, and they must be the last character in the string. Value cannot be null.
Note To include single quotation marks (') in the filter Value, use two single quotation marks to represent one. For example, to filter on O'Malley, the criteria string should be "col1 = 'O''Malley'". To include single quotation marks at both the beginning and the end of the filter value, enclose the string with pound signs (#). For example, to filter on '1', the criteria string should be "col1 = #'1'#".
There is no precedence between AND and OR. Clauses can be grouped within parentheses. However, you cannot group clauses joined by an OR and then join the group to another clause with an AND, like this:
(LastName = 'Smith' OR LastName = 'Jones') AND FirstName = 'John'
Instead, you would construct this filter as
(LastName = 'Smith' AND FirstName = 'John') OR (LastName = 'Jones' AND FirstName = 'John')
In a LIKE clause, you can use a wildcard at the beginning and end of the pattern (for example, LastName Like '*mit*'), or only at the end of the pattern (for example, LastName Like 'Smit*').
- utopiomania
- Addict
- Posts: 1655
- Joined: Tue May 10, 2005 10:00 pm
- Location: Norway
Justin, I'm shure it can be used for this. The simplest would probably be to write a
procedure to walk through the expression string and replace all FieldName-Op-Value's
with a 1 for True and 0 for a False, then let Eval() solve it:
"(LastName = 'Smith' OR LastName = 'Jones') AND FirstName = 'John'" is translated to:
"(1 OR 0) AND 1" which is then solved by Eval().
procedure to walk through the expression string and replace all FieldName-Op-Value's
with a 1 for True and 0 for a False, then let Eval() solve it:
"(LastName = 'Smith' OR LastName = 'Jones') AND FirstName = 'John'" is translated to:
"(1 OR 0) AND 1" which is then solved by Eval().

that should work but would require to filter the recordset programatically by me, i was thinking in an expression translator that accepts a string like,
(LastName = 'Smith' OR LastName = 'Jones') AND FirstName = 'John'
and returns a string,
(LastName = 'Smith' AND FirstName = 'John') OR (LastName = 'Jones' AND FirstName = 'John')
so it can be used by the filter property and lets the ado engine do the work, looks a bit complex.
(LastName = 'Smith' OR LastName = 'Jones') AND FirstName = 'John'
and returns a string,
(LastName = 'Smith' AND FirstName = 'John') OR (LastName = 'Jones' AND FirstName = 'John')
so it can be used by the filter property and lets the ado engine do the work, looks a bit complex.
-
- Addict
- Posts: 2344
- Joined: Mon Jun 02, 2003 9:16 am
- Location: Germany
- Contact:
Noooo, here a short equation:utopiomania wrote:It isn't case sensitive if that's what you mean ?, so O and o is the same variable, just like variables in PureBasic.
Hope I understood you right.
0=x^2+x-5
There it should give me 2 results:
x1/2 = -0.25+-sqr(0.25+5)
x1 = 2.04 ;Result 1
x2 = -2.54 ;Result 2
Or this one:
1) y=x+5
2) y=2x-5
---
2x-5 = x+5 | +5
2x = x+10 | - x
x = 10
---
y = 10+5
y = 15
Result = (10|15)
bye,
Daniel
Daniel
- utopiomania
- Addict
- Posts: 1655
- Joined: Tue May 10, 2005 10:00 pm
- Location: Norway
- utopiomania
- Addict
- Posts: 1655
- Joined: Tue May 10, 2005 10:00 pm
- Location: Norway
Justin, I don't know if I can add string support, but I have to tell you I have too much
work to do on my own petty projects already, so I can't say yes or no.
Sorry for my late answer, but I'm on holiday now, and just managed to log on to the net
using my laptop and my Moto V600, at 9.6kbits a sec... Sloooow and expensive, so I have
to keep it short for the next week and a half.
work to do on my own petty projects already, so I can't say yes or no.
Sorry for my late answer, but I'm on holiday now, and just managed to log on to the net
using my laptop and my Moto V600, at 9.6kbits a sec... Sloooow and expensive, so I have
to keep it short for the next week and a half.

even if there are some improvements to do, it's a nice & clean parser, thanx.
@utopiomania:
Eval("(23).56")
Eval("23___56")
...should return ERR_SYNTAX, no ?
@utopiomania:
Eval("(23).56")
Eval("23___56")
...should return ERR_SYNTAX, no ?
No programming language is perfect. There is not even a single best language.
There are only languages well suited or perhaps poorly suited for particular purposes. Herbert Mayer
There are only languages well suited or perhaps poorly suited for particular purposes. Herbert Mayer
- utopiomania
- Addict
- Posts: 1655
- Joined: Tue May 10, 2005 10:00 pm
- Location: Norway
- utopiomania
- Addict
- Posts: 1655
- Joined: Tue May 10, 2005 10:00 pm
- Location: Norway