I've made a small function which gets the system drives filters them based on ready state and also if they are not a mapped network drive and then returns the collection to the calling code, like so:
Code:
Function getLocalFixedDrives()
Set filesys = CreateObject("Scripting.FileSystemObject")
Set driveColl = filesys.Drives
Set LocalFixedDrivesColl = CreateObject("Scripting.Dictionary")
counter = 0
For each drv in driveColl
If drv.IsReady = true Then
If drv.DriveType <> 3 Then '<- 0=unknown, 1=removable, 2=Fixed, 3=network, 4=CD-ROM, 5=RAMDisk
LocalFixedDrivesColl.add counter, drv.RootFolder
counter = counter + 1
End if
End if
Next
'below is the problem
getLocalFixedDrives = LocalFixedDrivesColl
End Function
My problem is when I need to return my 'filtered collection' to the calling code, which is this line:
Code:
getLocalFixedDrives = LocalFixedDrivesColl
I'm getting an error which states it's an invalid property assignment or wrong number of arguements. But since VBScript forces you to 'return' your function values in the above manner, it's getting confused on what I need to do. I've been searching the intarweb for the last couple of days trying to find an alternate solution, but none were found. Help!!
Wouldn't it just be easier it VBscript utilized the 'return' statement for returning objects from methods?!?!? argh!