Do you have lots of DLL's to load ? Is re-typing (or copying) LOAD DLL getting you down ? Do you wish for an easier life ?
Well, I can help with the first two points with the following code :
+ Code Snippet#constant DLL_FILEMISSING -1
#constant DLL_NUMMISSING -2
function loadDLL(str as string)
pos as integer
cpos as integer
full$ as string
filename$ as string
dllnum as integer
done as integer
done=0
while str""
pos=instr(str,"|")
if pos=0
pos=len(str)+1
endif
full$=left$(str,pos-1)
cpos=instr(full$,",")
if cpos0
filename$=left$(full$,cpos-1)
dllnum=val(right$(full$,len(full$)-cpos))
if file exist(filename$)0
load dll filename$,dllnum
else
exitfunction DLL_FILEMISSING
endif
str=right$(str,(len(str)-pos))
inc done
else
exitfunction DLL_NUMMISSING
endif
endwhile
endfunction done
function instr(str as string,search as string)
a as integer
found as integer
for a=1 to len(str)
if mid$(str,a)=search
exitfunction a
endif
next a
endfunction 0
Each DLL that you want to load is seperated with a | symbol
The 'bank' that the DLL loads into is given straight after the filename, and is seperated with a , - thus :
loadDLL("Hello.DLL,1") - Will load the Hello.DLL into bank #1
loadDLL("Hello.DLL,1|Goodbye.DLL,2") - Will load the Hello.DLL into bank #1, and Goodbye.DLL into bank #2
A really big example is given here :
+ Code Snippet#constant POINTERS 1
#constant INIFILE 2
#constant SELECTCARD 3
if loadDLL("E:\Users\Nicholas\Visual Studio Projects\Pointers\Release\Pointers.DLL,"+str$(POINTERS)+_
"|E:\Users\Nicholas\Visual Studio Projects\INIFile\Release\INIFile.DLL,"+str$(INIFILE)+_
"|I:\Program Files\Microsoft Visual Studio\MyProjects\SelectGraphicsCardAndMode\Release\SelectGraphicsCardAndMode.dll,"+str$(SELECTCARD))>0
print "All done"
endif
wait key
end
Dont try to run the example as is, as its set up for my system...
Later on I'll be modifying it so the same routine can remove the DLL's from memory.
It can also be modifed to load .X, meshes etc etc.