Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion.

Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.

 

Go Back   Doom9's Forum > Capturing and Editing Video > Avisynth Usage

Reply
 
Thread Tools Search this Thread Display Modes
Old 4th February 2020, 16:42   #1  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
StrMatchDemo.avsi v1.00

Moved here from devs forum Avisynth+ thread.
No requirements, Except Groucho2004 SysInfo where indicated, OK in Avs v2.58.

Code:
# StrMatchDemo.avsi # https://forum.doom9.org/showthread.php?p=1898400
/*
    v1.01

    These 3 require Groucho2004 SysInfo v0.119+, otherwise no requirements.
        AvsVersionNumberString(Type=1)
        AvsVersionNumberPartNo(Type=1)
        IsAvsVerOrGreater(Type=1)
*/

# Handy stuff [No requirements]
Function SystemInfoVersion()      { try{v=SysInfoVersion}catch(msg){v=-1.0} v }   # v = -1.0, Groucho SysInfo not installed
Function RT_StatsVersion()        { try{v=RT_Version}catch(msg){v=-1.0} v }       # v = -1.0, RT_Stats not installed
Function GScriptExists()          { ret=false try{ GScript(123,42.0,false,"") } catch(msg){ret = FindStr(msg,"Invalid arguments")>=1 } Return ret }
Function FuncNameExists(String Fn){ Try{Eval(Fn+"()")B=True}catch(e){Assert(e.FindStr("syntax")==0,"FuncNameExists: Error in Function Name '"+Fn+"'")B=(e.FindStr("no function named")==0)}Return B}
###
Function IsAvs26()                { Return VersionNumber>=2.6}
Function IsAvsPlus()              { Return FindStr(VersionString,"AviSynth+")!=0||FindStr(VersionString," Neo")!=0 }
# Deprecated:
Function PlusBuildNumber()        { V=VersionString Off=(!IsAvsPlus)?0:FindStr(V,"(r") Return (Off==0)?0:V.MidStr(Off+2).Value.Int } # Avs+ & Neo, (More than 4 digits, Max 24 bit, ~16M)
Function AvsPlusVersionNumber()   { Return PlusBuildNumber }                   # Deprecated, Stub for AvsPlusBuildNumber()
Function IsAvsNeo()               { Return FindStr(VersionString," Neo")!=0 }  # Deprecated

######

# Return extent of string S [ie length from the beginning] that matches any character in Chars set of characters [Default case insignificant]. # StrMatchChrLen("1234.567abcd","0123456789.") = 8
Function StrMatchChrLen(String s,String Chars,Bool "Sig") {
    Function __StrMatchChrLen_LOW(String s,String Chars,int n) { c=s.MidStr(n+1,1) Return(c==""||Chars.FindStr(c)==0) ? n : s.__StrMatchChrLen_LOW(Chars,n+1) }
    Sig=Default(Sig,False)  # Default Case Insignificant
    s=(Sig)?s:s.UCASE   Chars=(Sig)?Chars:Chars.UCASE
    __StrMatchChrLen_LOW(s,Chars,0)
}

# Return extent of string S [ie length from the beginning] that DOES NOT match any character in Chars set of characters [Default case insignificant].
#                                                                                                                        # StrBrkChrLen("1234.567,abcd",",.")  = 4
# If 1st character of s matches any in Chars set, then returns 0.                                                        # StrBrkChrLen("1234.567,abcd","321") = 0
# If no characters in s match any character in Chars set, then returns length of string s.                               # StrBrkChrLen("1234.567,abcd","NOP") = 13
Function StrBrkChrLen(String s,String Chars,Bool "Sig") {
    Function __StrBrkChrLen_LOW(String s,String Chars,int n) {c=s.MidStr(n+1,1) Return(c==""||Chars.FindStr(c)!=0)?n:s.__StrBrkChrLen_LOW(Chars,n+1)}
    Sig=Default(Sig,False)  # Default Case Insignificant
    s=(Sig)?s:s.UCASE   Chars=(Sig)?Chars:Chars.UCASE
    __StrBrkChrLen_LOW(s,Chars,0)
}

Function AvsVersionNumberString(Int "Type") {
/*
    Returns a version string guaranteed 4 dot separated number parts, eg "3.5.2" would return "3.5.2.0"
    Type = Default 0. : Range -1, or 0, or 1, Source TYPE for Version, ie where to obtain source version string.
      -1 = RAW VersionString, eg from "AviSynth 2.58, build:Dec 22 2008 [08:46:51]" would return "2.58" with ".0.0" appended, ie "2.58.0.0".
       0 = VersionString with KLUDGE eg "2.58" -> "2.5.8.0" (Default) :: Kludge, If Parts 3 & 4 both "" and StrLen(Part2) > 1 Then Shift single digit into part3
       1 = SysInfo:AI_AvsProductVersion eg "2.5.8.5" [As shown in Avisynth.dll file Properties dialog box] ::: Requires Groucho SysInfo.
*/
    myName="AvsVersionNumberString: "
    Type=Default(Type,0)                      # Default is version number from VersionString
    Assert(-1 <= Type <= 1,myName+"0 <= Type <= 1 ("+String(Type,"%.f")+")")
    Assert(Type<1 || SystemInfoVersion>=0.121,myName+"Groucho2004 SysInfo v0.121+ required")
    s = (Type<=0) ? VersionString : AI_AvsProductVersion
    s = (Type<=0) ? s.MidStr(s.StrBrkChrLen("0123456789.",True)+1)  : s
    s = (Type<=0) ? s.LeftStr(s.StrMatchChrLen("0123456789.",True)) : s
    d=s.FindStr(".") n1=(d==0)?s:s.LeftStr(d-1) s=(d==0)?"":s.MidStr(d+1)
    d=s.FindStr(".") n2=(d==0)?s:s.LeftStr(d-1) s=(d==0)?"":s.MidStr(d+1)
    d=s.FindStr(".") n3=(d==0)?s:s.LeftStr(d-1) s=(d==0)?"":s.MidStr(d+1)
    d=s.FindStr(".") n4=(d==0)?s:s.LeftStr(d-1)
    # KLUDGE: If Type==0 and Parts 3 & 4 both "" and StrLen(Part2) > 1 Then Shift single digit into part3
    Shift1=(Type==0) && (n3==""&&n4=="") && (n2.StrLen>1)
    n3=(Shift1)?n2.RightStr(1):n3
    n2=(Shift1)?n2.LeftStr(n2.StrLen-1):n2
    # END KLUDGE
    (n1==""?"0":n1) + "." + (n2==""?"0":n2) + "." + (n3==""?"0":n3) + "." + (n4==""?"0":n4)
}

