|
|
|||||||
I have an array called $oldprintarray and an array called $newprintarray. In each array is a printer mapping like so. $oldprintarray: $oldprinter1=\\server\path1 $oldprinter2=\\server\path2 $oldprinter3=\\server\path3 $newprintarray: $newprinter1=\\server\path1 $newprinter2=\\server\path2 $newprinter3=\\server\path3 OldPrinter1 represents the printer to be replaced and NewPrinter1 represents the replacement. I have to do it this way because the servers and the queue names are not the same. The arrays are pulled from 2 seperate text files that the NT Server team will be populating. In my script if $OldPrinter1 is detected on the system then I want it to be replaced with $NewPrinter1. $OldPrinter1 will always go with $NewPrinter1 and $OldPrinter2 will always go with $NewPrinter2 etc. Is there a way to search $newprintarray for the corresponding printer without using a "For Each" Ex.- I already know new $oldprinter1 is on my machine and needs to be replaced. Now I want to replace it with it's cooresponding value ($newprinter1). How can I match this?? Sorry if this is a little confusing. Thanks, S |
||||||||
|
|
|||||||
Borrowing from the manual... quote: |
||||||||
|
|
|||||||
Perfect...I looked through the manual but I must have missed that....I will give that a shot thanks. |
||||||||
|
|
|||||||
Use ASCAN to find an array element or do a simple string replace like code:$a='\\server1\printer' |
||||||||
|
|
|||||||
These will probably help you as we recently completed a printer migration from one server to another - Prevent special printers from being deleted Here is a synopsis of what we went through - Printer Migration HTH, Kent |
||||||||
|
|
|||||||
Can you search for a substring with ASCAN....ie.... I just want to find the text NEWPRINTER1....If that text is in any of the elements we have a match. I have been messing with it but I have not been able to successfully get this to work. KDYER....thanks...I will look through this code tomorrow. |
||||||||
|
|
|||||||
Sealeopard...I would use the string replace but some of the queue names are different....that is why I need to match them up. |
||||||||
|
|
|||||||
I think that the optimum method to associate your two arrays is to use my HASH library which you can find in the UDF library and on Jooel's (Lonkero's) UDF mirror site. The example in the UDF script will demonstrate how to use it. I think you will see an immediate correlation to your your implementation needs. |
||||||||
|
|
|||||||
Still, you can use the replace function I posted above in combination with a FOR-EACH. Please study the examples given to you as the REPLACE will fit your bill. |
||||||||
|
|
|||||||
I think you would be better of with one file. it having: "\\oldserver\oldprinter"="\\newserver\shoeprinter" kinda... this way the match is already done for each. |
||||||||
|
|
|||||||
Or even better a .INI file code:[Printer Migration] |
||||||||
|
|
|||||||
Don't you guys like my HASH |
||||||||
|
|
|||||||
lol. the word hash (just like regexpr) sound so unix to me we just might not dear to use your UDFs... who knows, they might be too powerfull |
||||||||
|
|
|||||||
What about this one code:split(split(join($newprintarray, ";"), "newprinter1=")[1], ";")[0] |
||||||||
|
|
|||||||
whoa ... a JoinSplit with a half Split !!! The Canadian judge gives that a 10. [ 16. July 2003, 19:59: Message edited by: Shawn ] |
||||||||
|
|
|||||||
Thanks Shawn. I had to do a lot of stretching before I attempted all those splits |
||||||||
|
|
|||||||
half split? shawn, to me it looks full. maciep, I'm glad to see someone else uses these powerfull kixtart shortcuts than the ultimate kixgolf hardknocks. |
||||||||
|
|
|||||||
Yes, I stand corrected. But the term half-split just sounded better In terms of golf ... i thought maciep was a hard-knock KiXgolfer ?! I recognised the coding style as soon as I saw it. A style forged in the heat of battle, wrought by a scripter skilled in the black-arts of KiXgolf ... its very obvious ! |
||||||||
|
|
|||||||
I said ultimate as far as I remember, he has only participated in 2 of them |