#42851 - 2003-07-15 10:31 PM
Searching an array
|
sliver
Getting the hang of it
Registered: 2002-09-05
Posts: 94
|
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
|
Top
|
|
|
|
#42853 - 2003-07-15 10:35 PM
Re: Searching an array
|
sliver
Getting the hang of it
Registered: 2002-09-05
Posts: 94
|
Perfect...I looked through the manual but I must have missed that....I will give that a shot thanks.
|
Top
|
|
|
|
#42855 - 2003-07-15 10:43 PM
Re: Searching an array
|
Kdyer
KiX Supporter
Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
|
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
|
Top
|
|
|
|
#42856 - 2003-07-15 11:29 PM
Re: Searching an array
|
sliver
Getting the hang of it
Registered: 2002-09-05
Posts: 94
|
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.
|
Top
|
|
|
|
#42857 - 2003-07-15 11:36 PM
Re: Searching an array
|
sliver
Getting the hang of it
Registered: 2002-09-05
Posts: 94
|
Sealeopard...I would use the string replace but some of the queue names are different....that is why I need to match them up.
|
Top
|
|
|
|
#42858 - 2003-07-15 11:56 PM
Re: Searching an array
|
Howard Bullock
KiX Supporter
Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
|
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.
|
Top
|
|
|
|
#42862 - 2003-07-16 04:47 AM
Re: Searching an array
|
Howard Bullock
KiX Supporter
Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
|
Don't you guys like my HASH
|
Top
|
|
|
|
#42865 - 2003-07-16 07:58 PM
Re: Searching an array
|
Shawn
Administrator
Registered: 1999-08-13
Posts: 8611
|
whoa ... a JoinSplit with a half Split !!!
The Canadian judge gives that a 10. [ 16. July 2003, 19:59: Message edited by: Shawn ]
|
Top
|
|
|
|
#42868 - 2003-07-16 11:36 PM
Re: Searching an array
|
Shawn
Administrator
Registered: 1999-08-13
Posts: 8611
|
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 !
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
0 registered
and 557 anonymous users online.
|
|
|