I would like to construct strings based on parameter inputs.
I want to make a function that adds null frames. So something like this:
This would translate in the function likeCode:FillGap(source, blank, "118,4;503,2,1100,2")
I'm not sure whether this is possible in avisynth scripting. I use this heavily to sync audio from one video to another. Later on I would add an option for minus integers so I can trim out video.Code:prune(source,blank,scmd="0(0,118);1(119,122);0(123,502);1(503,505);0(506,1099);1(1100,1102)")
+ Reply to Thread
Results 1 to 8 of 8
-
-
http://avisynth.nl/index.php/Internal_functions#String_functions
Of course it's possible, and if the internal string functions aren't enough for you, you can write your own plugin using c++.
Is what you're really asking is if anyone wants to write a function to do it for you? -
How? In avisynth language.
-
Astring = "118,4;503,2,1100,2"
cpos = FindStr(Astring,",")
will give you the position of the first comma.
snum = LeftStr(Astring, cpos)
will give you the first number
dstring = RightString(Astring, cpos + 1)
will remove the number from the string.
Then you just need to write a recursive function that calls itself...Last edited by ndjamena; 15th Feb 2015 at 09:12.
-
What's RightString()? you mean RightStr()? it does nothing more than return the last 4 digits "00,2"(because the first found "," is in 4th position as cpos).
I guess one could do a mix of StrLen and cpos, to get the remaining string.
This is the easy part, the recursive function is the core of the issue, I guess I need to rely on things like Gscript or such? -
Yup, sorry, don't care so I'm not paying attention.
function Recurse( string s )
{
return s.Recurse
}
That will circle forever, generally you add a check to see if it needs to continue, if it doesn't you just don't call the function in the current return statement.
-edit-
and before you ask:
http://avisynth.nl/index.php/Operators
return dstring == "" ? newstring : newstring.Recurse -
I just got the building block, here I can get both values; I only need the recursive function:
Code:function FillStr(string Astring){ cpos = FindStr(Astring,";") str = LeftStr(Astring, cpos-1) sstr=FindStr(str,",") L1 = LeftStr(str,sstr-1) R1 = MidStr(str,sstr+1) # prune(a,b,scmd="0(0,15308);") #2nd pass Astring1=MidStr(Astring,cpos+1) return Astring1 == "" ? Astring1 : FillStr(Astring1)}
Another untackled bit is how you are supposed to do the operations. I need to operate with the numbers to build the prune call. I was searching but I don't see any string to value function. Are you sure this is doable in avisynth?Last edited by Dogway; 15th Feb 2015 at 13:37.
-
Value(string)
Its' in the conversion functions:
http://avisynth.nl/index.php/Internal_functions#Conversion_functions
And you can concatenate strings using an addition '+' operator:
http://avisynth.nl/index.php/Operators