Page 1 of 1 1
Topic Options
#62267 - 2002-01-18 05:46 PM Arrays in Kix
churt Offline
Lurker

Registered: 2002-01-18
Posts: 2
Loc: Southampton, UK
Hi all,
Wonder if anyone could provide some information relating to the use of array variables in KiX.

I am working on an administrative script to assign permissions using a custom built Kix script. Here's a section of the code:

Open(9,$LogPath + "\PERMS.CMD",5)

If Open(1, $LogPath + "\" + $InputFile,2)=0
$x = ReadLine(1)
While @ERROR = 0
$InputArray=Split($x,",",-1); Extract tokens from CSV File
WriteLine (9, $UtilPath + "\XCACLS.EXE " + $InputArray + " /C /E /G " + $InputArray + ":" + $InputArray + ";" + $InputArray + Chr(13) + Chr(10))
$x = ReadLine(1)
Loop
EndIf

The problem I have is that, although the code executes and actually completes the WriteLine step, the script then halts with an "array reference out of bounds" error. I have checked all the array values are populated - can't actually see where the problem is.

Any ideas anyone??

Thanks,

Craig

PS. I'm thinking this might relate to the 2D array functions in 2001??


Top
#62268 - 2002-01-18 06:02 PM Re: Arrays in Kix
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
You're missing the element mumber in your array calls in line
code:
WriteLine (9, $UtilPath + "\XCACLS.EXE " + $InputArray + " /C /E /G " + $InputArray + ":" + $InputArray + ";" + $InputArray + Chr(13) + Chr(10))

. I think you want to accomplish something like this:
code:

WriteLine (9, $UtilPath + "\XCACLS.EXE " + $InputArray[0] + " /C /E /G " + $InputArray[1] + ":" + $InputArray[2] + ";" + $InputArray[3] + Chr(13) + Chr(10))


Another example:
code:

$a='aaa,bbb,ccc'
$b=split($a,',')
? $b[0]
? $b[1]
? $b[2]
? $b


The first three outputs are correct, the last one trying to output the complete array will result in the error code you described.
_________________________
There are two types of vessels, submarines and targets.

Top
#62269 - 2002-01-18 06:16 PM Re: Arrays in Kix
churt Offline
Lurker

Registered: 2002-01-18
Posts: 2
Loc: Southampton, UK
Thanks Jens.

I'd actually updated the script to reference Array[x], but it seems my problem actually lay with the input file having blank lines in it - this was causing the routine to stop when the script referenced the array values that didn't exist.

Do you know of any way to remove "white space" in Kix - any UDF's about?

(not quite so confused any more!)

Top
#62270 - 2002-01-18 06:33 PM Re: Arrays in Kix
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
TRIM removes leading/trailing spaces. You might want to consider using a .INI file that can be read with READPROFILESTRING. This would also make your configuration file more readable and gives you added flexibility.
_________________________
There are two types of vessels, submarines and targets.

Top
Page 1 of 1 1


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

Who's Online
0 registered and 857 anonymous users online.
Newest Members
JimDunn, fgarcia, Viginette, ManuvdWielNL, Sir_Barrington
17890 Registered Users

Generated in 0.056 seconds in which 0.027 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