PC Review


Reply
Thread Tools Rate Thread

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

 
 
Jakub Bednarczuk
Guest
Posts: n/a
 
      11th Jan 2007
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

 
Reply With Quote
 
 
 
 
Bruce Wood
Guest
Posts: n/a
 
      11th Jan 2007

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....

 
Reply With Quote
 
Ben Voigt
Guest
Posts: n/a
 
      11th Jan 2007

"Bruce Wood" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>
> 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>


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Simple web fetching class with: string Get(string URL), bool Busy and Stop() members x.meglio@gmail.com Microsoft C# .NET 10 21st Mar 2007 01:18 PM
cannot implicitly convert type string to bool eric.goforth@gmail.com Microsoft C# .NET 6 18th Mar 2006 04:56 PM
convert int to bool John A Grandy Microsoft C# .NET 4 3rd Mar 2006 03:02 PM
Convert a string to bool ReidarT Microsoft C# .NET 9 20th Feb 2005 10:10 AM
Cannot convert to bool error in VB but not C# Bill Dee Microsoft VB .NET 12 5th May 2004 02:39 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:45 PM.