StainlessS
4th February 2020, 16:42
Moved here from devs forum Avisynth+ thread.
No requirements, Except Groucho2004 SysInfo where indicated, OK in Avs v2.58.
# 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
No requirements, Except Groucho2004 SysInfo where indicated, OK in Avs v2.58.
# 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