02-09-2005, 08:15 AM | #1 (permalink) |
Psycho
Location: the hills of aquafina.
|
[VBscript] Function cannot return a collection
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 Code:
getLocalFixedDrives = LocalFixedDrivesColl Wouldn't it just be easier it VBscript utilized the 'return' statement for returning objects from methods?!?!? argh!
__________________
"The problem with quick and dirty, as some people have said, is that the dirty remains long after the quick has been forgotten" - Steve McConnell Last edited by cartmen34; 02-09-2005 at 09:00 AM.. Reason: spelling, it is a biatch |
02-09-2005, 12:34 PM | #2 (permalink) |
Guest
|
Try
Code:
set getLocalFixedDrives = LocalFixedDrivesColl You might also want to tell the function what kind of value it's going to return as in Code:
Function myfunction() as MyClass |
Tags |
collection, funtion, return, vbscript |
|
|