Normal Topic Using NOT incorrectly? (Read 1035 times)
NICEBERG
Full Member
Members
***
Offline


I came, I saw, I'm still
trying to figure it out!

Posts: 208
Location: Green Bay, WI
Joined: Dec 17th, 2003
Using NOT incorrectly?
Sep 1st, 2006 at 7:42pm
Print Post Print Post  
I've been staring at this awhile and am about to go bug-eyed, so, here I am bothering you guys(gals) again. I've inserted two WriteLns in the code to see what's going on. The first one returns the expected value,  the second, nothing. That tells me where the issue is, but I can't figure out if I'm using NOT correctly, combined with the OR. It looks simple enough in the manual....

Code
Select All
 

vStatus = @FormFieldValue("orders","Status",0)


WriteLn(vStatus)
If NOT vStatus = "7 - Canceled" or NOT vStatus = "8 - Completed" then
{
  WriteLn(vStatus)
  @MSGBOX("Be sure to change STATUS to either:","7 - Canceled or","8 - Completed  BEFORE CLOSING.")
  STOP
}

else ....

Also, this is my first attempt at inserting code - sorry if it didn't work out. Someday.... Undecided

Fred
  
Back to top
 
IP Logged
 
NICEBERG
Full Member
Members
***
Offline


I came, I saw, I'm still
trying to figure it out!

Posts: 208
Location: Green Bay, WI
Joined: Dec 17th, 2003
Re: Using NOT incorrectly?
Reply #1 - Sep 1st, 2006 at 7:52pm
Print Post Print Post  
OK, I figured out the inserting-code-in-a-message thing. Now if only the other issue was so obvious to me...

I'm in Green Bay and the Packers game starts in 15 minutes, so maybe I'm rushing a little. Don't know why though:
1 - they stink this year
2 - I'm a VIKINGS fan
  
Back to top
 
IP Logged
 
Hammer
YaBB Administrator
Lanticans
*****
Offline


Fire bad. Tree pretty.

Posts: 3436
Location: Ohio
Joined: Nov 22nd, 2002
Re: Using NOT incorrectly?
Reply #2 - Sep 1st, 2006 at 8:06pm
Print Post Print Post  
Fred,

Your logic isn't going to produce the desired result. Try this:

Code
Select All
vStatus = @FormFieldValue("orders","Status",0)


WriteLn(vStatus)
If (vStatus <> "7 - Canceled") And (vStatus <> "8 - Completed")
 {
  WriteLn(vStatus)
  @MSGBOX("Be sure to change STATUS to either:","7 - Canceled or","8 - Completed  BEFORE CLOSING.")
  // STOP ---Get rid of this! Never use STOP!!!!
 }

else ....  

  

- Hammer
The plural of anecdote is not data.
Back to top
IP Logged
 
Hammer
YaBB Administrator
Lanticans
*****
Offline


Fire bad. Tree pretty.

Posts: 3436
Location: Ohio
Joined: Nov 22nd, 2002
Re: Using NOT incorrectly?
Reply #3 - Sep 1st, 2006 at 8:18pm
Print Post Print Post  
BTW, just to explain what's going on, your main problem is that you are not using parentheses to control what your NOTs affect. Because of this, Sesame is taking its own guess and its guess isn't what you had in mind. Here is what's happening. You wrote this:

If NOT vStatus = "7 - Canceled" or NOT vStatus = "8 - Completed"

NOT nots everything after it. So you are getting,in effect, this:

NOT ((vStatus = "7 - Canceled") or NOT (vStatus = "8 - Completed"))

If vStatus equals "hoosa", this resolves as follows:

NOT ((FALSE) or NOT (FALSE))
NOT (FALSE or TRUE)
NOT (TRUE)
FALSE

Since the final result is FALSE, you never get into your condition.


BTW, in your case, you would also have wanted And instead of Or. Since the value of vStatus can never be both 7 and 8, one would always be false.
  

- Hammer
The plural of anecdote is not data.
Back to top
IP Logged
 
NICEBERG
Full Member
Members
***
Offline


I came, I saw, I'm still
trying to figure it out!

Posts: 208
Location: Green Bay, WI
Joined: Dec 17th, 2003
Re: Using NOT incorrectly?
Reply #4 - Sep 1st, 2006 at 8:18pm
Print Post Print Post  
Thanks Erika, I was getting closer. I had tried the AND and two WriteLn results were returned.

I had used STOP in attempt to halt the programming from running all the way through, but obviously, since my conditions weren't being met this command was moot. Just curious - why not use STOP if you REALLY WANT TO STOP? (And why is it in the manual??)
  
Back to top
 
IP Logged
 
Hammer
YaBB Administrator
Lanticans
*****
Offline


Fire bad. Tree pretty.

Posts: 3436
Location: Ohio
Joined: Nov 22nd, 2002
Re: Using NOT incorrectly?
Reply #5 - Sep 1st, 2006 at 8:23pm
Print Post Print Post  
NICEBERG wrote on Sep 1st, 2006 at 8:18pm:
I had used STOP in attempt to halt the programming from running all the way through, but obviously, since my conditions weren't being met this command was moot. Just curious - why not use STOP if you REALLY WANT TO STOP? (And why is it in the manual??)



It's in the manual because it exists in Q&A. You shouldn't use it because it is a very very hard stop. There is never a need to stop your code this aggressively unless the computer is actually on fire. Use Else or comments instead to prevent code from running. Think of STOP as stopping your car by ejecting the engine. It'll work, but you're much better off using the brakes.
  

- Hammer
The plural of anecdote is not data.
Back to top
IP Logged
 
NICEBERG
Full Member
Members
***
Offline


I came, I saw, I'm still
trying to figure it out!

Posts: 208
Location: Green Bay, WI
Joined: Dec 17th, 2003
Re: Using NOT incorrectly?
Reply #6 - Sep 1st, 2006 at 8:27pm
Print Post Print Post  
I see said the (very)blind man. Thanks!
  
Back to top
 
IP Logged
 
Bob_Hansen
Senior Member
Members
*****
Offline


WOW, They have the Internet
on computers now!

Posts: 1861
Location: Salem, NH
Joined: Nov 24th, 2002
Re: Using NOT incorrectly?
Reply #7 - Sep 2nd, 2006 at 12:33am
Print Post Print Post  
Quote:
I see said the (very)blind man.


Hmmm, I thought it was "I see", said the blind carpenter who picked up his hammer and SAW.   Roll Eyes
  



Bob Hansen
Sesame Database Manager Professional
Sensible Solutions Inc.
Salem, NH
603-898-8223
Skype ID = sensiblesolutions
Back to top
IP Logged