Function AvsVersionNumberPartNo(int PartNo, Int "Type") {
/*
    Return a single version Part Number as Int, Source version obtained from AvsVersionNumberString(type=Type). [where source is in 4 parts, eg "1.2.3.4"]
    PartNo=1->4. 1=MAJOR version: 2=MINOR version : 3=Part3 version : 4=Part4 version
    Type = Default 0. : Range -1, or 0, or 1, Source TYPE for Version, ie where to obtain source version string.
      -1 = RAW VersionString, eg from "AviSynth 2.58, build:Dec 22 2008 [08:46:51]" would return "2.58" with ".0.0" appended, ie "2.58.0.0".
       0 = VersionString with KLUDGE eg "2.58" -> "2.5.8.0" (Default) :: Kludge, If Parts 3 & 4 both "" and StrLen(Part2) > 1 Then Shift single digit into part3
       1 = SysInfo:AI_AvsProductVersion eg "2.5.8.5" [As shown in Avisynth.dll file Properties dialog box] ::: Requires Groucho SysInfo.
*/
    PartNo=Min(Max(PartNo,1),4)             # Limit Range 1->4
    s=AvsVersionNumberString(Type)          # eg "1.2.3.4", guaranteed 4 dot separated digit strings.
    d=s.FindStr(".") n1=s.LeftStr(d-1) s=s.MidStr(d+1)  d=s.FindStr(".") n2=s.LeftStr(d-1) s=s.MidStr(d+1)
    d=s.FindStr(".") n3=s.LeftStr(d-1) n4=s.MidStr(d+1)
    Return ((PartNo==1)?n1:(PartNo==2)?n2:(PartNo==3)?n3:n4).Eval
}

Function IsAvsVerOrGreater(int a,int "b",int "c",int "d", Int "Type") {
/*
    Test and return true if current version of avisynth is at least as high as your required minimum version part numbers.
        eg IsAvsVerOrGreater(3,5,2,0,Type=1) returns true if Avisynth version by dll resource string(ie Type=1) is at least "3.5.2.0".
    a,b,c and d, Your required minimum part numbers [b, c and d all default 0].
    Type = Default 0. : Range -1, or 0, or 1, Source TYPE for Version, ie where to obtain source version string.
      -1 = RAW VersionString, eg from "AviSynth 2.58, build:Dec 22 2008 [08:46:51]" would return "2.58" with ".0.0" appended, ie "2.58.0.0".
       0 = VersionString with KLUDGE eg "2.58" -> "2.5.8.0" (Default) :: Kludge, If Parts 3 & 4 both "" and StrLen(Part2) > 1 Then Shift single digit into part3
       1 = SysInfo:AI_AvsProductVersion eg "2.5.8.5" [As shown in Avisynth.dll file Properties dialog box] ::: Requires Groucho SysInfo.
*/
    b=Default(b,0)  c=Default(c,0)  d=Default(d,0)
    aa=AvsVersionNumberPartNo(1, Type)    bb=AvsVersionNumberPartNo(2, Type)
    cc=AvsVersionNumberPartNo(3, Type)    dd=AvsVersionNumberPartNo(4, Type)
    return (aa>a) || (aa==a && (bb>b || (bb==b && (cc>c || (cc==c && dd>=d)))))
}

################## NON VERSION DEMO STUFF ##################

# Return leading string from S that matches any character in Chars set of characters [Default case insignificant ].      # StrMatchChr("1234.567abcd","0123456789.") = "1234.567"
# If There are no characters matching Chars set, then returns empty string "".                                           # StrMatchChr("123456789","ABCDEFGH")       = ""
# If all characters in s match any in Chars set, then returns original string s.                                         # StrMatchChr("abcdefgh","HGFEDCBA")        = "abcdefgh"
Function StrMatchChr(String s,String Chars,Bool "Sig") { Return s.LeftStr(s.StrMatchChrLen(Chars,Sig))}

# Remove/Eat leading string from S that matches any character in Chars set of characters [Default case insignificant].   # StrEatChr("123abcxyz","a1b2c3")  = "xyz"
# If There are no characters matching Chars set, then returns original string s.                                         # StrEatChr("123abcxyz","QPR")     = "123abcxyz"
# If all characters in s match any in Chars set, then returns empty string "".                                           # StrEatChr("123abc","abc321")     = ""
Function StrEatChr(String s,String Chars,Bool "Sig")   { Return s.MidStr(s.StrMatchChrLen(Chars,Sig)+1) }

# Below, case insignificant where Alpha chars involved, else Significant where eg ALL non Alpha matching. [Roll your own if you want different]
Function StrMatchWhite(String s)    { Return s.StrMatchChr(" "+Chr(8)+Chr(9)+Chr(10)+Chr(11)+Chr(12)+Chr(13),true) }     # StrMatchWhite("   543")            = "   "        # (SPC, BackSPC, TAB, LF, VT, FF, CR)
Function StrMatchDigits(String s)   { Return s.StrMatchChr("0123456789",true) }                                          # StrMatchDigits("123.0adomoakad")   = "123"
Function StrMatchHex(String s)      { Return s.StrMatchChr("0123456789ABCDEF") }                                         # StrMatchHex("123adomoakad")        = "123ad"
Function StrMatchAlpha(String s)    { Return s.StrMatchChr("ABCDEFGHIJKLMNOPQRSTUVWXYZ") }                               # StrMatchAlpha("adomoakad123")      = "adomoakad"
Function StrMatchAlpNum(String s)   { Return s.StrMatchChr("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ") }                     # StrMatchAlpNum("123abc;!&*")       = "123abc"
Function StrMatchDigitDot(String s) { Return s.StrMatchChr("0123456789.",true) }                                         # StrMatchDigitDot("123.456.789ABC") = "123.456.789"

Function StrMatchInt(String s)    {                                                                                      # StrMatchInt("123.456.789")         = "123"
    c=s.MidStr(1,1)  HasSign=(c=="-"||c=="+") s=(HasSign)?s.MidStr(2):s c=(HasSign)?c:""
    w=s.StrMatchChr(Chr(32)+Chr(9),True)  s=(w=="")?s:s.MidStr(w.StrLen+1)
    s=s.StrMatchDigits
    d=s.FindStr(".") n=(d==0)?s:s.LeftStr(d) s=(d==0)?"":s.MidStr(d+1)
    d=s.FindStr(".") n=n+((d==0)?s:s.LeftStr(d-1)) return c+w+n
}

Function StrMatchFloat(String s)    {                                                                                    # StrMatchFloat("123.456.789")       = "123.456"    # Match single dot only eg
    c=s.MidStr(1,1)  HasSign=(c=="-"||c=="+") s=(HasSign)?s.MidStr(2):s c=(HasSign)?c:""
    w=s.StrMatchChr(Chr(32)+Chr(9),True)  s=(w=="")?s:s.MidStr(w.StrLen+1)
    s=s.StrMatchDigitDot
    d=s.FindStr(".") n=(d==0)?s:s.LeftStr(d) s=(d==0)?"":s.MidStr(d+1)
    d=s.FindStr(".") n=n+((d==0)?s:s.LeftStr(d-1)) return c+w+n
}

