Dynamically updating counter for distance to object

Hello I am a complete beginner at scripting and need help to make a script that does the following:

I have a camera animated with path constraint and there are light signals along this path. I need a countertext to become visible as I come within a certain distance of this signal (say 300meters) and then start counting down until the camera has passed the signal. The text should then dissapear until the next signal comes within range.

This is what I got right now in a scriptcontroller in the text objects kerning controller:

SCRIPT START

----------------------------------------------------------------------------------------------------------------------------------------------

SignalGroup = selection as array     -- put groupe of signal helpers in an array(each helper is a signal along the anim path)
signalfound = false             -- has a signal within range been found?
signalpass = false             --declare var (cam has passed signal to false)
$test.visibility = off            -- set counter text invisible

for i = 1 to SignalGroup.count do      -- go through entire group of singalhelpers to see which one is in range
(                     -- start for loop    
dist = distance SignalGroup[i] cam             -- compute distance between signal and camera
distlast = at time (F-1) distance SignalGroup[i] cam    --get distance to signal from previous frame                
if (dist > distlast) do
(                 -- check if distance to signal is starting to increase then set...
signalpass = true
)

if (dist <= 300 and signalpass==false) do     -- test if selected signal node is 300m or less AND distance to it is decreasing
(
signalfound = true
$test.visibility = on                -- set text object to visible
$test.text = ("Avstand til signal: ") +  int(dist)  as String + (" Meter")    --display distance to approaching signal as whole numbers
)
)--while signalfound
0

 ---------------------------------------------------------------------------------------------------------

SCRIPT END

Currently the counter is only showing the distance for the first object in the group and then stops.

Also if I add a EXTRUDE modifier on the text it goes all haywire and slow...

Any help will be greatly appreciated!

Feel free to laugh at my feeble attempts scripting as I really don't even know the very basics of it. Just laugh with me and not at me :P