Solved

Evaluating a String as Boolean

Posted on 1997-12-13
12
288 Views
Last Modified: 2010-04-04
Hi

I have a rather tricky problem.  I don't want to use SQL, but I want the result of a function to evaluate as true or false.
The user picks a fieldname from a list, then an operator (=,<>,>=,<=), then types in the answer required.  I want to evaluate the concatenation of the above to a Boolean result.

I think I would need to make the whole expression into a string because I will need to use the As operator when I get the fieldtype from the field, and then cast the typed in criteria to the correct type.
I don't want to type multiple lines to cater for every possible combination of results, so I need an Eval(String) type of function.

Any help gratefully received.  I am using D1.
0
Comment
Question by:jdthedj
  • 5
  • 4
  • 2
  • +1
12 Comments
 
LVL 4

Expert Comment

by:itamar
ID: 1353535
I am suposing that you need this to select registers from a Table, right ?
What about using the Filter property of TTable ?
You can set the expression "on the fly".

P.S.: I am not sure if you have this property in D1
0
 
LVL 3

Author Comment

by:jdthedj
ID: 1353536
Thanks for the reply Itamar.  No, filtering is not an option with D1. The reason I don't want to use SQL is because I want the user to be able to edit the data returned, and SQL is often read only.
I am basically trying to build a filter which will work on the user's choices, but I can't work out a simple way of getting a Boolean answer from the pseudo "Where" statement.

0
 
LVL 8

Expert Comment

by:ZifNab
ID: 1353537
Hi jdthedj,

You have Rx Library not?
Why don't you use that filter? Isn't it usable in D1, supose it is!

c.u. Zif.
0
 
LVL 3

Expert Comment

by:Pegasus100397
ID: 1353538
Heya Jdthedj,

  I love these types of questions (NOT!) hehehahaha
Anyways, if I understand correctly you want to do comparisons of fields against data in a table right?

Such As: Table1
Name        Points
---------------------------
Itamar       3000
jdthedj       2500
ZifNab      4000

and construct a string such as: "Points >=3000" and have it return TRUE if *any* (no matter how many) records match that criteria and FALSE otherwise, is this correct? If so I have a nifty solution as I recently (in the past month) had to build similiar functionality into my app. Let me know if this is what you are trying to accomplish.

Good Luck With Your Project!
Pegasus
0
 
LVL 4

Expert Comment

by:itamar
ID: 1353539
To: ZifNab

Hi Zif !

What is Rx Library ?

0
 
LVL 3

Author Comment

by:jdthedj
ID: 1353540
Hi Guys

Thanks for the replies.  

Zifnab - I also wonder what is Rx Library??
Pegasus - I think what you're talking about is what I need.  Basically the ap I am working on is like the Database Desktop, but with more functionality.  It allows sorting on any field indexed or not, and that part works, but I have also placed 3 fields on a form above the grid as outlined in the original question.  I would then make a string out of the combination of the 3 fields which would need to evaluate as Boolean.
The resulting string would be Fields[cField.ItemIndex].AsString >= "FieldValue" etc.
I would be grateful for your solution.

JD
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 8

Expert Comment

by:ZifNab
ID: 1353541
? Don't you guys know about Rx Library? Strange...
It's a freeware library with lot's of interesting stuff. Full source!!! It's for D1, D2, D3. Handy, isn't it? I think it are about 70 components, ... Pitty though the help-file is in russian ;-(. But the components are self-explaining.

I suggest that you all have a look at it. But look out when installing the stuff. I always recommend to take a copy of your library, even it looks very professional stuff. There always can go something wrong.

Here is the url :

http://rx.demo.ru

Those guys really did a great job...

You can use there filter to filter through a table, I think it's even faster (I'm almost sure) ....

Have fun with it!
c.u. Zif.
0
 
LVL 3

Author Comment

by:jdthedj
ID: 1353542
Thanx for the tip, Zifnab - I'll check it out.
0
 
LVL 8

Expert Comment

by:ZifNab
ID: 1353543
And, tried out the Rx library? What do you think about it?
c.u.'ll
0
 
LVL 3

Author Comment

by:jdthedj
ID: 1353544
Hi ZifNab

I've downloaded the RxLibrary and it's great - the filter does just what I need.  If you want to turn your comments into an answer, you deserve the points for this one.  Thanx again

John D
0
 
LVL 8

Accepted Solution

by:
ZifNab earned 120 total points
ID: 1353545
Hi John D,

Well, I'll answer the question :
Try the freeware filter in the RxLibrary, you can find this library at http://rx.demo.ru.

My opinion is also that I don't diserve the full points, I didn't make the component. So, if it's possible and you think the same, I don't mind that you reduce the pints of this question.

Glad I could help you. Have fun with the Library!
c.u. BanZif.

0
 
LVL 3

Author Comment

by:jdthedj
ID: 1353546
Thanks BanZif.  They won't let me reduce the points, but I have a very happy client, so I don't mind giving you the points.

John D
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now