would this be a place for select case?
You could, but it just uses more code space. It's pretty much a Select Case the way the last example is shown. But here's a Select Case version...
Code:
combo:
Select CASE combocount
Case 0 : if ByteA = 7 then GoodKey
Case 1 : if ByteA = 8 then GoodKey
Case 2 : if ByteA = "A" then GoodKey
Case 3 : if ByteA = 5 then GoodKey
Case 4 : if ByteA = "D" then GoodKey
END SELECT
combocount = 0
return
GoodKey:
combocount = combocount + 1
if combocount = 5 then GrantAccess
return
Or, just to keep things nice and confusing, you could also do this...
Code:
Combo:
Lookup combocount,[7,8,"A",5,"D"], NextDigit
if ByteA = NextDigit then
combocount = combocount + 1
if combocount = 5 then GrantAccess
else
combocount = 0
endif
return
It seems as though the THEN Goodkey scenerio would make the combination work if out of sequence?
Nope, that can't happen. You should run the program in MCSP debugger and watch what happens. After watching debuggers for awhile, you'll be able to see it in your mind, and programming will go a lot smoother. And eventually, you won't even need the debugger anymore, or the PIC. It'll run inside your head.
Oh your code works SWEET! Thanks Again.
No Problemo!
Bookmarks