simple if...then question

lbenson

Senior Member
Yes, you got it:

if b0>128 and b1>128 then

The simulator is your friend in this case--quicker than asking.
Code:
b0 = 129
b1 = b0
if b0>128 and b1>128 then
 high b.0
endif
 

Attachments

Jarubell

Senior Member
I miss that simulator, I'm using AXEpad on Ubuntu. I tried using 'and' earlier but I clearly must had made a mistake where the syntax checker found an error. Works as instructed, thank you.
 

inglewoodpete

Senior Member
Perhaps not the clearest piece of documentation but the Command Manual (Manual 2) describes the use of AND and OR in the description of the IF command.

The description is also described here in the on-line manual, under Multiple Conditions, half way down the web page.
 

westaust55

Moderator
It would also be worth reading this thread on IF...THEN statements:
http://www.picaxeforum.co.uk/showthread.php?28456-simple-if-then-question

Further, at least in the past there was a problem with combining AND and OR in the same test. (where each "test" is variable =/</>/etc variable or variable =/</>/etc constant)

IF test AND test AND test THEN was okay
IF test OR test OR test THEN was okay

but
IF test AND test OR test gave problems.
Technical or hippy might be able to confirm if this is now resolved.
 

marks

Senior Member
I don't think there was ever a problem in there use!
but it can be difficult to interpret.
Every time I write a long statement I seem to have to relearn how to use it.

here's one example with the months and dates used in Day Light Saving snip
Code:
#picaxe 18m2
#terminal 38400 'marks
 SYMBOL index    = b0     
 SYMBOL hours    = b1
 SYMBOL mins     = b2
 SYMBOL secs     = b3  
 SYMBOL day      = b7     ' not used 
 SYMBOL date     = b4  
 SYMBOL month    = b5   
 SYMBOL year     = b6 
 SYMBOL CommonYear  = b8
 SYMBOL DayNumber   = W6 
 SYMBOL DSTstart    = W7
 SYMBOL DSTend      = W8  : SYMBOL DayS = W8
SETFREQ M32      

 InitialiseTime:
    HI2Csetup I2Cmaster, %11010000, I2Cslow_32, I2Cbyte  ' Set  DS1307 to 100kbps 
      HI2Cout $0 , ( $30, $59, $1,day, $01 , $11 , $15) ' program DS1307 with GMT 
 Main: pause 8000
    HI2Csetup I2Cmaster, %11010000, I2Cslow_32, I2Cbyte  ' Set  DS1307 to 100kbps 
      HI2Cin  $0 , (secs,mins,hours,day,date,month,year) ' Read DS1307
	
        FOR bptr = 1 TO 6   
          @bptr = @bptr/$10*250+@bptr                     ' Convert BCD to Decimal  
        NEXT

 EasternDaylightTime:                       ' United States       
     CommonYear = year //4 +3 /4            ' CommonYear =1              
      DayNumber = month +9 /12   
      DayNumber = CommonYear + DayNumber * DayNumber
      DayNumber = month *275 /9 +date -30 -DayNumber 
           DayS = year *512 **46752         ' year =1 to 99    
       DSTstart = Days +72//7                 
       DSTstart = 74 -CommonYear -DSTstart  ' Second SunDay in March                  
         DSTend = DSTstart +238              ' First SunDay in November 	   
	IF DayNumber < DSTstart OR DayNumber > DSTend THEN Display
	IF DayNumber = DSTstart AND hours <2 THEN Display   ' DST starts at 0200 
	IF DayNumber = DSTend   AND hours >1 THEN Display    ' DST ends at 0200
	   IF hours =23 THEN : INC date  
	     IF month =4 or month =6 or month =9  and date =31 OR date=32 THEN : date =1 INC month: ENDIF
	   ENDIF : hours =hours +1//24           
	  Sertxd ("EDT  ") :  GOTO DateTime                 ' DST +1	  
Display:Sertxd ("EST  ")                                   ' StandardTime  
DateTime:  
	  sertxd ("20",#year,"/",#month,"/",#date,"    ")    ' Date 20yy/mm/dd 
         index = mins/10 :mins = mins//10                  
          sertxd (#hours,".",#index,#mins)                 ' 24hr time hh/mm/ss          
         index = secs/10 :secs = secs//10
          sertxd (".",#index,#secs,CR,LF)
   goto main
 

marks

Senior Member
As always Thanks!
Westaust55
for that extra information!
looks like I was lucky not using the sequence of more than one AND followed by an OR
and only being with the simulation.

hopefully all is fixed from
6.0.8.3
New Updated Blockly core to 1.0.4
Change sim behaviour to match OR after AND real chip behaviour
Added Blockly manual
 
Top