toxicmouse
Senior Member
I am trying to clean up the code below to make it less clumsy, any ideas appreciated. I am using a 40x2.
symbol PIR1= B.1
symbol PIR2= B.2
symbol PIR3= B.3
symbol PIR4= B.4
symbol PIR5= B.5
symbol PIR6= B.6
symbol PIR7= B.7
main:
gosub check_pir
{some other code in here to process the results}
goto main
check_pir: 'if PIR activated then pirflag = 1 and pir_activated = the id number of the activated PIR
b7 = PIR1
if b7 = 1 then goto check_pir_PIR1
b7 = PIR2
if b7 = 1 then goto check_pir_PIR2
b7 = PIR3
if b7 = 1 then goto check_pir_PIR3
b7 = PIR4
if b7 = 1 then goto check_pir_PIR4
b7 = PIR5
if b7 = 1 then goto check_pir_PIR5
b7 = PIR6
if b7 = 1 then goto check_pir_PIR6
b7 = PIR7
if b7 = 1 then goto check_pir_PIR7
return 'this is only if none of the PIRs have been activated.
check_pir_PIR1:
pirflag = 1
pir_activated =1
return 'return to main programme
check_pir_PIR2:
pirflag = 1
pir_activated = 2
return 'return to main programme
check_pir_PIR3:
pirflag = 1
pir_activated = 3
return 'return to main programme
check_pir_PIR4:
pirflag = 1
pir_activated = 4
return 'return to main programme
check_pir_PIR5:
pirflag = 1
pir_activated =5
return 'return to main programme
check_pir_PIR6:
pirflag = 1
pir_activated = 6
return 'return to main programme
check_pir_PIR7:
pirflag = 1
pir_activated = 7
return 'return to main programme
symbol PIR1= B.1
symbol PIR2= B.2
symbol PIR3= B.3
symbol PIR4= B.4
symbol PIR5= B.5
symbol PIR6= B.6
symbol PIR7= B.7
main:
gosub check_pir
{some other code in here to process the results}
goto main
check_pir: 'if PIR activated then pirflag = 1 and pir_activated = the id number of the activated PIR
b7 = PIR1
if b7 = 1 then goto check_pir_PIR1
b7 = PIR2
if b7 = 1 then goto check_pir_PIR2
b7 = PIR3
if b7 = 1 then goto check_pir_PIR3
b7 = PIR4
if b7 = 1 then goto check_pir_PIR4
b7 = PIR5
if b7 = 1 then goto check_pir_PIR5
b7 = PIR6
if b7 = 1 then goto check_pir_PIR6
b7 = PIR7
if b7 = 1 then goto check_pir_PIR7
return 'this is only if none of the PIRs have been activated.
check_pir_PIR1:
pirflag = 1
pir_activated =1
return 'return to main programme
check_pir_PIR2:
pirflag = 1
pir_activated = 2
return 'return to main programme
check_pir_PIR3:
pirflag = 1
pir_activated = 3
return 'return to main programme
check_pir_PIR4:
pirflag = 1
pir_activated = 4
return 'return to main programme
check_pir_PIR5:
pirflag = 1
pir_activated =5
return 'return to main programme
check_pir_PIR6:
pirflag = 1
pir_activated = 6
return 'return to main programme
check_pir_PIR7:
pirflag = 1
pir_activated = 7
return 'return to main programme