× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Terry Grider wrote:

>Has anyone ever written or seen an 
>example of program code designed to
>evaluate complex conditions?  For 
>example, if you wanted to evaluate 
>a =b and (c = d or c = e or c = f).  
>I'm looking for something that can do
>multiple levels of parenthesis and 
>all "and/or" combinations.

I had to do this years and years ago on S/3 using RPG II.  The book I used
(and still keep on my shelf here at work) is "Compiler Design Theory" by
Lewis, Rosenkrantz and Stearns.  Addison-Wesley Publishing Co., Nov. 1978.
It's part of the IBM Systems Programming Series.  

I'm not going to pretend to have workable code for you using RPG, but you
can use ReXX to do much of the work for you:  Here is a ReXX example.  Place
this in QREXSRC, member EVAL.  To execute, strrexprc eval.

/* EVAL - Evaluate expressions */                                           
/* The goofy variable names are there to avoid conflicts with user input */ 
                                                                            
Top:                                                                        
   Signal On Syntax                                                         
   Do i0z0=1                                                                
      last=c000                                                             
      Parse Pull c0z0                                                       
      Select                                                                
         When c0z0=''                                                       
            Then Say 'EXIT to quit.'                                        
         Otherwise                                                          
            Interpret c0z0                                                  
      End                                                                   
   End                                                                      
                                                                            
Syntax:                                                                     
   Say 'Error (rc =' rc':' errortext(rc)')'                                 
   Signal Top                                                               

I hope this helps.  It was the best I could do without knowing how you get
the expression and how you intend to use the results.

Buck Calabro
Aptis; Albany, NY
"We are what we repeatedly do.
 Excellence, then, is not an act, but a habit." --Aristotle


Billing Concepts Corp., a NASDAQ Listed Company, Symbol: BILL
+---
| This is the Midrange System Mailing List!
| To submit a new message, send your mail to MIDRANGE-L@midrange.com.
| To subscribe to this list send email to MIDRANGE-L-SUB@midrange.com.
| To unsubscribe from this list send email to MIDRANGE-L-UNSUB@midrange.com.
| Questions should be directed to the list owner/operator: david@midrange.com
+---

As an Amazon Associate we earn from qualifying purchases.

This thread ...


Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.