# Match Variable OR Function name ('_' or Alpha for first character, thereafter additionaly digits, alway case Insignificant).
Function StrMatchVarName(String s) {                                                                                     # StrMatchVarName("_My_FuncName66><!ds") = "_My_FuncName66"
    c=s.MidStr(1,1)
    return (c>="0" && c<="9")?"": s.LeftStr(s.StrMatchChrLen("_ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"))  # If first char is digit, then NOT Valid Variable name(force fail).
}

# Below, case insignificant where Alpha chars involved, else Significant where eg ALL non Alpha matching. [Roll your own if you want different]
Function StrEatWhite(String s)     { Return s.MidStr(s.StrMatchWhite.StrLen+1)     }                                     # StrEatWhite("   "+Chr(10)+"543") = "543" # (SPC, BackSPC, TAB, LF, VT, FF, CR)
Function StrEatDigits(String s)    { Return s.MidStr(s.StrMatchDigits.StrLen+1)    }                                     # StrEatDigits("543abc")           = "abc"
Function StrEatHex(String s)       { Return s.MidStr(s.StrMatchHex.StrLen+1)       }                                     # StrEatHex("abc321xyz")           = "xyz"
Function StrEatAlpha(String s)     { Return s.MidStr(s.StrMatchAlpha.StrLen+1)     }                                     # StrEatAlpha("xyz321!&*")         = "321!&*"
Function StrEatAlpNum(String s)    { Return s.MidStr(s.StrMatchAlpnum.StrLen+1)    }                                     # StrEatAlpNum("abc321!&*")        = "!&*"
Function StrEatDigitDot(String s)  { Return s.MidStr(s.StrMatchDigitDote.StrLen+1) }                                     # StrEatDigitDot("32.1.2.3.4ABC")  = "ABC"
Function StrEatInt(String s)       { Return s.MidStr(s.StrMatchInt.StrLen+1)       }                                     # StrEatInt("-123.456.789")        = ".456.789"
Function StrEatFloat(String s)     { Return s.MidStr(s.StrMatchFloat.StrLen+1)     }                                     # StrEatFloat("-123.456.789")      = ".789"
Function StrEatVarName(String s)   { Return s.MidStr(s.StrMatchVarName.StrLen+1)   }                                     # StrEatVarName("_My_FuncName66><!ds") = "><!ds"

############

# Return leading string from s that DOES NOT match any character in Chars set of characters [case insignificant].        # StrBrkChr("12.34:567;abcd",",:;")  = "12.34"
# If 1st character of s matches any in Chars set, then returns empty string "".                                          # StrBrkChr("12.34:567;abcd","321")  = ""
# If no character of s matches any in Chars set, then returns original string s.                                         # StrBrkChr("12.34:567;abcd","PON")  = "12.34:567;abcd"
Function StrBrkChr(String s,String Chars,Bool "Sig")  { return s.LeftStr(s.StrBrkChrLen(Chars,Sig)) }

# Remove/Eat leading string from S that DOES NOT match any character in Chars set of characters [Default case insig].    # StrEatTillChr("12.34:567;abcd",",:;")  = ":567;abcd"
# If 1st character of s matches any in Chars set, then returns original string s.                                        # StrEatTillChr("12.34:567;abcd","321")  = "12.34:567;abcd"
# If There are no characters matching Chars set, then returns empty string "".                                           # StrEatTillChr("12.34:567;abcd","PON")  = ""
Function StrEatTillChr(String s,String Chars,Bool "Sig") { Return s.MidStr(s.StrBrkChrLen(Chars,Sig)+1) }
Updated
__________________
I sometimes post sober.
StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace

"Some infinities are bigger than other infinities", but how many of them are infinitely bigger ???

Last edited by StainlessS; 4th May 2020 at 04:15.
StainlessS is offline   Reply With Quote
Old 2nd May 2020, 12:56   #2  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
Post #1 updated, client moved here [post too big]

StrMatchDemo_Client.avs
Code:
#import("StrMatchDemo.avsi")
######################################
###    UnComment ONE of Below     ####
######################################
###
#s=StrMatchChrLen("1234.567abcd","0123456789.")    # = 8
#s=StrMatchChrLen("1234.567abcd","")               # = 0  ## BUG CHK: Nul length Chars
#s=StrMatchChrLen("","0123456789.")                # = 0  ## BUG CHK: Nul length S
#s=StrMatchChrLen("","")                           # = 0  ## BUG CHK: Nul length S & Chars
#
#s=StrBrkChrLen("1234.567,abcd",",.")              # = 4
#s=StrBrkChrLen("1234.567,abcd","321")             # = 0
#s=StrBrkChrLen("1234.567,abcd","NOP")             # = 13
#s=StrBrkChrLen("1234.567,abcd","")                # = 13  ## BUG CHK: Nul length Chars
#s=StrBrkChrLen("","123")                          # = 0   ## BUG CHK: Nul length S
#s=StrBrkChrLen("","")                             # = 0   ## BUG CHK: Nul length S & Chars
###
#s=PlusBuildNumber                                 # = 2983 for Avs+ 3.4
s=AvsVersionNumberString                          # = 3.5.2.0 for current Avs+ 3.5.2 [From VersionString]
#s=AvsVersionNumberString(Type=1)                  # = 3.5.2.0 for current Avs+ 3.5.2 [From SysInfo::AI_AvsProductVersion]
#s=AvsVersionNumberPartNo(1)                       # = 3 for current Avs+ 3.5.2 [From VersionString]
#s=AvsVersionNumberPartNo(2)                       # = 5 for current Avs+ 3.5.2 [From VersionString]
#s=AvsVersionNumberPartNo(3)                       # = 2 for current Avs+ 3.5.2 [From VersionString]
#s=AvsVersionNumberPartNo(4)                       # = 0 for current Avs+ 3.5.2 [From VersionString]
#s=AvsVersionNumberPartNo(1,Type=1)                # = 3 for current Avs+ 3.5.2 [From SysInfo::AI_AvsProductVersion]
#s=AvsVersionNumberPartNo(2,Type=1)                # = 5 for current Avs+ 3.5.2 [From SysInfo::AI_AvsProductVersion]
#s=AvsVersionNumberPartNo(3,Type=1)                # = 2 for current Avs+ 3.5.2 [From SysInfo::AI_AvsProductVersion]
#s=AvsVersionNumberPartNo(4,Type=1)                # = 0 for current Avs+ 3.5.2 [From SysInfo::AI_AvsProductVersion]
#s=IsAvsVerOrGreater(3,5)                          # = True, for current Avs+ 3.5 [From VersionString]
#s=IsAvsVerOrGreater(3,5,Type=1)                   # = True, for current Avs+ 3.5 [From SysInfo::AI_AvsProductVersion]
#s=IsAvsVerOrGreater(10,0,0)                       # = False, for Avs+ 10.0.0, not yet implemented. [From VersionString]
#s=IsAvsVerOrGreater(10,0,0,Type=1)                # = False, for Avs+ 10.0.0, not yet implemented. [From SysInfo::AI_AvsProductVersion]

