View Single Post
Old 21st June 2008, 03:27   #15  |  Link
IanB
Avisynth Developer
 
Join Date: Jan 2003
Location: Melbourne, Australia
Posts: 3,167
@Gavino,

The programmatically better way to express your example :-
Code:
Function F(Clip, Current_Frame) {
  return Clip.Subtitle(String(Current_Frame))
}

ScriptClip("f(current_frame)")
Global variables generally are horrid and if you find yourself using them, then there probably is a better way to express the idea your are implementing. And I did say generally, very occasionally using a global variable can be the easier solution.

If you really have you heart set on a global var solution, do this:-
Code:
Function F(Clip) {
  return Clip.Subtitle(String(Current_Frame))
}

ScriptClip("Global Current_Frame=current_frame
f()")
@gzarkadas,

Performance is not that much of an issue here, ScriptClip, et el, all recompile the script string every frame so a few extra GetVar calls won't make a difference. If you are using ScriptClip then performance is already shot to hell, using it will generally be the result of a wrong thought process i.e. Linear (C) instead of Functional (AVS) thinking.
IanB is offline   Reply With Quote