#108734 - 2003-11-22 09:00 PM
HELP!! I'm so confused...can't create an array....
|
flippis
Fresh Scripter
Registered: 2002-10-03
Posts: 15
|
Hi,
I'm trying to create a simple array, this is the code
______________________________________________________
$COMMON = "Group1"
Global $array[9]
IF INGROUP("$COMMON") = 1
? "Member Of Group1"
DIM $Var1
$Var1 = "C:\KVARK"
ENDIF
For Each $element In $array
? $Var
Next
? "DONE!"
______________________________________________
I want to create an array which will containg a certain value depentent on which group a user is member of..
This script produces ten blank lines....
Thanks !
-Flippis
|
|
Top
|
|
|
|
#108735 - 2003-11-22 09:06 PM
Re: HELP!! I'm so confused...can't create an array....
|
Shawn
Administrator
   
Registered: 1999-08-13
Posts: 8611
|
hmmm, you probably want to do this then:
Code:
IF INGROUP("$COMMON") = 1 $array[0] = "C:\KVARK" ENDIF
; etc ...
|
|
Top
|
|
|
|
#108736 - 2003-11-22 09:16 PM
Re: HELP!! I'm so confused...can't create an array....
|
flippis
Fresh Scripter
Registered: 2002-10-03
Posts: 15
|
Thanks, now the code is: -------------------------- $COMMON = "Group1"
Global $array[9]
IF INGROUP("$COMMON") = 1 $array[0] = "C:\Kvark" ENDIF
For Each $element In $array ? $array Next
? "DONE!" ------------------------------------- and it gives me this error:
ERROR : Error in expression: this type of array not supported in expressions.! Line 10.
You know ?
|
|
Top
|
|
|
|
#108738 - 2003-11-23 11:16 AM
Re: HELP!! I'm so confused...can't create an array....
|
flippis
Fresh Scripter
Registered: 2002-10-03
Posts: 15
|
Hi,
things are working now but I still have some small issues. Kix do not accept this code .... For Each $Element > "" In $Folder copy "$Element\*.*" "C:\Data\*.*" Next ....
What I want to do is to check if an element is empty before executing a command. The Element would contain a path.
-Flippis
|
|
Top
|
|
|
|
#108739 - 2003-11-23 02:38 PM
Re: HELP!! I'm so confused...can't create an array....
|
Howard Bullock
KiX Supporter
   
Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
|
Make your check using an if...endif construct inside your loop. Code:
For Each $Element In $Folder if $Element <> "" copy "$Element\*.*" "C:\Data\*.*" endif Next
|
|
Top
|
|
|
|
#108741 - 2003-11-23 04:20 PM
Re: HELP!! I'm so confused...can't create an array....
|
flippis
Fresh Scripter
Registered: 2002-10-03
Posts: 15
|
That code will not work, I had to write a function which only do the copy "thing"..
Or else it will only run the statements on the first record in the array.
-Flippis
|
|
Top
|
|
|
|
#108742 - 2003-11-23 04:39 PM
Re: HELP!! I'm so confused...can't create an array....
|
Howard Bullock
KiX Supporter
   
Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
|
Based on your previous example code, the posted code would work and accomplish what you described. Please explain in detail what it is you are trying to accomplish and post your current code if you desire additional help. We are not mind readers.
|
|
Top
|
|
|
|
#108745 - 2003-11-23 06:07 PM
Re: HELP!! I'm so confused...can't create an array....
|
Radimus
Moderator
   
Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
|
May the fleas of a thousand camels nest in your armpits
|
|
Top
|
|
|
|
#108746 - 2003-11-24 10:12 AM
Re: HELP!! I'm so confused...can't create an array....
|
flippis
Fresh Scripter
Registered: 2002-10-03
Posts: 15
|
Okey,
First, I know you cant read minds...:/ so forgive me if I did not explain my problem good enough.
As I said if I check whether the value of a record less than or equals to zero (nada) inside the "for each...." loop the script executes the statements on the first record then it exit even though the next record in the array contains data. So, to remedy this I wrote a simple function: ----------------------------------------------------- Function T_Copy($T_Path) If $T_Path > "" Copy "$T_Path\*.*" "C:\T\*.*" EndIf EndFunction ----------------------------------------------------- ...then inside the "for each...." loop ----------------------------------------------------- For Each $Element In $Folder T_Copy($Element) Next -----------------------------------------------------
This works. I have not check the results of the script throughly but I will today.
-Flippis
|
|
Top
|
|
|
|
#108747 - 2003-11-24 04:26 PM
Re: HELP!! I'm so confused...can't create an array....
|
Howard Bullock
KiX Supporter
   
Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
|
I am happy that your code now works. But what you wrote using a function appears to be no different than what I posted to you above without the function.
|
|
Top
|
|
|
|
#108748 - 2003-11-24 04:57 PM
Re: HELP!! I'm so confused...can't create an array....
|
Radimus
Moderator
   
Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
|
I still don't see why you just use xcopy:
xcopy '\\server\share\folder\*.* "'+$destination +'" /d /y /v >nul'
|
|
Top
|
|
|
|
#108749 - 2003-11-24 06:45 PM
Re: HELP!! I'm so confused...can't create an array....
|
flippis
Fresh Scripter
Registered: 2002-10-03
Posts: 15
|
hi,
I'm writing a script which will deploy office templates. Based on which group the user is member of the script will check a network share if there any updates or new files. The script will run each time the user is loged in. Why I dont have this script in the login script for each OU i AD, well because for some reason the administrator has decided to put all the users in one OU (and its a lot of users). First the script checks which group the user is member of, put the correct path for that group into the array, and then it uses robocopy for the synch. Why array, because a user can be member of several template groups. If you have a simpler script or have done this before...ohhhh give it to me )
|
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
0 registered
and 1067 anonymous users online.
|
|
|