None of the above.
It's because it's the Wrong Logic for the job.
With an
IF ELSE ENDIF, there are only 2 possibilities.
True or False.
And that result is based entirely on 1 expression ... (ByteA = 7) and (combocount=0)
So essentially, you're asking it if the Whole combination is correct, by looking at just one keypress.
Then by stacking up 5
IF ELSE ENDIF's together, since they can't ALL be true at the same time, there will always be 4 of them saying the combination is Wrong.
Much like in real life, decisions aren't always as easy as True or False.
Usually, you'll have to consider several different things Before making a decision.
And those "things" may happen at different times, so you may not be able to make a decision until more information is available.
So instead of just the
True or False, Black or White. Here's the answer.
You also need to be able to say
"I don't know yet".
This is where just
IF THEN is more useful.
Instead of only the 2 possibilities,
IF THEN has Infinite possibilities.
Granted, It's either TRUE, or it's NOT, but by
not taking action when it's
not true, it's the same as saying "I don't know".
So now you can stack those up if you want, because they won't be interfering with each other by making their own decisions independently.
They only act on what they KNOW to be TRUE.
Here's what I mean...Still not the way I would do it, but for the sake of argument...
Code:
combo:
IF (combocount = 0) and (ByteA = 7) then GoodKey
IF (combocount = 1) and (ByteA = 8) then GoodKey
IF (combocount = 2) and (ByteA = "A") then GoodKey
IF (combocount = 3) and (ByteA = 5) then GoodKey
IF (combocount = 4) and (ByteA = "D") then GoodKey
combocount = 0 ; invalid keypress
return
GoodKey:
combocount = combocount + 1
if combocount = 5 then GrantAccess
return
Bookmarks