ActiveXPowUpload 1.2.0.5
DownloadItems collection properties |
![]() ![]() |
DownloadItems collection provides access to items of the download file list. You cannot create the DownloadItems collections directly. The DownloadItems collection is returned by the DownloadItems property of the ActiveXPowUpload object.
Long Count {get}
Number of items in the collection.
The DownloadFileCount property returns the same.
var cnt = ActiveXPowUpload.DownloadItems.count; // number of items in the download file list
Variant Item(Index:Variant) {get}
Provides access to individual items of the collection.
See the GetDownloadItem method, this property works just the same.
This property is a default property, it can be omitted. Instead of ActiveXPowUpload.DownloadItems.Item(0)
you may simply write ActiveXPowUpload.DownloadItems(0)
.
<script language="jscript"> var file = ActiveXPowUpload.DownloadItems.Item(0); // Get file by position; file = ActiveXPowUpload.DownloadItems(0); file = ActiveXPowUpload.DownloadItems.Item("http://myserver.com/path/file.ext"); // Get file by URL; file = ActiveXPowUpload.DownloadItems("http://myserver.com/path/file.ext"); var index = "0"; file = ActiveXPowUpload.DownloadItems.Item(parseInt(index)); // Use this to convert a string into a number file = ActiveXPowUpload.DownloadItems.Item("http://not_existing_URL"); // here file == null </script> <!-- You may traverse though collection using index: --> <script language="jscript"> for (var i = 0; i < ActiveXPowUpload.DownloadItems.count; i++) { var name = ActiveXPowUpload.DownloadItems(i).FullName; } </script> <script language="vbcript"> for i = 0 to ActiveXPowUpload.DownloadItems.count - 1 name = ActiveXPowUpload.DownloadItems(i).FullName next </script>
IUnknown* _NewEnum {get}
Returns an enumeration over download list items.
First of all, you should never use this property directly. This property allows you to use the vbscript For-Each statement to iterate over DownloadItems collection. See the examples section.
Enumeration mechanism guarantees that each item of the collection will be visitted and only once, assuming the collection is not modified during enumeration. The order in which items are visitted is not specified.
<!-- vbscript provide a convenient way to iterate over collection --> <script language="vbscript"> For Each obj In ActiveXPowUpload.DownloadItems ' here obj is an object of type DownloadItem ' You may get FullName property of the file like this: obj.FullName Next </script> <!-- jscript can also use the enumeration interface, but requires an auxiliary object to work with it: --> <script language="jscript"> for(var e = new Enumerator(ActiveXPowUpload.DownloadItems); !e.atEnd(); e.moveNext()) { // here e is an enumeration object // to get the corresponding DownloadItem object use the item method of the enumeration: e.items(); // this is a DownloadItem object // to get the FullName property you should use this syntax: var name = e.item().FullName; } </script>
For more details on the jscript Enumeration object see Enumerator Object (Windows Scripting - JScript). For more detail on traversing through collections see Q229693.
You may delete items while iterating over the collection. In particular, you may be interested in deleting the current item. You may delete any item of the being interated collection. You should only understand the following: the order in which items are enumerated is not specified. If you delete the current item, you've already visitted it and you will not visit it again. If you delete not current item, there are two cases. Either that item was already visitted or it will not be visitted at all because it is deleted now.
The following code demostrated how items can be deleted, nothing special about enumeration, actually.
<script language="vbscript"> Sub EnumerateOverFileItemsWithDelete ind = 0 ' this code removes each fourth item of the collection, just for example For Each o In ActiveXPowUpload.DownloadItems If ind Mod 3 = 0 Then ActiveXPowUpload.RemoveDownloadFile o.Index End If ind = ind + 1 Next End Sub </script>
You may add new items while enumerating the collection. It is completely undefined whether the new items will be visitted or not, but if they will, they will be visitted only once.