Its dumb but Its not working. SO I declare my 4D array Dim arr(13,13,13,13) set values arr(1,1,1,1)=("ST05V01","E:","N:","0:") or arr(2,2,2,2)=("ST05V02", "F:","K:","")
Do you really need a 4D array (over 28,000 items)? I realize you only provided a short example, but it looks like a 2D arary would work. Dim Arr(13,4) Arr(1,1) = "ST05V01" Arr(1,2) = "E:" Arr(1,3) = "N:" Arr(1.4) = "0:" Arr(2,1) = "ST05V02" Arr(2,2) = "F:" Arr(2,3) = "K:" Arr(3,1) = ...
Yeah, dictionary also works if it doesn't actually need a 4D array. I know split works or using an actual array, but can you use Array when adding a dictionary item? Dim oDic : Set oDic = CreateObject("Scripting.Dictionary") oDic.Add "ST05V01", Array("E:","N:","O:") oDic.Add "ST05V02", Array("F:","K:")
why use a dictionary in this case? The lack of features of VBScript Arrays may justify the use of a dictionary given special circumstances. But as a rule of thumb: Use a dictionary if and only if
(a) you want to access elements by alphabetical key instead of numerical index
(b) you are willing to pay the price:
(1) keys must be unique (no second "ST05V01" possible)
(2) arrays as values in a dictionary are accessed ByVal/Copy; you can't change their elements directly
That's why I'd advise 4scriptmoni to stick to his array.
" The workaround is to change the entire array. Granted not very efficient for a large array, but not terrible for a small one"
is technically correct, it should be added that the necessity for the workaround isn't obvious (ragged arrays/arrays of arrays don't cause the problem) and it's easy to forget to apply it. Most important - in my opinion - is the fact that you don't gain anything by using dictionaries in this context (ok - as I understand the context).
Hi guys, thanks so much for all the answers. I like the idea about the dictonary, although I have to confess I never have used it before.. Basicly what I need are pair or more of value ex: ST05V01, E,N,O ST05V02,F,K So my function would run in that server but only in those disks. At the moment I do have a 2D array but the for loop is ugly. Anyways, can I do such with this code:
How can I do a for loop to go once in that server with disk e, and again disk N, O... ? Now I have:
Ehvbs, to be honest with you, the requirement for using a dictionary is all in my brain. I just think better in those terms and was simply presenting it as an alternative for people who have the misfortune to think like I do.
The answer was given in one of the examples previously. I added it using your script supplied to give you the following:
I woud not have done it this way though. I think that it would be simpler to have the list in a file and read it. The values would be seperated by a comma and each server on a seperate line. This would be an example:
Thanks CondoPC and everyone else. Before my script was taking about 290 seconds now it only takes about 30 seconds. I should have thought about a text file. I am posting the complete script here http://www.visualbasicscript.com/m_49860/tm.htm cheers,