473,385 Members | 1,769 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

how to convert logic operation stored as a string to bool ?

Hi everybody

I am trying to find the solution for the problem stated in the topic,
but so far without any result.
Let's see the problem.

I have set of conditions and the description (logical sentence) how
should be these conditions connected with each other. See how does it
look in xml

<root>
<conditions>
<condition term = '1'/>
<condition term = '2'/>
</conditions>
<logicOperation>(#1 and #2)</logicOperation>
</root>

I store the conditions results in bool array. How can I get the
logicOperation result having (#1 and #2) as a string ?

I already converted the given logicOperation into the form (true &&
false). However it is still string, and the during the converting to
bool sample is impossible.

I have the idea to loop thru all "true" and "false" strings and
converting them to bool. The problem is how to store logicOperation
during transformation. I mean: How to store (true && false) where true
is of bool type and false is of string type? I think it is impossible.

Maybe someone of you have the tricky idea how to do it ?

Thanks in advance
Jakub

Jan 11 '07 #1
2 2402

Jakub Bednarczuk wrote:
Hi everybody

I am trying to find the solution for the problem stated in the topic,
but so far without any result.
Let's see the problem.

I have set of conditions and the description (logical sentence) how
should be these conditions connected with each other. See how does it
look in xml

<root>
<conditions>
<condition term = '1'/>
<condition term = '2'/>
</conditions>
<logicOperation>(#1 and #2)</logicOperation>
</root>

I store the conditions results in bool array. How can I get the
logicOperation result having (#1 and #2) as a string ?

I already converted the given logicOperation into the form (true &&
false). However it is still string, and the during the converting to
bool sample is impossible.

I have the idea to loop thru all "true" and "false" strings and
converting them to bool. The problem is how to store logicOperation
during transformation. I mean: How to store (true && false) where true
is of bool type and false is of string type? I think it is impossible.

Maybe someone of you have the tricky idea how to do it ?
There is no tricky way in C# that I know of. You have to write your own
little parser and expression evaluation class. Fortunately, it's not
that difficult....

Jan 11 '07 #2

"Bruce Wood" <br*******@canada.comwrote in message
news:11**********************@o58g2000hsb.googlegr oups.com...
>
Jakub Bednarczuk wrote:
>Hi everybody

I am trying to find the solution for the problem stated in the topic,
but so far without any result.
Let's see the problem.

I have set of conditions and the description (logical sentence) how
should be these conditions connected with each other. See how does it
look in xml

<root>
<conditions>
<condition term = '1'/>
<condition term = '2'/>
</conditions>
<logicOperation>(#1 and #2)</logicOperation>
</root>

I store the conditions results in bool array. How can I get the
logicOperation result having (#1 and #2) as a string ?

I already converted the given logicOperation into the form (true &&
false). However it is still string, and the during the converting to
bool sample is impossible.

I have the idea to loop thru all "true" and "false" strings and
converting them to bool. The problem is how to store logicOperation
during transformation. I mean: How to store (true && false) where true
is of bool type and false is of string type? I think it is impossible.

Maybe someone of you have the tricky idea how to do it ?

There is no tricky way in C# that I know of. You have to write your own
little parser and expression evaluation class. Fortunately, it's not
that difficult....
If the xml schema is changed to represent an AST, then parsing strings won't
be necessary either.

something like:

<root>
<nodes>
<condition term="1"/>
<condition term="2"/>
<condition term="3"/>
<expression term="out1" logicOperation="and">
<input term="1"/>
<input term="2"/>
</expression>
<expression term="tmp1" logicOperation="or">
<input term="1"/>
<input term="2"/>
</expression>
<expression term="out2" logicOperation="and">
<input term="3"/>
<input term="tmp1"/>
</expression>
</nodes>
</root>
Jan 11 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

22
by: James H. | last post by:
Greetings! I'm new to Python and am struggling a little with "and" and "or" logic in Python. Since Python always ends up returning a value and this is a little different from C, the language I...
14
by: Chris | last post by:
Hi, I try to print out truth-tables for an &&-operation using the following code, unfortunatly I get compiler errors : for ( byte i1=0; i1<=1; i1++) { for ( byte i2=0; i2<=1; i2++) { bool...
2
by: Dino L. | last post by:
How can I run stored procedure (MSSQL) ?
5
by: simon | last post by:
I have datetime variable: Datetime tsEndTime; Should I use (DateTime): tsEndTime=(DateTime)rdr.GetValue(15) or is better to use: tsEndTime=Convert.ToDateTime(rdr.GetValue(15))
5
by: Learner | last post by:
Hello, Here is the code snippet I got strucked at. I am unable to convert the below line of code to its equavalent vb.net code. could some one please help me with this? static public...
3
by: mrajanikrishna | last post by:
Hi Friends, I am accepting a number from the user entered in a textbox. I want to assign to a variable in my code and assignt this to that variable. double num1 = (double)txtNum1.text; ...
0
by: weird0 | last post by:
Here is the code for executing stored procedure ExecuteSP() , and object that sets all its parameters in other functions and the stored procedure. I think it has something to do with db datatypes...
6
by: John | last post by:
The following code: int test = 1; bool isTrue = (bool)test; results in a compiler error: Cannot convert type 'int' to 'bool' wtf, any ideas on how to work around this?
1
by: Michel Walsh | last post by:
In the same spirit, but more LINQ related, you can also use ExecuteQuery: var query = dataContext.ExecuteQuery<className>( @"SELECT ... WHERE ... AND... OR... "); where className is...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.