Yeah, that's pretty much what you can expect when you can expect when using global variables. It's not a problem with ApplyRange.
You can think of script evaluation as being in two stages:
1. Script load.
2. Exuection/frame requests.
When the script is loaded, AviSynth parses the script, evaluates expressions, and creates the filter chains. This means that it calls the "flash" function three times when the script is loaded, before it ever requests a frame. By the time you request frames, your global variables have been set to their final values already.
(I really do not like this global variable business with ScriptClip/FrameEvalute/et al., but oh well.)
And none of that really helps you. Heh.
I suppose a possible workaround to try:
Code:
function flash(clip f, int "first", int "qty")
{
return ScriptClip(f, "first = " + String(first)
\ + "qty = " + String(qty)
\ + """x = FreezeFrame(...)
y = x.FreezeFrame(...)
...""")
}