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 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.
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 |
- RE: [Hardhats-members] M statements Pringle, Duncan