Page 1 of 1 1
Topic Options
#108734 - 2003-11-22 09:00 PM HELP!! I'm so confused...can't create an array....
flippis Offline
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 Offline
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 Offline
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
#108737 - 2003-11-22 09:23 PM Re: HELP!! I'm so confused...can't create an array....
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
For Each $element In $array
? $element
Next
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#108738 - 2003-11-23 11:16 AM Re: HELP!! I'm so confused...can't create an array....
flippis Offline
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 Offline
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

_________________________
Home page: http://www.kixhelp.com/hb/

Top
#108740 - 2003-11-23 03:31 PM Re: HELP!! I'm so confused...can't create an array....
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Argh! vars in strings. tsk, tsk
Code:
For Each $Element In $Folder

if $Element <> ""
copy $Element+"\*.*" "C:\Data\*.*"
endif
Next



Edited by Les (2003-11-23 03:35 PM)
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#108741 - 2003-11-23 04:20 PM Re: HELP!! I'm so confused...can't create an array....
flippis Offline
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 Offline
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.
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#108743 - 2003-11-23 05:13 PM Re: HELP!! I'm so confused...can't create an array....
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Careful, Howard. Shawn made a liar out of me once.
http://www.kixscripts.com/forum/tm.asp?m=1475
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#108744 - 2003-11-23 05:56 PM Re: HELP!! I'm so confused...can't create an array....
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
Les,

May a diseased yak squat in your hot tub.


Top
#108745 - 2003-11-23 06:07 PM Re: HELP!! I'm so confused...can't create an array....
Radimus Moderator Offline
Moderator
*****

Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
May the fleas of a thousand camels nest in your armpits
_________________________
How to ask questions the smart way <-----------> Before you ask

Top
#108746 - 2003-11-24 10:12 AM Re: HELP!! I'm so confused...can't create an array....
flippis Offline
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 Offline
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.
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#108748 - 2003-11-24 04:57 PM Re: HELP!! I'm so confused...can't create an array....
Radimus Moderator Offline
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'
_________________________
How to ask questions the smart way <-----------> Before you ask

Top
#108749 - 2003-11-24 06:45 PM Re: HELP!! I'm so confused...can't create an array....
flippis Offline
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
#108750 - 2003-12-05 07:14 PM Re: HELP!! I'm so confused...can't create an array....
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
Still, the XCOPY /D will only copy files that are newer, thus it should do what you need.
_________________________
There are two types of vessels, submarines and targets.

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 1067 anonymous users online.
Newest Members
Viginette, ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder
17888 Registered Users

Generated in 0.182 seconds in which 0.137 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