James,
This is not actually true since the interpreter always evaluates logic
within paranthesis first!
For Example, in the world of Magic:
3+(2x2) = 7 read as: two times two equals four, three plus four equals
seven
but
3+2x2 = 10 read as: three plus two equals five times two equals ten.
In your expression "A&B&(3^C)", the first thing to happen is the value
of 3 is assigned to the variable C, then the interpreter reads the value
of A and passes the lesser value of A versus B. (The & is not really
read as "and" but rather as "Minimum" while the ! is not "or" but rather
"Maximum". It functions the same since we are actually dealing with
values.)
To answer your question, since A is nil and the minimum value is to be
passed, the interpreter does NOT continue to evaluate the rest of the
expression but rather immediately passes the value of nil. To prove
this, set up the following code and then check the values:
""^A,
1^B,
IF{A&B+1^B&(1^C) DO.THIS;DO.THAT}
After the expression is evaluated, you will find the following:
[B] = 1
[C] = 1
This is true because the interpreter read: ""^A, 1^B, IF 1^C, take the
minimum(lesser) value of A..... pass the value of nil since it is the
minimum, DO.THAT}
Had the interpreter read the logic to the right of A&, the value of B
would have been increased by 1 making it 2. Since the value of B
remained 1, that logic was not read by the interpreter!
Thanks for the brain teaser!
Kenny Whiteside
Kenny Whiteside BSN, RN
Patient Care Information Systems
Catawba Valley Medical Center
810 Fairgrove Church Road
Hickory, NC 28602
[EMAIL PROTECTED]
>>> "Purvins, James A." <[EMAIL PROTECTED]> 06/22/2007 11:46:55 AM >>>
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
>
>
>
>
>
>
>
--
This message has been scanned for viruses and
dangerous content, and is
believed to be clean.
Catawba Valley Medical Center
810 Fairgrove Church Rd
Hickory NC 28602
828-326-3000
**This electronic message may contain information that is confidential
and/or legally privileged. It is intended only for the use of the
individual(s) and entity named as recipients in the message, please
notify the sender immediately and delete the material from any computer.
Do not deliever, distribute or copy this message, and do not disclose
its contents or take any action in reliance on the information it
contains.
Thank you
--
This message has been scanned for viruses and
dangerous content, and is
believed to be clean.
=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=
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