Log in

View Full Version : Syntax Q - filter args as a variable


DDogg
6th March 2003, 21:18
Is it possible to use variables with internal quotes as a filter argument?

If this works:

LoadPlugin("Convolution3D.dll")
avisource("Clip 001.avi").ConvertToYV12().Convolution3d(preset="movieHQ")
Why would not this work? (it gives a "there is no function named "cvl")

LoadPlugin("Convolution3D.dll")
cvl="Convolution3d(preset=``movieHQ'')"
avisource("Tape 1 - Clip 001.avi").ConvertToYV12().cvl

sh0dan
6th March 2003, 23:37
Use Eval(string). From the docs:

You can use Eval for something like:

settings = "352, 288"
Eval( "BicubicResize(" + settings + ")" )

DDogg
7th March 2003, 00:59
Thanks for your reply. I tried many variations of that before wasting your time. Would you be kind enough to verify if TEX style quotes are broken in avisynth? I am becoming suspicious they may be. If not, I certainly cannot figure out how to use eval (it has never made sense to me). The following give a "unexpected character "'" :

s1="preset= "``moviehq''"
avisource("Tape 1 - Clip 001.avi").ConvertToYV12()
eval("Convolution3d(" + s1 +")")

Guest
7th March 2003, 01:05
Your s1= line does not have matching quotes. There are 3 " marks (odd number).

DDogg
7th March 2003, 01:12
Sharp eyed one, how is India? I think that was just a typo when I posted. Same error with this:

s1="preset= ``moviehq''"
avisource("Tape 1 - Clip 001.avi").ConvertToYV12()
eval("Convolution3d(" + s1 +")")

Guest
7th March 2003, 01:21
Now you've got me. Can't do any testing because this is not my PC. I'm sure the great sh0dan will come through for you. Try building up the eval string a step at a time and see if the results shed further light.

India is great, but the 90 deg F temp swing got me sick for a week. And it snowed 8 inches back home so every burglar in town knows my house is empty. Got a shovel? :(

DDogg
7th March 2003, 01:43
Ah HA! The tex style is broken or my use of the back quote (Non shifted tilde key) was incorrect. This subtitle line below showed the `` were not being replaced with ". (add: Maybe it would not show the replacement until the eval command?) I would be 100% sure of that if the script below would now work but it will not.

LoadPlugin("Convolution3D.dll")
s1="preset=''moviehq''"
avisource("Tape 1 - Clip 001.avi").ConvertToYV12()
Blackness.Subtitle(s1)
#eval("Convolution3d(" + s1 +")")

Further, this will work just fine, so I think this quote thing is a bug that has not been noticed before:

LoadPlugin("Convolution3D.dll")
cvl="Convolution3d(0, 3, 4, 3, 4, 2.8, 0)"
avisource("Tape 1 - Clip 001.avi").ConvertToYV12()
eval(cvl)

Where as this will not work:

LoadPlugin("Convolution3D.dll")
cvl="Convolution3d(preset=''movieHQ'')" # or ``movieHQ''
avisource("Tape 1 - Clip 001.avi").ConvertToYV12()
eval(cvl)

DDogg
7th March 2003, 20:49
@sh0dan, I know these type of things are not your favorite, but I wonder if you could aknowledge whether you think this may be a bug in the core code. If it is a problem, then NIC does not need to waste his time (if/when he has the time to even look at it)on changing the quote handling mechanism in the CALL command. If it is not a problem, then just call me a dummy and give me a few more of your cryptic one line hints :p

sh0dan
7th March 2003, 20:59
@DDogg: I see the problem. I think the issue is, that the " is being reinterpreted so that the finished line looks like this:

Eval("Convolution3d(preset="movieHQ")") #when it should look like this:

Eval("Convolution3d(preset=''movieHQ'')")

I can't give you any workaround, and I don't have the faintest clue on how to solve it. :(

DDogg
7th March 2003, 21:26
Bummer. I guess that means it is a bug duly reported. I wonder if whoever added all the string functions in 2.07 would add the old chr$() That was always a last resort - oldanddead$="+chr$(34)+back in the old days+chr$(34)+". (or something like that, hehheh)

Edit: Sneaking back to change the 13 to a 34 :o

WarpEnterprises
7th March 2003, 22:39
Attached maybe the smallest possible AviSynth plugin creating just a global (i.e. being known in functions too) variable chr34 which is set to "


loadplugin("c:\myprojects\chr\release\chr.dll")
version()
subtitle(chr34)


[edit: attachement deleted]

DDogg
7th March 2003, 23:23
WarpEnterprises, hey, thanks! I'll give it a shot when the attachment is approved. Eh, while you are at it, how 'bout a TIME, DATE and DAY variable? Yes, I am a shameless man :---)

Mentioned here:http://forum.doom9.org/showthread.php?s=&threadid=47377

sh0dan
8th March 2003, 00:26
Originally posted by WarpEnterprises
Attached maybe the smallest possible AviSynth plugin creating just a global (i.e. being known in functions too) variable chr34 which is set to.
Would it be too to ask, for you to extend this to all ASCII characters? Just for the sake of completion?

Someone might also find a 2.5 version great ;)

bilu
8th March 2003, 00:43
This works:


a="Convolution3d(preset=''movieHQ'')"
Eval("Subtitle(a)")


This doesn't:


a="Convolution3d(preset=''movieHQ'')"
Eval(a)


Nothing except chr can do it? :confused:


Bilu

bilu
8th March 2003, 01:28
@Ddogg

Well, this works :)

