Page 1 of 1 1
Topic Options
#23833 - 2002-06-25 02:00 PM Problem with USE Command
8bit Offline
Fresh Scripter

Registered: 2002-06-21
Posts: 21
Loc: Bristol / UK
I thought it might be a good idea to use an array to store all my drive mappings for each different type of user (based on Group membership) and then use the USE command on each entry using a loop. It's not mapping the drives though and I suspect this is because the drive letter is part of the array value. Is there any way round this (So I can keep the array idea?)

Code is as follows:
Dim $CCentre_Drive[8]
$CCentre_Drive[1] = "I: \\FAIRY\DESSERT"
$CCentre_Drive[2] = "Q: \\IO\XCRIPT"
$CCentre_Drive[3] = "R: \\IO\INTRANET"
$CCentre_Drive[4] = "U: \\CUSTBAK\DATA"
$CCentre_Drive[5] = "V: \\HAL\DATA"
$CCentre_Drive[6] = "X: \\CUSTBAK\DATA"
$CCentre_Drive[7] = "Y: \\HAL\DATA"
$CCentre_Drive[8] = "END"

....

If InGroup("MMGROUP\CCOpsX")=1
$Counter=1
While $CCentre_Drive[$Counter] <> "END"
USE $CCentre_Drive[$Counter]
If @ERROR<>0
$ErrorLine = "Error "+@ERROR+" Mapping : "+$CCentre_Drive[$Counter]
Else
$ErrorLine = "Mapped : "+$CCentre_Drive[$Counter]
Endif
Gosub Write_Error
sleep 1
$Counter = $Counter + 1
Loop
Endif

Top
#23834 - 2002-06-25 02:11 PM Re: Problem with USE Command
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
I am working on an Associative array (Hash) UDF. See Pseudo Hash UDFs (Hash & MHash) - RFC for more details. It will let you manage two arrays pretty easily.

You could load all mappings for all groups into the Hash using the group name as the key. The data could be exactly what you currently have.

Even if you do not like the above idea, all you have to do is split the value:

$map = split($CCentre_Drive[1]," ")
use $Map[0] $Map[1]

this is assuming that you do not use any spaces in the names of your servers or shares.

Or if you like the above idea:
$map = split(MHash("Mappings","CCOpsX"), " ")
use $Map[0] $Map[1]

If you use spaces in server or share names, then add a special character to the data as in "X:~\\server\share" and split on the "~".

{edit}
Or maybe this is more accurate.
for each $drive in HashKeys("CCOpsX")
    USE $drive MHash("CCOpsX",$drive) ;where the value returned is "\\servername\share"
next

HashKeys UDF still needs to be written.

[ 25 June 2002, 14:38: Message edited by: Howard Bullock ]
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#23835 - 2002-06-25 03:55 PM Re: Problem with USE Command
BrianTX Offline
Korg Regular

Registered: 2002-04-01
Posts: 895
There are other ways to do this as well. You could create 2 arrays with the corresponding index (which is similar to what Howard's hash function is doing).

code:
$CCentre_Share = "I:","Q:","R:","U:","V:","X:","Y:"
$CCentre_Drive = "\\FAIRY\DESSERT","\\IO\XCRIPT","\\IO\INTRANET",
"\\CUSTBAK\DATA","\\HAL\DATA","\\CUSTBAK\DATA","\\HAL\DATA","END"

If Ingroup("MMGroup\CCOpsX")=1
$counter = 0
While $CCentre_Drive[$counter] <> "END"
USE $CCENTRE_DRIVE[$counter] $CCENTRE_SHARE[$counter]
.
.
.
.

This should work.. also you could do something like subsituting for this:
USE $CCentre_Drive[$Counter]

code:
$drivemap = $CCentre_Drive[$Counter]
EXECUTE("USE $drivemap")

....

I haven't tested this second code. You might need to enclose your declarations in single quotes like:

$CCentre_Drive[1] = "I: '\\FAIRY\DESSERT'"

Or it may work fine as-is.
Brian

Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 1046 anonymous users online.
Newest Members
Viginette, ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder
17888 Registered Users

Generated in 0.049 seconds in which 0.024 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org