#205307 - 2012-05-23 10:00 AM
variable in variable
|
mbwh
Fresh Scripter
Registered: 2012-03-08
Posts: 5
Loc: Germany
|
Hello,
ich have a Problem to become a value as an variable.
I have the variable
$localdrive_H = "\\Fileserver\share"
i build the new variable with $drive = LEFT($localdrive_H, 1)
$NewVariable = "$localdrive_" + $drive The variable $NewVariable has the value $localdrive_H
when i use this in use h: $NewVariable
i become an errer because the Value of this is $localdrive_H and not \\Fileserver\share
how can i become the right value? can everyone help me?
Regards Michael
|
Top
|
|
|
|
#205312 - 2012-05-24 10:07 AM
Re: variable in variable
[Re: ShaneEP]
|
mbwh
Fresh Scripter
Registered: 2012-03-08
Posts: 5
Loc: Germany
|
Hello,
oh sorry, i mean right!
With Execute ()???
Regards Michael
|
Top
|
|
|
|
#205317 - 2012-05-24 03:31 PM
Re: variable in variable
[Re: mbwh]
|
mbwh
Fresh Scripter
Registered: 2012-03-08
Posts: 5
Loc: Germany
|
Hello!
here is my right script.
$lokalDrive_G = "\\filesrv001\log$"
For $Count = 65 To 90 Step 1
$L = Chr ($Count)
$LD = $L + ":"
$LDR = ("$lokalDrive_" + $L)
$LDRIVE = execute ('$$LDR')
? $LDRIVE ; This variable has the value 0 when the variable $LDR have the value "$lokaldrive_G". What can i do to become the value \\filesrv001\log$ ???
If $LDRIVE <> NULL
$Counter = 0
DO
$Counter = $Counter + 1
? $Counter
? $LD
? $L
? "$lokalDrive_" + $L
If Exist ($LD) = 1
Use $LD /Del
Use $LD $LDRIVE
Else
Use $LD $LDRIVE
EndIf
Until Exist($LD) = 1 or $Counter = 5
If Exist ($LD) = 0
MessageBox ("ACHTUNG! Kein " + $L + "-Laufwerk vorhanden! Evtl. sind Sie nicht richtig am Netzwerk angemeldet.", "@TIME", 0)
$Error = $L + " "
EndIf
EndIf
Next
Can everyone help me?
Regards Michael
Edited by Mart (2012-05-24 04:56 PM) Edit Reason: Please use code tags when posting code.
|
Top
|
|
|
|
#205322 - 2012-05-24 09:19 PM
Re: variable in variable
[Re: Lonkero]
|
mbwh
Fresh Scripter
Registered: 2012-03-08
Posts: 5
Loc: Germany
|
i will ? $LDRIVE ; This variable has the value 0 when the variable $LDR have the value "$lokaldrive_G". What can i do to become the value \\filesrv001\log$ ???
This is a construct variable about $lokalDrive_G = "\\filesrv001\log$"
my target is to show if the variable $lokalDrive_A....Z has an value and when it is, then connect the network drive.
Regards Michael
|
Top
|
|
|
|
#205325 - 2012-05-25 08:40 AM
Re: variable in variable
[Re: ShaneEP]
|
mbwh
Fresh Scripter
Registered: 2012-03-08
Posts: 5
Loc: Germany
|
Hello,
this was the right hint.
Here is my script.
$lokalDrive_G = "\\Server\Share"
For $Count = 65 To 90 Step 1
$L = Chr ($Count)
$LD = $L + ":"
$LDR = "$$lokalDrive_" + $L
$junk = execute ('$$LDRIVE="'+$LDR+'"')
If $LDRIVE <> $LDR
$Counter = 0
DO
$Counter = $Counter + 1
If Exist ($LD) = 1
Use $LD /Del
Use $LD $LDRIVE
Else
Use $LD $LDRIVE
EndIf
Until Exist($LD) = 1 or $Counter = 5
If Exist ($LD) = 0
MessageBox ("ACHTUNG! Kein " + $L + "-Laufwerk vorhanden! Evtl. sind Sie nicht richtig am Netzwerk angemeldet.", "@TIME", 0)
$Error = $L + " "
EndIf
EndIf
Next
Thank you for all!!!
Regards Michael
|
Top
|
|
|
|
#205334 - 2012-05-25 08:12 PM
Re: variable in variable
[Re: Lonkero]
|
ShaneEP
MM club member
Registered: 2002-11-29
Posts: 2125
Loc: Tulsa, OK
|
Gotcha...My mistake. I missed the very first line of his script (before the looped script).
The weird thing is that the <> check is still needed. For some reason if LOKALDRIVE_X is never defined in the list of mappings, the execute sets it to the name of the variable, not blank.
When I run the code, they all appear equal except for the G which is the one defined at the beginning of the script. It's weird that the execute simply uses the variable name when it isnt defined.
Attachments
Description:
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
0 registered
and 507 anonymous users online.
|
|
|