The ! operator is maximum and the & operator is minimum.  Magic
evaluates the entire expression which is the condition of your IF
statement, therefore C = 3.   The ! behaves like an OR and the & behaves
like an AND but the thing that magic is really doing is maximum and
minimum.

 

So 4&5 returns 4

     4!5  returns 5

 

 

Some languages have what is called "short circuit boolean evaluation",
meaning they process the AND and OR expressions from left to right and
as soon as they have a failure which would make the whole expression
false, they quit and do not run the rest of the comparisons.

 

Magic works this way only with IF and DO, if you have an ELSE (;) the
ELSE expression won't get evaluated if the prior condition is true.

 

Your IF statement has an condition which is a single expression
A&B&(3^C) so the entire expression is evaluated because magic just goes
left to right doing the AminimumBminimum(3^C).

 

If you use IF and else, the elses do not execute if the IF is true:

 

IF{1=1 "THIS EXECUTES";

2=2 "THIS DOES NOT"}

 

 

 

Joe Cocuzzo
Vice President
NPR Services
Iatric Systems, Inc.
Phone/Fax: (978) 805-4115
Email: [EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]> 
Web:  www.iatric.com <http://www.iatric.com>  

________________________________

From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf
Of Purvins, James A.
Sent: Friday, June 22, 2007 11:47 AM
To: [email protected]
Subject: [MEDITECH-L] Magic Question : IF : DO : Expression Evaluation

 

When I had this question in mind, I did not think of actually just
writing some code to prove one way or another. 

It appears Magic continues evaluating even though the statement will
evaluate to false. 

Here's the code I tried at the front end:

""^A, 
1^B, 
IF{A&B&(3^C) do this; 
Do that} 

When I examined variable C - its value was 3 so apparently the
interpreter continues evaluating even though the evaluation will be
false.

James Purvins 
Inland Northwest Health Services 
(509) 232-8384 

This e-mail and any attachments are confidential and may also be
privileged. If you are not the named recipient, or have otherwise
received this communication in error, please delete it from your inbox,
notify the sender immediately by replying to the message, and do not
disclose its contents to any other person, use the information for any
purpose or store or copy the information in any medium. Thank you for
your cooperation

_____________________________________________ 
From:   Purvins, James  A.  
Sent:   Thursday, June 21, 2007 2:46 PM 
To:     [email protected] 
Subject:        Magic Question : IF : DO : Expression Evaluation 

To Meditech-L, 
This is just a curiousity question to kill the cat. 

Does anyone know if Magic continues to evaluate an IF or DO statement
once it has been determined that it will fail. 

For example: 
""^A,
1^B, 
IF{A&B do this; 
Do that}, 

Will the Magic interpreter evaluate B even though A is nil and the
interpreter should just automatically <do that>? 

This is one of those Friday questions (its not Friday yet but I am
thinking about it) 

James Purvins 
Inland Northwest Health Services 
(509) 232-8384 

This e-mail and any attachments are confidential and may also be
privileged. If you are not the named recipient, or have otherwise
received this communication in error, please delete it from your inbox,
notify the sender immediately by replying to the message, and do not
disclose its contents to any other person, use the information for any
purpose or store or copy the information in any medium. Thank you for
your cooperation








=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=
To subscribe or unsubscribe to the meditech-l, visit 
http://mtusers.com/mailman/listinfo/meditech-l_mtusers.com

To check the status of the meditech-l, visit MTUsers.NET

For help, email [EMAIL PROTECTED]

Please visit and add information to the MTUsers WikiPedia at MTUsers.NET/mwiki
______________________________________
meditech-l mailing list
[email protected]
http://mtusers.com/mailman/listinfo/meditech-l_mtusers.com

Reply via email to