Log in

View Full Version : FindStr enhancement


dosdan
19th August 2005, 01:12
The string handling in AviSynth appears pretty limitied. I want to bring a variable number of filenames into a function as a single string and then use string manipulation to separate them. For example:

LoadPhotoSequence("01,02,05,07")

The problem is that FindStr has no offset capability. I can find the first "," but not the second without chopping off the first term with MidStr. Would it be possibe to to enhance FindStr from its current:

FindStr (string1, string2)

to either:

FindStr (string1, string2, [offset])

offset for the start position in string1 for the search for string2

or:
Findstr (string1, string2, [occurance])

where an occurance value of 4 would find the fourth occurance of string2 and return 0 if it was not found.

mg262
19th August 2005, 19:48
For the first, you can wrap the MidStr (or better, RightStr) and the Find call in a script function to create something that behaves as you want and is essentially indistinguishable from a built-in function.

For the second, it is also possible, by making the function call itself -- so Findstr (string1, string2, 4) either returns 0 (if it finds can't find the string at all) or calls Findstr(trimmed-string1, string2, 3) if it can. [trimmed-string1 would again be produced by using RightStr to chop off the first found instance of string2 and everything before it.] I'm not one of the resident script wizards, or I would try to cobble it together... but have a go yourself, and if you get stuck I am sure someone will help.

edit: also have a look at stickboys page,which has a whole host of interesting and useful aids to creating complex scripts.

Didée
20th August 2005, 01:25
Another proposal: a simple "Joker" character to be able to find pairs of necessary characters no matter what's inbetween them (e.g. to match "A°A" on "abAcAde", with '°' being the joker.)