Log in

View Full Version : Deriving and calling function name from string


Emulgator
25th August 2022, 11:09
Parameterizing my cam preprocessing scripts.
Now the source filters. Arguments can be taken from strings, so this works nice

v=LWLibavVideoSource(String(Folder)+"\"+String(File)+String(vidext))
a=LWLibavAudioSource(String(Folder)+"\"+String(File)+String(audext))
This works too
v=Eval("""DGSource(String(Folder)+"\"+String(File)+String(vidext))""")
a=Eval("""LWLibavAudioSource(String(Folder)+"\"+String(File)+String(audext))""")


I would like to have sourcefilters parametrized also, so I am parsing and extracting the file extension frim script name,
assign a sourcefilter name string and hope to call the appropriate sourcefilter, something along the lines of:

v=(String(vidsrc)(String(Folder)+"\"+String(File)+String(vidext)))
a=(String(audsrc)(String(Folder)+"\"+String(File)+String(audext)))

But that won't work, with or without Eval()
Avisynth complains "Script error: 'string cannot be called. Give me a function!"

I am a bit stuck here...

P.S. Ah, so simple, found it. Apply() it is. Rarely seen in the wild...

v=Apply(vidsrc,String(Folder)+"\"+String(File)+String(vidext))
a=Apply(audsrc,String(Folder)+"\"+String(File)+String(audext))