View Single Post
Old 27th October 2013, 18:03   #11  |  Link
Gavino
Avisynth language lover
 
Join Date: Dec 2007
Location: Spain
Posts: 3,431
Quote:
Originally Posted by martin53 View Post
To stay indeppendent from number of instances, maybe better style to define inside RTE, after check that they're undefined:
Code:
GScriptClip("""
    ...
    try { __ = RTE_myVar%%%%%% } catch(err) { global RTE_myVar%%%%%% = 0 }
    ...
    first use of RTE_myVar%%%%%% in RTE
    ...
""", local=true)
An alternative would be to initialise in the function, but outside the RTE, avoiding a try/catch on each frame.
Code:
Eval("global RTE_myVar"+string(RTE_InstanceNumber)+"=0")
Both approaches are a bit ugly!

If staying with the try/catch approach, note the assignment to __ is unnecessary:
Code:
    try { RTE_myVar%%%%%% } catch(err) { global RTE_myVar%%%%%% = 0 }
__________________
GScript and GRunT - complex Avisynth scripting made easier
Gavino is offline   Reply With Quote