| View previous topic :: View next topic | 
	
	
		| Author | Message | 
	
		| hogandeveloper Beginner
 
 
 Joined: 05 Aug 2008
 Posts: 11
 Topics: 10
 
 
 | 
			
				|  Posted: Mon Sep 28, 2009 2:44 am    Post subject: IF Then Else Assistance required |   |  
				| 
 |  
				| Hi All, I have an unusual problem. The eventhough the FIELD-A is spaces it still goes to the IF part and not to the ELSE part. Please help me to sort this out.
 
  	  | Code: |  	  | IF FIELD-A NOT = SPACES OR LOW-VALUES
 SET ALPH-NAME(12)      TO TRUE
 MOVE 'ACCOUNT TYPE:'   TO ENT-ALPHA(12)
 SET ALPH-NAME(13)      TO TRUE
 MOVE 'SAVINGS POCKET'  TO ENT-ALPHA(13)
 SET ALPH-NAME(14)      TO TRUE
 MOVE 'ACCOUNT NUMBER:' TO ENT-ALPHA(14)
 SET STAT-DATA(15)      TO TRUE
 MOVE FIELD-A           TO ENT-ALPHA(15)
 ELSE
 SET  ALPH-NAME(12)   TO TRUE
 MOVE SPACES          TO ENT-ALPHA(12)
 SET ALPH-NAME(13)    TO TRUE
 MOVE SPACES          TO ENT-ALPHA(13)
 SET ALPH-NAME(14)    TO TRUE
 MOVE SPACES          TO ENT-ALPHA(14)
 SET ALPH-NAME(15)    TO TRUE
 MOVE SPACES          TO ENT-ALPHA(15)
 END-IF.
 
 | 
 Thanks,
 HD
 |  | 
	
		| Back to top |  | 
	
		|  | 
	
		| Anuj Dhawan Intermediate
 
 
 Joined: 19 Jul 2007
 Posts: 298
 Topics: 7
 Location: Mumbai,India
 
 | 
			
				|  Posted: Mon Sep 28, 2009 4:07 am    Post subject: Re: assistance required |   |  
				| 
 |  
				| Please check the contentes of FIELD-A with HEX ON, you will come to know what's there. 
 Please learn to use BBcode that makes code rather readable.
 _________________
 Regards,
 Anuj
 |  | 
	
		| Back to top |  | 
	
		|  | 
	
		| acevedo Beginner
 
  
 Joined: 03 Dec 2002
 Posts: 127
 Topics: 0
 Location: Europe
 
 | 
			
				|  Posted: Mon Sep 28, 2009 6:41 am    Post subject: Re: assistance required |   |  
				| 
 |  
				| If I'm not wrong: 
 
  	  | Code: |  	  | IF FIELD-A NOT = SPACES OR LOW-VALUES | 
 is the same as
 
 
  	  | Code: |  	  | IF FIELD-A NOT = SPACES OR field-a not = LOW-VALUES | 
 
 so if FIELD-A = SPACES then meets the IF condition.
 
 maybe, just maybe you ment:
 
  	  | Code: |  	  | IF FIELD-A NOT = SPACES AND LOW-VALUES | 
 
 HTH
 |  | 
	
		| Back to top |  | 
	
		|  | 
	
		| dbzTHEdinosauer Supermod
 
 
 Joined: 20 Oct 2006
 Posts: 1411
 Topics: 26
 Location: germany
 
 | 
			
				|  Posted: Mon Sep 28, 2009 8:25 am    Post subject: |   |  
				| 
 |  
				| acevedo, 
 very nicely posed.
 _________________
 Dick Brenholtz
 American living in Varel, Germany
 |  | 
	
		| Back to top |  | 
	
		|  | 
	
		| Anuj Dhawan Intermediate
 
 
 Joined: 19 Jul 2007
 Posts: 298
 Topics: 7
 Location: Mumbai,India
 
 | 
			
				|  Posted: Mon Sep 28, 2009 11:37 am    Post subject: |   |  
				| 
 |  
				| acevedo is correct and just to extend a bit on what he has said. Actually, the code: will NOT work. While you can use "NOT =" with AND, you can not have it work with OR. 	  | Code: |  	  | IF FIELD-A NOT = SPACES OR LOW-VALUES | 
 
 Your code:
 will expand to 	  | Code: |  	  | IF FIELD-A NOT = SPACES OR LOW-VALUES | 
 as acevedo has said and it will ALWAYS set TRUE with any value of FIELD-A.  Reason: FIELD-A = SPACES is NOT = LOW-VALUES result is true on first condition and same for other condition etc... 	  | Code: |  	  | IF FIELD-A NOT = SPACES OR FIELD-A NOT = LOW-VALUES
 | 
 _________________
 Regards,
 Anuj
 |  | 
	
		| Back to top |  | 
	
		|  | 
	
		| Terry_Heinze Supermod
 
 
 Joined: 31 May 2004
 Posts: 391
 Topics: 4
 Location: Richfield, MN, USA
 
 | 
			
				|  Posted: Mon Sep 28, 2009 3:17 pm    Post subject: |   |  
				| 
 |  
				| A good example of how using NOT can get you in trouble.  Alternative methods of coding this:  	  | Code: |  	  | IF FIELD-A = SPACE OR LOW-VALUE <DO ONE THING>
 ELSE
 <DO SOMETHING ELSE>
 END-IF
 | 
 or
  	  | Code: |  	  | EVALUATE FIELD-A WHEN SPACE
 WHEN LOW-VALUE
 do something
 WHEN OTHER
 do another thing
 END-EVALUATE
 | 
 _________________
 ....Terry
 |  | 
	
		| Back to top |  | 
	
		|  | 
	
		|  | 
	
		|  |