##################
### DEMO MATCH
#s=StrMatchChr("1234.567abcd","0123456789.")       # = "1234.567"
#s=StrMatchChr("123456789","ABCDEFGH")             # = ""
#s=StrMatchChr("abcdefgh","HGFEDCBA")              # = "abcdefgh"
#s=StrMatchChr("1234.567abcd","")                  # = ""  ## BUG CHK: Nul length Chars
#s=StrMatchChr("","0123456789")                    # = ""  ## BUG CHK: Nul length S
#s=StrMatchChr("","")                              # = ""  ## BUG CHK: Nul length S & Chars
#
#s=StrMatchWhite("   543")                         # = "   "
#s=StrMatchDigits("123.0adomoakad")                # = "123"
#s=StrMatchHex("123adomoakad")                     # = "123ad"
#s=StrMatchAlpha("adomoakad123")                   # = "adomoakad"
#s=StrMatchAlpNum("123abc;!&*")                    # = "123abc"
#s=StrMatchDigitDot("123.456.789ABC")              # = "123.456.789"
#s=StrMatchInt("123.456.789")                      # = "123"
#s=StrMatchInt("- 123.456.789")                    # = "- 123"
#s=StrMatchInt("+ 123.456.789")                    # = "+ 123"
#s=StrMatchFloat("123.456.789")                    # = "123.456"
#s=StrMatchFloat("- 123.456.789")                  # = "- 123.456"
#s=StrMatchFloat("+ 123.456.789")                  # = "+ 123.456"
#s=StrMatchVarName("_My_FuncName66><!ds")          # = "_My_FuncName66"
#s=StrMatchVarName("_My FuncName66><!ds")          # = "_My"
#s=StrMatchVarName("9My_Func")                     # = ""
#
#s=StrEatChr("123abcxyz","a1b2c3")                 # = "xyz"
#s=StrEatChr("123abcxyz","QPR")                    # = "123abcxyz"
#s=StrEatChr("123abc","abc321")                    # = ""
#s=StrEatChr("123abcxyz","")                       # = "123abcxyz"  ## BUG CHK: Nul length Chars
#s=StrEatChr("","a1b2c3")                          # = ""           ## BUG CHK: Nul length S
#s=StrEatChr("","")                                # = ""           ## BUG CHK: Nul length S & Chars
#
#s=StrEatWhite("   "+Chr(10)+"543")                # = "543"
#s=StrEatDigits("543abc")                          # = "abc"
#s=StrEatHex("abc321xyz")                          # = "xyz"
#s=StrEatAlpha("xyz321!&*")                        # = "321!&*"
#s=StrEatAlpNum("abc321!&*")                       # = "!&*"
#s=StrEatDigitDot("32.1.2.3.4ABC")                 # = "ABC"
#s=StrEatInt("-123.456.789")                       # = ".456.789"
#s=StrEatInt("+ 123.456.789")                      # = ".456.789"
#s=StrEatFloat("-123.456.789")                     # = ".789"
#s=StrEatFloat("+ 123.456.789")                    # = ".789"
#s=StrEatVarName("_My_FuncName66><!ds")            # = "><!ds"
#s=StrEatVarName("_My FuncName66><!ds")            # = " FuncName66><!ds"
#s=StrEatVarName("9My_Func")                       # = "9My_Func"
###  DEMO BRK
#s=StrBrkChr("12.34:567;abcd",",:;")               # = "12.34"
#s=StrBrkChr("12.34:567;abcd","321")               # = ""
#s=StrBrkChr("12.34:567;abcd","PON")               # = "12.34:567;abcd"
#s=StrBrkChr("1234.567,abcd","")                   # = "1234.567,abcd"    ## BUG CHK: Nul length Chars
#s=StrBrkChr("","123")                             # = ""                 ## BUG CHK: Nul length S
#s=StrBrkChr("","")                                # = ""                 ## BUG CHK: Nul length S & Chars
#
#s=StrEatTillChr("12.34:567;abcd",",:;")           # = ":567;abcd"
#s=StrEatTillChr("12.34:567;abcd","321")           # = "12.34:567;abcd"
#s=StrEatTillChr("12.34:567;abcd","PON")           # = ""
#s=StrEatTillChr("12.34:567;abcd","")              # = ""       ## BUG CHK: Nul length Chars
#s=StrEatTillChr("",",:;")                         # = ""       ## BUG CHK: Nul length S
#s=StrEatTillChr("","")                            # = ""       ## BUG CHK: Nul length S & Chars
###
Return BlankClip.subtitle("'"+String(s)+"'")
__________________
I sometimes post sober.
StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace

"Some infinities are bigger than other infinities", but how many of them are infinitely bigger ???

Last edited by StainlessS; 4th May 2020 at 03:01.
StainlessS is offline   Reply With Quote
Old 2nd May 2020, 13:04   #3  |  Link
videoh
Useful n00b
 
Join Date: Jul 2014
Posts: 1,667
It would be great if you could tell us what this thing does.
videoh is offline   Reply With Quote
Old 2nd May 2020, 19:15   #4  |  Link
kedautinh12
Registered User
 
Join Date: Jan 2018
Posts: 2,153
Quote:
Originally Posted by videoh View Post
It would be great if you could tell us what this thing does.
I think so
kedautinh12 is offline   Reply With Quote
Old 2nd May 2020, 21:19   #5  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
I did all that work on it, and you want me to explain it too.
Some peeple iz neva appy.

EDIT: THIS NEED UPDATE FOR KLUDGE Type=0 ,and new Type= -1..

Code:
The StrMatchDemo.avsi thing is initially to obtain version related stuff for scriptors/scriptesses.

# Handy functions: without avs version or external plugin requirements (some may use a little string memory at each call).
SystemInfoVersion()         Tells version of installed Groucho2004 SysInfo plugin, -1.0 indictates NOT INSTALLED.
RT_StatsVersion()           Tells version of installed RT_Stats plugin, -1.0 indictates NOT INSTALLED.
GScriptExists()             True, then GScript is Installed, else not installed.
FuncNameExists("myfunc")    True if Function/Filter myfunc exists, Same As builtin FunctionExists("myFunc") in Avs+ but usable in any Avs version.
                            NOTE, If RT_Stats is installed, then RT_FunctionExist() is available in all versions avs. [note exist not exists same as original Exist() function].