function c3(clip c,string p) {
pr=Convolution3d(c,preset=p)
return pr
}

c3("movieHQ")

Bilu

DDogg
8th March 2003, 01:33
x-post < never mind
@WarpEnterprises Not being picky at all, it is just that I am right in the middle of a 2.5 project I am working on. It has got a little complex so I don't want to change to 2.07. Any chance of a 2.5? AS sh0dan said, I think it would be very helpful, especially with a full chr set.

bilu
8th March 2003, 01:38
Originally posted by DDogg
x-post


I was referring to a workaround on the initial problem :o


Bilu

DDogg
8th March 2003, 01:43
Sorry, I had posted a query to you before you brought up the work around. I was going to go back and edit when I had digested the function. I have a lot of trouble understanding them so it takes me a while :) I should have put "thinking" instead of x-post (meaning crossing post)

bilu
8th March 2003, 01:50
OK :)

a="movieHQ"
c3(a)

also works, is it what you were looking for? :)


Bilu

DDogg
8th March 2003, 02:07
Bilu, thanks for the workaround(s)

I was really just using the example of convolution because it used quotes in a sub-argument. Trying to put something like that within a variable is supposed to work (if my reading is correct) using the syntax a = "main(``stuff'')" . My understanding is eval(a) is supposed to replace the ``'' with "" so that avisynth sees the statement as: main("stuff"). This is really going to cause some grief for anybody trying to do complex variable manipulation. I hope it gets fixed, (I don't even know who is running that area). Workarounds will have to do until/if then.

WarpEnterprises
10th March 2003, 00:28
Look here:

CHR.DLL (http://www.avisynth.org/~warpenterprises/)

(has a CHR and a TIME function)

2.0 + 2.5

For the possible time formatting codes look into chr.cpp.

DDogg
10th March 2003, 06:50
WarpEnterprises, thanks so much! I look forward to giving this a try tomorrow and will report back the reults and some more examples.

WarpEnterprises
10th March 2003, 08:28
Forgot to emphasize: the time is of course the LOAD TIME of the script (it cannot be used to imprint e.g. the current time on a video from start to the end, this would have to be done by a completely different function)

DDogg
11th March 2003, 02:53
WarpEnterprises, those time functions in chr really work well and are very comprehensive and thought out. Thanks!
http://forum.doom9.org/showthread.php?s=&postid=276597#post276597
Note: I do understand it is the start time. I used it in the script as a place holder until I can figure out how to get the end time.