| Author | 
         | 
         
      
        
         
         edtude Groupie 
          
  
  Joined: July 26 2006 Location: United States
 Online Status: Offline Posts: 64
          | 
        
         
          
           | Posted: June 04 2013 at 22:23 | IP Logged
		     | 
                    
            		  
           | 
           
          
           
  | 
           
          
I am working on some Macros for my Tstat setup and using some of Gadget Guys work as a basis. however this one line I can not get to work and it is a 'case' statement and when I run the macro I get a syntax error. Can anybody tell me where I am making my mistake?
 
 case([LOCAL4]WHEN 0 THEN "Off" WHEN 1 THEN "Heat" WHEN 2 THEN "Cool" WHEN 3 THEN "Auto" WHEN 4 THEN "Fan" )
         | 
       
       
        | Back to Top | 
         
          
         | 
       
       
       
        |   | 
      
        
         
         JaredM Newbie 
          
 
  Joined: November 04 2007
 Online Status: Offline Posts: 36
          | 
        
         
          
           | Posted: June 04 2013 at 23:29 | IP Logged
		     | 
                    
            		  
           | 
           
          
           
  | 
           
          
One guess is that when you're testing it [LOCAL4] is not a number, so your getting a syntax error trying to compare a string to an integer. Try this:
 
 
Code: 
   
    
    
      
       | case(integer('[LOCAL4]') WHEN 0 THEN "Off" WHEN 1 THEN "Heat" WHEN 2 THEN "Cool" WHEN 3 THEN "Auto" WHEN 4 THEN "Fan") | 
       
       | 
    
    | 
 
 
         | 
       
       
        | Back to Top | 
         
          
         | 
       
       
       
        |   | 
      
        
         
         edtude Groupie 
          
  
  Joined: July 26 2006 Location: United States
 Online Status: Offline Posts: 64
          | 
        
         
          
           | Posted: June 10 2013 at 15:25 | IP Logged
		     | 
                    
            		  
           | 
           
          
           
  | 
           
          
I needed to re-init the application and then the 'case' statement worked as expected.
         | 
       
       
        | Back to Top | 
         
          
         | 
       
       
       
        |   |