Magnetic switch to mechanical counter

in BASIC Stamp
Hello!
I have two mechanical counters here, one uses 24v to click its armature to increment its displayed count. And the uses 12v to do the same thing. And also a collection of NC (Normally Closed) reed switches, and a collection of NO (Normally Open) switches as well. I'm brainstorming for a simple program that would wait for the switch to either open in the case of NC ones, or conversely close for the NO ones, and then cause a connected solid state relay to have one of the two, simply count.
It's the glue in the form of a BASIC program that has me peeved.
---
Mascot away.
I have two mechanical counters here, one uses 24v to click its armature to increment its displayed count. And the uses 12v to do the same thing. And also a collection of NC (Normally Closed) reed switches, and a collection of NO (Normally Open) switches as well. I'm brainstorming for a simple program that would wait for the switch to either open in the case of NC ones, or conversely close for the NO ones, and then cause a connected solid state relay to have one of the two, simply count.
It's the glue in the form of a BASIC program that has me peeved.
---
Mascot away.
Comments
This bit of code samples the inputs and waits for a change. By using XOR we can find the pins that changed state -- a "1" bit in delta tells us the corresponding input changed. By looking at the actual value in the last scan, we can respond to that input as required.
' {$STAMP BS2} ' {$PBASIC 2.5} oldState VAR Nib newState VAR Nib delta VAR Nib Setup: DIRA = %0000 ' all inputs oldState = INA Main: PAUSE 25 newState = INA IF newState = oldState THEN Main Change_Detected: delta = newState ^ oldState oldState = newState Process_Input0: IF delta.BIT0 = 1 THEN IF newState.BIT0 = 1 THEN ' normally-open input ' active ELSE ' released ENDIF ENDIF Process_Input1: IF delta.BIT1 = 1 THEN IF newState.BIT1 = 1 THEN ' normally-open input ' active ELSE ' released ENDIF ENDIF Process_Input2: IF delta.BIT2 = 1 THEN IF newState.BIT2 = 0 THEN ' normally-closed input ' active ELSE ' released ENDIF ENDIF Process_Input3: IF delta.BIT3 = 1 THEN IF newState.BIT3 = 0 THEN ' normally-closed input ' active ELSE ' released ENDIF ENDIF Clean_Up: GOTO Main