Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


Array filtering

 
Logged in as: Guest
arrSession:exec spGetSession 2,2,58234
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Array filtering
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 Array filtering - 3/20/2008 12:18:54 AM   
  sgimi

 

Posts: 6
Score: 0
Joined: 9/15/2006
Status: offline
Hello,

I'm trying to write a script that gets data on printers from printservers. The script sends this data to excel but some parts of the data have to be formatted. For example:
The script gets the printerdrivername, which should be formatted for use in a new column in excel: a printerdrivername HP LaserJet 4300 PS should be formatted to HPLJ4300-001-PS. However if there already is an entry called HPLJ4300-001-PS the script should convert this to HPLJ4300-002-PS. And that's where my trouble begins...

I've tried to accomplish this renaming by putting every single value into an array and filter that array on every new formatted printedrivername the script will come up with. I was, if not I wouldn't be posting here, unsuccesfull in getting this to work. Below is the code I came up with so far, but just the for next loop in which the actual printerdata is being formatted. The troublesome part is marked with '>>>>>>>>>>>'. There's also some remarked stuff in the script that might come in handy for later use, I hope this will not render the script unreadable....

I hope somebody can help me out here....


      
 
 
Post #: 1
 
 RE: Array filtering - 3/20/2008 12:41:02 AM   
  ebgreen


Posts: 4972
Score: 31
Joined: 7/12/2005
Status: offline
Use a dictionary. Before you try to add the driver, check to see if that name already exists. Then tou can increment the counter.

_____________________________

"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to sgimi)
 
 
Post #: 2
 
 RE: Array filtering - 3/20/2008 8:58:35 PM   
  sgimi

 

Posts: 6
Score: 0
Joined: 9/15/2006
Status: offline
I've googled some on dictionaries, and the concept sounds real great but.....

This is what I tried but unfortunately it didn't work. Can you give me a hint (or a solution will do as well ;)) on how to get this working?


      

(in reply to ebgreen)
 
 
Post #: 3
 
 RE: Array filtering - 3/22/2008 6:53:59 AM   
  ebgreen


Posts: 4972
Score: 31
Joined: 7/12/2005
Status: offline
Take it in baby steps. First figure out how to make a dictionary and add elements to it (looks like you have that). Next put the if statement before you try to add new elements.

_____________________________

"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to sgimi)
 
 
Post #: 4
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Array filtering Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts