A visual look at the first line, parsing and calculating the truth value of each _expression_ in the string, then substituting that value in the next calculation:
 
EHR>W X
0115LV
EHR>W $L(X)
6
EHR>W 6>30
0
EHR>W 0!$L(X)
1
EHR>W 1<6
1
which is the truth value, so write "Done"
 
 
Now, the second line:
EHR>W X
0115LV
EHR>W $L(X)
6
EHR>W 6!$L(X)
1
EHR>W 1>30
0
which is false - so don't write "Done"
 

Duncan Pringle, PMP
perotsystems
813.371.7284 (office)
813.891.6138 (fax)
727.244.8008 (cell)
AIM:    imdpringle
Email:  [EMAIL PROTECTED]

 


From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Robert DeWayne
Sent: Tuesday, October 25, 2005 9:39 AM
To: hardhats-members@lists.sourceforge.net
Subject: RE: [Hardhats-members] M statements

Maybe a simpler explanation is this:
 
The length of X is 6, so when M does the logic, is x greater than 30? No, then it gets an or, this is where the logic breaks.  The or get evaluated as the length of X (the less than 6 is excluded), therefore it is true.
 
 
Robert DeWayne
Senior Consultant
Daou Systems, Inc.
P: (317) 616-4745  C:(317) 727-7477
 


From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Holloway, Thomas (EDS)
Sent: Tuesday, October 25, 2005 8:21 AM
To: hardhats-members@lists.sourceforge.net
Subject: RE: [Hardhats-members] M statements

Usha,
 
   M is very strict about interpreting logic sequences and about evaluating each separate element and operator.  In your first statement M does something like this:
 
$L(X) is 6, is 6 greater than 30?  No, so that evaluates False or 0.  Now OR that with $L(X) which is 6, giving 0 OR 6.  0 is False, 6 is True, so result is True or 1.  Now is 1 less than 6?  Yes, so whole logic equation evaluates as True and we Write "Done. 
 
   The solution to making it perform as intended is to use parentheses:
 
>S X="0115LV" I ($L(X)>30)!($L(X)<6) W "DONE"
 
   For the sake of pure logic, you don't need the parentheses around $L(X)>30 but using them helps clarify the intent to the next programmer that reads it.
 
   tjh


From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Usha
Sent: Tuesday, October 25, 2005 7:25 AM
To: hardhats-members@lists.sourceforge.net
Subject: [Hardhats-members] M statements

Hi
 
Just wondering what brings in the difference in output of the following statements
 
EHR 3f0>S X="0115LV" I $L(X)>30!$L(X)<6 W "DONE"
DONE
EHR 3f0>S X="0115LV" I $L(X)<6!$L(X)>30 W "DONE"
 
EHR 3f0>
 
Why does the respond in the way it is?
 
Usha

Reply via email to