How many If...ElseIf statements can I use?
Posted: Wed Dec 27, 2006 10:56 am
Hi everybody,
I hope that everyone have had a very nice christmas. After a long time of testing I found something, that makes me confused. Please have a look at the following code:
This interrupt handle works ok. My first try was the following that doesn't work:
In the second code the Interrupt 'lineswitch' was added at the end with an ElseIf but it doesn't work
I thing the last interrupt handle should also work ok. That is the reason for the question how many If....ElseIf... statements can I use. Is there a limit? (Maybe I have made a little misstake, that I myself can't find!?)
Please help.
Reguards,
CS
I hope that everyone have had a very nice christmas. After a long time of testing I found something, that makes me confused. Please have a look at the following code:
Code: Select all
interrupt OnChange()
If LineSwitch Then
LineSwitch = false
Toggle(PORTE.2)
If DLine = 0 Then
DLine = 1
Else
DLine = 0
End If
End If
If Setup Then
Setup = false
SpecialMessage = false
Button.Timeout = btnTimeout
Button.Debounce = btnDebounce
ElseIf TMR0IF Then
TMR0IF = false
TMR0 = TMR0 + Word(ReloadTimerValue)
If Button.Debounce > 0 Then
Dec(Button.Debounce)
ElseIf PORTB.1 = 1 Then
Button.Timeout = 0
SetupAktiv = false
ElseIf Button.Timeout > 0 Then
Dec(Button.Timeout)
If Button.Timeout = 0 Then
SetupAktiv = true
EndIf
EndIf
ElseIf Extern Then
'check kind of message
Extern = false
SpecialMessage = true
High(PORTE.0)
EndIf
Code: Select all
If Setup Then
Setup = false
SpecialMessage = false
Button.Timeout = btnTimeout
Button.Debounce = btnDebounce
ElseIf TMR0IF Then
TMR0IF = false
TMR0 = TMR0 + Word(ReloadTimerValue)
If Button.Debounce > 0 Then
Dec(Button.Debounce)
ElseIf PORTB.1 = 1 Then
Button.Timeout = 0
SetupAktiv = false
ElseIf Button.Timeout > 0 Then
Dec(Button.Timeout)
If Button.Timeout = 0 Then
SetupAktiv = true
EndIf
EndIf
ElseIf Extern Then
'check kind of message
Extern = false
SpecialMessage = true
High(PORTE.0)
ElseIf lineswitch Then
lineswitch = false
toggle(porte.2)
If dline = 0 Then
dline = 1
Else
dline = 0
End If
EndIf
I thing the last interrupt handle should also work ok. That is the reason for the question how many If....ElseIf... statements can I use. Is there a limit? (Maybe I have made a little misstake, that I myself can't find!?)
Please help.
Reguards,
CS