Further to previous post, below seems to work OK:
AutoLoadPlugs.AVSI
Code:
Function AutoLoadPlugs(string "Root",string "Folder",Int "Type",Bool "Debug") {
# Root = main alternative plugins DIR containing FOLDERS that hold dll's
# Folder, the folder name relative to Root containing dll's
# TYPE, 0=Standard CPP LoadPlugin, 1 = Import AVSI scripts, 2= LoadCPlugin(built into Avisynth v2.5), 3=LoadCPlugin(v2.0 Avisynth_c.dll)
# Debug==true, send info to DebugView window.
# Cannot mix Standard CPP and Cv2.0 and Cv2.5 plugins in same directory.
# MUST Set Default for ROOT and V2_CPlugin for YOUR SYSTEM.
V2_CPlugin="D:\MyPlugins\C2LOADER\Avisynth_c.dll" # NOTE, MUST set complete Path and filename to Kevin Atkinson avisynth_c.dll
Root=Default(Root,"D:\MyPlugins\") # Set your own default path
Folder=default(Folder,"") # Default = Root ie FULL Path is USER SUPPLIED
Type=Default(Type,0) # Standard CPP is default
Debug=Default(Debug,false)
Assert(Type>=0 && Type <=3,"AutoLoadPlugs: TYPE 0 -> 3 ONLY")
TMPFile="~AutoLoadPlugs.TMP"
GSCript("""
if(TYPE==3) {
if(!RT_VarExist("GLB_V2_CPLUGIN")) {
(!Exist(V2_CPlugin)) ? Assert(false,"AutoLoadPlugs: v2.0 C Plugin Loader Does NOT Exist"+Chr(10)+"("+V2_CPlugin+")"): NOP
(DEBUG) ? RT_Debug("AutoLoadPlugs: LOADING Avisynth V2.0 C Plugin Loader(Avisynth_c.dll)") : NOP
LoadPlugin(V2_CPlugin) # Load v2.0 C Plugin Loader
Global GLB_V2_CPLUGIN=True
}
}
eS=RightStr(Root,1)
Path=(eS!="\" && eS!="/") ? Root+"\" : Root # Ensure End Slash
if(Folder!="") {
eS=RightStr(Folder,1)
Folder=(eS!="\" && eS!="/") ? Folder+"\" : Folder # Ensure End Slash
Path=Path + Folder # Concatenate
}
TestPath=LeftStr(Path,Strlen(Path)-1) # Test PATH Exist without End Slash, else Error
Assert(Exist(TestPath),"AutoLoadPlugin: Path Does not exist ("+Path+")")
WildCard=Select(Type,"*.dll","*.AVSI","*.dll","*.dll")
SearchString = Path + WildCard
Got = RT_WriteFileList(SearchString,TMPFile)
if(Got > 0) {
SS=RT_ReadTxtFromFile(TMPFile) # Read multiline list of filenames
for(i=0,Got-1) {
S=RT_TxtGetLine(SS,i)
if(TYPE==0) { # Standard CPP Plugin
(DEBUG) ? RT_Debug("AutoLoadPlugs: Loading CPP Plugin '"+S+"'") : NOP
LoadPlugin(S)
} else if(TYPE==1){ # AVSI Import
(DEBUG) ? RT_Debug("AutoLoadPlugs: Importing AVSI '"+S+"'") : NOP
Import(S)
} else if(TYPE==2){ # V2.5 Built-in C plugin Loader
(DEBUG) ? RT_Debug("AutoLoadPlugs: Loading v2.5 C Plugin '"+S+"'") : NOP
Load_Stdcall_Plugin(S) # alias for BUILT-IN v2.5 LoadCPlugin().
} else { # V2.0 Avisynth_C.dll C plugin Loader
(DEBUG) ? RT_Debug("AutoLoadPlugs: Loading v2.0 C Plugin '"+S+"'") : NOP
LoadCPlugin(S) # Using Kevin Atkinson Avisynth_c.dll
}
}
RT_FileDelete(TMPFile)
}
""")
return Got
}
Client
Code:
n=0
n=n+ AutoLoadPlugs("D:\MyPlugins\","CPP\" ,TYPE=0,debug=true) # Standard CPP
n=n+ AutoLoadPlugs("D:\MyPlugins\","AVSI\",TYPE=1,debug=true) # AVSI
n=n+ AutoLoadPlugs("D:\MyPlugins\","C25\" ,TYPE=2,debug=true) # V2.5 C Plugins
n=n+ AutoLoadPlugs("D:\MyPlugins\","C2\" ,TYPE=3,debug=true) # V2.0 C Plugins
return Colorbars.RT_Subtitle("%d Plugins loaded",n)
EDITED: