arrays - How to get collection item by index? -
how access item in collection? next code gives me error in last line.
<package> <job id="nondisabledservicescollecting"> <comment> ************************************************************ 1 comment 2 3 ************************************************************ </comment> <script language="vbscript"> flash_folder="i:\123\" str_flash_folder_colfiles = "" num_flash_folder_colfiles = 0 set flash_folder_colfiles = createobject("scripting.filesystemobject").getfolder(flash_folder).files wscript.echo flash_folder_colfiles(1) each flash_folder_objfile in flash_folder_colfiles num_flash_folder_colfiles = num_flash_folder_colfiles + 1 str_flash_folder_colfiles = str_flash_folder_colfiles + cstr(num_flash_folder_colfiles) + " " + flash_folder_objfile.name + vbcrlf next dim response response = inputbox("please enter number corresponds selection:" + vbcrlf + str_flash_folder_colfiles, "choose dll copy...") if response = "" wscript.echo "input empty." 'detect cancel if isnumeric(response) exit 'detect value response. wscript.echo "you must enter numeric value." loop selected_flush_dll = flash_folder + flash_folder_colfiles(cint(response)) wscript.echo selected_flush_dll </script> </job> </package>
the .files collection can't accessed index:
>> set ofiles = gofs.getfolder(".\").files >> n = ofiles(0).name >> error number: 5 error description: invalid procedure call or argument
you need each loop fill random access collection e.g. array:
>> set ofiles = gofs.getfolder(".\").files >> redim afiles(ofiles.count - 1) >> = 0 >> each ofile in ofiles >> set afiles(i) = ofile >> next >> n = afiles(0).name >> wscript.echo n >> 31823568.notes
Comments
Post a Comment