IsAvs26()                   True if avs v2.60 or greater, ie NOT v2.58 or less. YV24, Y8 colorspaces etc available.
IsAvsPlus()                 True if Avs+, with GScript script syntax natively builtin.
                                Does NOT indicate high bit depth support, have to interrogate version info for that [indicates only that is called 'Avisynth+'"].

AvsVersionNumberString(int "Type"=0)    [Requires Groucho2004 SysInfo plugin where TYPE=1]
                            Returns a version number string for current avisynth.
                            There are two sources from which to obtain a version number string,
                                TYPE=0, from Avisynth function VersionString(), eg [top line only from VersionString ]
                                    v2.58       = "AviSynth 2.58, build:Dec 22 2008 [08:46:51]"
                                    Ultim+ x86  = "AviSynth+ 0.1 (r1576, x86)"             # ???
                                    v2.60       = "AviSynth 2.60, build:Mar 31 2015 [16:38:54]"
                                    v2.61 Alpha = "AviSynth 2.61, build:May 17 2016 [16:06:18] VC2008Exp"
                                    v3.52  x86  = "AviSynth+ 3.5.2 (r3218, neo, i386)"
                                    v3.52  x64  = "AviSynth+ 3.5.2 (r3218, neo, x86_64)"
                                TYPE=1, from Groucho2004 plugin SysInfo, AI_AvsProductVersion() which yields a string from the dll version resource [shows in file Properties dialog box].
                                    v2.58       = "2.5.8.5"
                                    Ultim+ x86  = "2.6.0.5"               # v2.60 Non Final (RC2 I think) ???
                                    v2.60       = "2.6.0.6"
                                    v2.61 Alpha = "2.6.1.0"
                                    v3.52  x86  = "3.5.2.0"
                                    v3.52  x64  = "3.5.2.0"
                            It has become tradition to obtain a TYPE 0 version string by extracting eg
                                    v2.58       = "2.58"
                                    Ultim+ x86  = "0.1"                   # ??? no idea what to do with this
                                    v2.60       = "2.60"
                                    v2.61       = "2.61"
                                    v3.52  x86  = "3.5.2"
                                    v3.52  x64  = "3.5.2"
                            You can probably see from above that version info derived from SysInfo plug produces numbers in a more predictable format.
                            So, for longevity, it is suggested that scriptors in future use TYPE 1 version string source, ie from SysInfo:AI_AvsProductVersion.
                            AvsVersionNumberString(TYPE=0), returns the data gotten from the VersionString, formatted like so, [with 4 dot separated numbers]
                                    v2.58       = "2.58.0.0"  # ".0.0" added to achieve the now standard dot numbers.
                                    Ultim+ x86  = "0.1.0.0"   # ".0.0" added to achieve the now standard dot numbers.   ??? No idea what to do with this
                                    v2.60       = "2.60.0.0"  #    Ditto
                                    v2.61       = "2.61.0.0"  #    Ditto
                                    v3.52  x86  = "3.5.2.0"   # ".0" added to achieve the now standard dot numbers.
                                    v3.52  x64  = "3.5.2.0"   #    Ditto
                            AvsVersionNumberString() uses string utility functions StrMatchChrLen() and StrBrkChrLen()  to find and extract a multi digit dot string
                                from the TYPE=0 Avisynth VersionString().
                            Show std dot format version number string:- Return BlankClip.Subtitle(AvsVersionNumberString(TYPE=0)) # or TYPE=1

AvsVersionNumberPartNo(int PartNo,Int "Type"=0)     # PartNo, 1->4.
                            Returns Int, one of the dot separated numbers described for AvsVersionNumberString(type=TYPE).


IsAvsVerOrGreater(int a,int "b"=0,int "c"=0,int "d"=0, Int "Type"=0)
                            Compares current version of avisynth with your specified minimum version part numbers, returns true if acceptable version.

                            Where TYPE=0,
                                IsAvsVerOrGreater(2,58,0,0,type=0)  # Return True if v2.58 or higher [may be alpha].
                                IsAvsVerOrGreater(2,60,0,0,type=0)  # Return True if v2.60 or higher [may be alpha].
                                IsAvsVerOrGreater(3, 5,2,0,type=0)  # Return True if Avs+ v3.5.2 or higher.
                            Where TYPE=1,
                                IsAvsVerOrGreater(2,5,8,5,type=1)   # Return True if v2.58 FINAL non Alpha or higher.
                                IsAvsVerOrGreater(2,6,0,6,type=1)   # Return True if v2.60 FINAL non Alpha or higher.
                                IsAvsVerOrGreater(3,5,2,0,type=1)   # Return True if Avs+ v3.5.2 or higher.


StrMatchChrLen(String s,String Chars,Bool "Sig"=False)
                            Return extent (length) of string s that matches to any character in Chars set of characters. Sig (default false) specifies whether case significant compararison.
                            StrMatchChrLen("1234.567abcd","0123456789.",True) = 8, ie there are 8 characters at beginning of string s that match with any character in the Chars string.
                            So as above, you are measuring the number of characters at the beginning of string s that match a digit or a dot, 'a' does not match digit nor dot and
                            so that is not included in the length returned by the function.
                            In this case, as the characters in Chars cannot be upper/lower cased [digits and dot], so it is pointless using anything other than case significant, ie use Sig=True,
                            and that will avoid Upper casing both s and Chars prior to comparisons.
                            If every character in string s matches a character in Chars set, the function returns the length of string s, ie all matched.
                            If either StrLen(s) or StrLen(Chars) == 0, then result is 0, ie no characters matched.
                            You can similarly match eg Hex Numbers (digits and letters a->f, maybe upper/lower case), Alpha Numeric, Alpha only, digit only
                            or some other set of characters that you would like to specify.

StrBrkChrLen(String s,String Chars,Bool "Sig"=False)
                            Return extent (length) of string s that DOES NOT match to any character in Chars set of characters. Sig (default false) specifies whether case significant compararison.
                            Whereas StrMatchChrLen() finds extent of s that matches some alphabet, so this function finds length that does not match, and so it tells how many characters
                            at the beginning of string s need to be removed so as to access the one or more characters that are in the Chars set of characters.
                            So eg StrBrkChrLen("abcd12","0123456789") = 4, tell the number of characters that need be skipped/removed to 'get at' a digit character [any one of "0123456789"],
                            remove 4 characters from start of s and result is "12", the '1' is the very first digit in string s.
                            If s = "" then returns 0. [There can be no characters to remove].
                            If the first character in string s matches any character in Chars set of characters, then returns 0, ie you dont need remove any from beginning of string s
                                to find a character that matches one on the chars Set.
                            If no characters in string s match characters in string Chars [or Chars==""] then returns length of s string [removing all characters from s will still not find any
                                characters present in Chars set].
                            Avisynth builtin FindStr() can search for a string, but it cannot search for eg 'any digit'.


The Remainder of functions in StrMatchDemo.avsi,
just to demo how flexible the above two functions are [StrMatchChrLen() and StrBrkChrLen(), so in brief only, I dont wanna spend more time on docs than it took to write the functions]:-

######

# MATCHING: Returning Matching String. [ As for StrMatchChrLen() ]
StrMatchChr(String s,String Chars,Bool "Sig"=False)   Return beginning of string s that matches any character in Chars, length same as in StrMatchChrLen().
StrMatchWhite(String s)                               Returns beginning of string s that matches white space, just calls StrMatchChr with Chars=SPACE+BackSPC+TAB,+LF+VT+FF+CR, all white space characters.
StrMatchDigits(String s)                              As above but matching Digits "0123456789".
StrMatchHex(String s)                                 As above but matching Hex Digits "0123456789ABCDEF".
StrMatchAlpha(String s)                               As above but matching Alpha chars "ABCDEFGHIJKLMNOPQRSTUVWXYZ".
StrMatchAlpNum(String s)                              As above but matching Alpha numeric chars "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789".
StrMatchDigitDot(String s)                            As above but matching Digits and dots chars "0123456789.".
# Specials [ what use ? ans=No idea ]
StrMatchInt(String s)                                 As above but matching Int number eg "123" or "+123" or "-123" or "+ 123" or "- 123".
StrMatchFloat(String s)                               As above but matching Float number eg "1234", "12.34", "+12.34", "-12.34", [but not "12.34.56", only first 5 characters "12.34"].
StrMatchVarName(String s)                             As above but matching Variable name, eg "MyVarName66", "_SomeVar", "My_42_Function", ie valid function or variable name.

# Removing/Eating Matching String
StrEatChr(String s,String Chars,Bool "Sig"=False)     Eat/Remove the characters from the beginning of string s that is StrMatchChrLen() in length.
StrEatWhite(String s)                                 Eat/Remove string from start of s as matched for above StrMatchWhite()
StrEatDigits(String s)                                    Ditto for Digits.
StrEatHex(String s)                                       Ditto for Hex
StrEatAlpha(String s)                                     Ditto for Alpha
StrEatAlpNum(String s)                                    Ditto for Alpha Numeric
StrEatDigitDot(String s)                                  Ditto for Digits & Dots
# Specials
StrEatInt(String s)                                       Ditto for Int
StrEatFloat(String s)                                     Ditto for float
StrEatVarName(String s)                                   Ditto for varName

Above, the two more important ones are StrMatchChr() and StrEatChr(), the others just provide an Alphabet of characters to match in the Chars arg, easy to roll you own by providing another alphabet.
So for above 2 functions [the alphabet variations could be anything, its just demo], you can find extent of some chunk of text, extract it from s using StrMatchChr(), then when done
with it, remove/eat it using StrEatChr(), and move on to the next chunk to look for/match & repeat.

######

# NOT_MATCHED: Returning Not Matching String. [ As for StrBrkChrLen() ]
StrBrkChr(String s,String Chars,Bool "Sig"=False)     Return beginning of string s that DOES NOT match any character in Chars, length same as in StrBrkChrLen()
                                                          StrBrkChr("12.34:567;abcd",",:;")  = "12.34"
                                                          StrBrkChrLen() for above returns 5, ie the first 5 characters are NOT matched to any in Chars set ",:;"
                                                          So above StrBrkChr() returns the first 5 characters as a string, ie "12.34".
                                                          Could use something like above where you want to find a separator that marks end of something and beginning
                                                          of something else, in this case the found separator was ":" and "12.34" was the string before it.

StrEatTillChr(String s,String Chars,Bool "Sig"=False) This function does the opposite of above StrBrkChr(), for the same example used above, it would Eat ie Remove the.
                                                      "12.34" from string s "12.34:567;abcd" leaving ":567;abcd"

AvsVersionNumberString(TYPE=0) {After removing the TYPE=1 stuff}
    s = VersionString                                   # eg s = VersionString = "AviSynth+ 3.5.2 (r3218, neo, i386)"
    s = s.MidStr(s.StrBrkChrLen("0123456789.",True)+1)  # Find length of string s that does NOT have any digits or dots and remove it [we used a shortcut, we could have used StrEatTillChr]
                                                        #     StrEatTillChr(s,Chars="0123456789.",True) { Return s.MidStr(s.StrBrkChrLen("0123456789.",True)+1) }
                                                        # so s now is "3.5.2 (r3218, neo, i386)"
    s = s.LeftStr(s.StrMatchChrLen("0123456789.",True)) # Get String that matches ONLY digits & dot, s is now "3.5.2"
                                                        # Nuther shortcut, equivalent to this
                                                        #      StrMatchDigitDot(String s) { Return s.StrMatchChr("0123456789.",true) }
                                                        #  which is also equivalent to this
                                                        #      StrMatchChr(String s,Chars="0123456789.",True) { Return s.LeftStr(s.StrMatchChrLen("0123456789.",True))}
##########
# SORTED #
##########
Me hates docs, if it were not for lockdown, me would have probly run out and jumped in front of a bus.
__________________
I sometimes post sober.
StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace

"Some infinities are bigger than other infinities", but how many of them are infinitely bigger ???

Last edited by StainlessS; 4th May 2020 at 04:32.
StainlessS is offline   Reply With Quote
Old 2nd May 2020, 22:24   #6  |  Link
videoh
Useful n00b
 
Join Date: Jul 2014
Posts: 1,667
Still not clear what's it good for.

Last edited by videoh; 3rd May 2020 at 00:06.
videoh is offline   Reply With Quote
Old 2nd May 2020, 22:58   #7  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
Whats it for ?
Well the version stuff is so as to extract avisynth version information for scriptors, in any version of avs.
You cant inquire if a function exists in v2.58 because FunctionExists() dont exist.
You cant (or at least have no standard way) to extract a proper version number that works under all version of Avs.
The functions that scan for a multi [ie 4] dot separated version number is now necessary to establish what particular version of avisynth is capable of. [EDIT: although avs+ is currently using only 3]

The remaining stuff is just to show how the required two functions that scan for multidot numbers can be used for other things, eg parsing strings.
The only two necessary ones are StrMatchChrLen() and StrBrkChrLen(), the others are just niceties to save using various alphabets that migh be wanted
by some. I dont anticipate that many would have any use for them at all, especially if their purpose needs explaining.
The Specials, for int float and varname, were just an experiment, but I have had cause to write a individual functions to do only that, in the past.
If they can be of use to anyone, then great, if not it dont matter.

EDIT: Some version string stuff

Code:
# AviSynth v2.58
AviSynth 2.58, build:Dec 22 2008 [08:46:51]

# AviSynth v2.60
AviSynth 2.60, build:Mar 31 2015 [16:38:54]

# AviSynth v2.61 Alpha
AviSynth 2.61, build:May 17 2016 [16:06:18] VC2008Exp

# Avisynth v2.60 ICL
AviSynth 2.60 (ICL10)

# Avisynth V2.60 MT
AviSynth 2.60, build:Feb 20 2015 [03:16:45]

# Avisynth NEO
AviSynth Neo 0.1 (r2822, Neo, i386)
AviSynth Neo 0.1 (r2822, Neo, x86_64)

# Avisynth NEO Forerunner Avisynth+ CUDA
AviSynth+ 0.1 (r2533, CUDA, i386)
AviSynth+ 0.1 (r2533, CUDA, x86_64)

# Avisynth+ v2.60
AviSynth+ 0.1 (r2772, MT, i386)
AviSynth+ 0.1 (r2772, MT, x86_64)

# Avisynth+ v3.4
AviSynth+ 3.4 (r2923, 3.4, i386)
AviSynth+ 3.4 (r2923, 3.4, x86_64)

# Avisynth+ v3.4.1
AviSynth+ 3.4 (r2983, linux3, i386)
AviSynth+ 3.4 (r2983, linux3, x86_64)

AviSynth+ 3.5.2 (r3218, neo, i386)
AviSynth+ 3.5.2 (r3218, neo, x86_64)
__________________
I sometimes post sober.
StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace

"Some infinities are bigger than other infinities", but how many of them are infinitely bigger ???

Last edited by StainlessS; 3rd May 2020 at 18:03.
StainlessS is offline   Reply With Quote
Old 3rd May 2020, 00:05   #8  |  Link
videoh
Useful n00b
 
Join Date: Jul 2014
Posts: 1,667
Thank you for your cogent description, SssS. We never want to underestimate the importance of clear documentation. And thank you for your great work over the years.
videoh is offline   Reply With Quote
Old 3rd May 2020, 00:56   #9  |  Link
Groucho2004
 
Join Date: Mar 2006
Location: Barcelona
Posts: 5,034
Quote:
Originally Posted by StainlessS View Post
You cant inquire if a function exists in v2.58 because FunctionExists() dont exist.
That functionality can be added to SysInfo. All internal functions are present in the aptly named "$InternalFunctions$".
__________________
Groucho's Avisynth Stuff
Groucho2004 is offline   Reply With Quote
Old 3rd May 2020, 01:39   #10  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
Yes, ideally people would start using a cross version function from a reasonably sized plugin.
RT_Stats RT_FunctionExist() already does that but is quite some size.
This from earlier post works, no requirements
Code:
Function FuncNameExists(String Fn)  { Try{Eval(Fn+"()")B=True}catch(e){Assert(e.FindStr("syntax")==0,"FuncNameExists: Error in Function Name '"+Fn+"'")B=(e.FindStr("no function named")==0)}Return B}
but not ideal and consumes string memory.

Even the IsAvsVerOrGreater() stuff would be beneficial if worked over all versions, I know quot27 was saying something
about implementing the same-ish named function with one of multiple version items returned, but, that will only work on some versions of avs+,
when its implemented. Seperate dll could perhaps implement same for all version of avs+ and prior.
Just something like HasAlpha is implemented in some version of Avs+, but not others, and you dont really wanna be checking if
existing before you call each function. (whos got time time scan change logs every couple of lines of written script).
I guess you could just set minimum version avs that was used to write a script, but that would likely prevent use in versions
that would have no problem running the script. Avisynth has had a surprising lack of status information in the past, I think
Pinterf only recently implemented inquiring the crop granularity of a colorspace, I guess with previous issues of avs, the user was just
expected to know crop restrictions, now that there are gazillions of colorspaces makes a helluva a lot of sense to be able to inquire about such things.
Quote:
That functionality can be added to SysInfo
Whatever floats your boat, yes why not, please.

EDIT: I've implemented FuncNameExists() in AvsInit.avsi thingy, but inside it is RT_FunctionExist [AvsIint has both SysInfo and RT_Stats mandatory requirement].
Purpose being that if someone may not be using AvsInit, and want to use the script only version, and thats fine. But if the user changes to using avsInit, then
no scripts broken and uses plugin instead (ok its wrapped in a script function but still got to be a bit faster).
Anyway, if/when you implement function exists type thngy, then that will replace RT_FunctionExist.
Maybe one day, people will directly use your sysinfo versions, got to be a good thing.

EDIT: I would not be at all upset if you also implemented IsAvsVerOrGreater() et al, but maybe would like some kind of input from Real.finder, see if it seems
ok or not, maybe he sees problems I dont. So dont be in a big rush to add it just yet [ I know how excitable you are ].
__________________
I sometimes post sober.
StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace

"Some infinities are bigger than other infinities", but how many of them are infinitely bigger ???

Last edited by StainlessS; 4th May 2020 at 05:11.
StainlessS is offline   Reply With Quote
Old 4th May 2020, 03:30   #11  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
V1.01, updated 1st post. Added a new mode, Type = -1, Type = 0 is now a Kludge mode[Default].

Code:
Function AvsVersionNumberString(Int "Type") {
/*
    Returns a version string guaranteed 4 dot separated number parts, eg "3.5.2" would return "3.5.2.0"
    Type = Default 0. : Range -1, or 0, or 1, Source TYPE for Version, ie where to obtain source version string.
      -1 = RAW VersionString, eg from "AviSynth 2.58, build:Dec 22 2008 [08:46:51]" would return "2.58" with ".0.0" appended, ie "2.58.0.0".
       0 = VersionString with KLUDGE eg "2.58" -> "2.5.8.0" (Default) :: Kludge, If Parts 3 & 4 both "" and StrLen(Part2) > 1 Then Shift single digit into part3
       1 = SysInfo:AI_AvsProductVersion eg "2.5.8.5" [As shown in Avisynth.dll file Properties dialog box] ::: Requires Groucho SysInfo.
*/
    myName="AvsVersionNumberString: "
    Type=Default(Type,0)                      # Default is version number from VersionString
    Assert(-1 <= Type <= 1,myName+"-1 <= Type <= 1 ("+String(Type,"%.f")+")")
    Assert(Type<1 || SystemInfoVersion>=0.121,myName+"Groucho2004 SysInfo v0.121+ required")
    s = (Type<=0) ? VersionString : AI_AvsProductVersion
    s = (Type<=0) ? s.MidStr(s.StrBrkChrLen("0123456789.",True)+1)  : s
    s = (Type<=0) ? s.LeftStr(s.StrMatchChrLen("0123456789.",True)) : s
    d=s.FindStr(".") n1=(d==0)?s:s.LeftStr(d-1) s=(d==0)?"":s.MidStr(d+1)
    d=s.FindStr(".") n2=(d==0)?s:s.LeftStr(d-1) s=(d==0)?"":s.MidStr(d+1)
    d=s.FindStr(".") n3=(d==0)?s:s.LeftStr(d-1) s=(d==0)?"":s.MidStr(d+1)
    d=s.FindStr(".") n4=(d==0)?s:s.LeftStr(d-1)
    # KLUDGE: If Type==0 and Parts 3 & 4 both "" and StrLen(Part2) > 1 Then Shift single digit into part3
    Shift1=(Type==0) && (n3==""&&n4=="") && (n2.StrLen>1)
    n3=(Shift1)?n2.RightStr(1):n3
    n2=(Shift1)?n2.LeftStr(n2.StrLen-1):n2
    # END KLUDGE
    (n1==""?"0":n1) + "." + (n2==""?"0":n2) + "." + (n3==""?"0":n3) + "." + (n4==""?"0":n4)
}
Kludge [Default Type= 0], converts version from VersionString eg "2.58" to "2.5.8.0".

Version for 2.58 dll ProductVersion is "2.5.8.5", so compare with 2.5.8.0 would pass with the Kludge, eg IsAvsVerOrGreater(2,5,8,0,Type=0).
To be sure of getting v2.58 final ie not an alpha version use exact numbers use IsAvsVerOrGreater(2,5,8,5,Type=1). (from dll ProductVersion)

RAW version number can still be extracted using Type = -1, where v2.58 string "2.58" would return "2.58.0.0".

So, in the main, most useful may be to use default Type=0 with Kludge, and only use first 3 parts as requirement, last part usually indicating Alpha level (at least in Avs std).
The only reall awkward ones are gonna be some Avs+ prior to about 3.x.x.x, and also those from Nekopanda Avs Neo.

Code:
# Avisynth+ v2.60
AviSynth+ 0.1 (r2772, MT, i386)
AviSynth+ 0.1 (r2772, MT, x86_64)

# Avisynth NEO
AviSynth Neo 0.1 (r2822, Neo, i386)
AviSynth Neo 0.1 (r2822, Neo, x86_64)

# Avisynth NEO Forerunner Avisynth+ CUDA
AviSynth+ 0.1 (r2533, CUDA, i386)
AviSynth+ 0.1 (r2533, CUDA, x86_64)
For above r2772, in addition to the VersionString version (ie "0.1") the dll ProductVersion and FileVersion both return "0.1.0.0" which kinda hampers things a bit,
I guess that it may be best to just always demand 3.x.x.x where avs+ is concerned, and just forget that earlier exists, unless you wanna mess with build numbers.

You can always use SysInfo and type=1 for dll ProductVersion, or if SysInfo not installed use the Kludge version [type=0].

EDIT: From Post #5 (which I'll have to update tomorrow) [Below does not show kludge versions]
Code:
                                TYPE=0, from Avisynth function VersionString(), eg [top line only from VersionString ]
                                    v2.58       = "AviSynth 2.58, build:Dec 22 2008 [08:46:51]"
                                    Ultim+ x86  = "AviSynth+ 0.1 (r1576, x86)"             # ???
                                    v2.60       = "AviSynth 2.60, build:Mar 31 2015 [16:38:54]"
                                    v2.61 Alpha = "AviSynth 2.61, build:May 17 2016 [16:06:18] VC2008Exp"
                                    v3.52  x86  = "AviSynth+ 3.5.2 (r3218, neo, i386)"
                                    v3.52  x64  = "AviSynth+ 3.5.2 (r3218, neo, x86_64)"
                                TYPE=1, from Groucho2004 plugin SysInfo, AI_AvsProductVersion() which yields a string from the dll version resource [shows in file Properties dialog box].
                                    v2.58       = "2.5.8.5"
                                    Ultim+ x86  = "2.6.0.5"               # v2.60 Non Final (either RC1 or RC2 I think, the one before FINAL) ???
                                    v2.60       = "2.6.0.6"
                                    v2.61 Alpha = "2.6.1.0"
                                    v3.52  x86  = "3.5.2.0"
                                    v3.52  x64  = "3.5.2.0"
                            It has become tradition to obtain a TYPE 0 version string by extracting eg
                                    v2.58       = "2.58"
                                    Ultim+ x86  = "0.1"                   # ??? no idea what to do with this
                                    v2.60       = "2.60"
                                    v2.61       = "2.61"
                                    v3.52  x86  = "3.5.2"
                                    v3.52  x64  = "3.5.2"
Above, seems Ultim versions had a non "0.1" ProductVersions.
I'll try create a list of RAW, Kludged, and ProductVersion version for a range of versions of avisynth, and post.

EDIT:
It seems that Avs std uses ProductVersion Part_4 as Alpha version, where Alpha = Part_4 + 1, ie 0=Alpha, 1=Alpha2 etc, and FINAL = last Alpha Part_4 + 1, whatever that is.
__________________
I sometimes post sober.
StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace

"Some infinities are bigger than other infinities", but how many of them are infinitely bigger ???

Last edited by StainlessS; 4th May 2020 at 18:31.
StainlessS is offline   Reply With Quote
Old 4th May 2020, 13:50   #12  |  Link
Groucho2004
 
Join Date: Mar 2006
Location: Barcelona
Posts: 5,034
Stainless, why fiddle with the version stuff? Are these functions ("AvsVersionNumberString", "IsAvsVerOrGreater", etc.) not just helpers to determine if the loaded AVS supports certain features?
__________________
Groucho's Avisynth Stuff
Groucho2004 is offline   Reply With Quote
Old 4th May 2020, 18:43   #13  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
Quote:
to determine if the loaded AVS supports certain features?
Well yes, so could use equiv of FunctionExist, but that does not tell if the required function/filter works properly.
__________________
I sometimes post sober.
StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace

"Some infinities are bigger than other infinities", but how many of them are infinitely bigger ???
StainlessS is offline   Reply With Quote
Old 4th May 2020, 18:58   #14  |  Link
Groucho2004
 
Join Date: Mar 2006
Location: Barcelona
Posts: 5,034
Quote:
Originally Posted by StainlessS View Post
but that does not tell if the required function/filter works properly.
Can you expand on that?
__________________
Groucho's Avisynth Stuff
Groucho2004 is offline   Reply With Quote
Old 4th May 2020, 19:10   #15  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
Well if you want to avoid bugged versions of whatever filter/function.
Also, if scripts do start using version numbers, might encourage avs devs to be more fastidious about setting
version numbers in version resource, or in VersionString, and in a more coherent manor.
Ain't nuttin' wrong with having some kind of order that can be relied upon.
__________________
I sometimes post sober.
StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace

"Some infinities are bigger than other infinities", but how many of them are infinitely bigger ???

Last edited by StainlessS; 4th May 2020 at 19:15.
StainlessS is offline   Reply With Quote
Old 4th May 2020, 19:14   #16  |  Link
Groucho2004
 
Join Date: Mar 2006
Location: Barcelona
Posts: 5,034
Quote:
Originally Posted by StainlessS View Post
Well if you want to avoid bugged versions of whatever filter/function.
Also, if scripts do start using version numbers, might encourage avs devs to be more fastidious about setting
version numbers in version resource, or in VersionString, and in a more coherent manor.
Ain't nuttin wrong with having some kind of order that can be relied upon.
Got it.
__________________
Groucho's Avisynth Stuff
Groucho2004 is offline   Reply With Quote
Old 4th May 2020, 19:20   #17  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
Also eg, Pinterf recently implemented Layer for a lot more colorspaces than of old, so checking for filter Layer existing tells nothing about Layer supported colorspaces.
(Layer probably supported long long long time)
__________________
I sometimes post sober.
StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace

"Some infinities are bigger than other infinities", but how many of them are infinitely bigger ???
StainlessS is offline   Reply With Quote
Reply

Tags
string matching

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 23:06.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.