I'm new to KiXtart (2 days and I only wrote a couple of lines of code in it), but I think you could take advantage of the ini-file reading routines and simplify your code.
Having an ini like this (OVERRIDE.INI):
code:
[GL helpdesk-telebilling]
Site 1 = helpdesk.telebilling.dk
[GL Servicerufnummern]
Site 1 = www.ihre-servicerufnummer.de
[GL Call Center]
Site 1 = www.teleauskunft.de
Site 2 = www.bankleitzahlen.de
[Team Intranet]
Site 1 = override=bla.de
[Everyone]
Site 1 = site.for.everyone.com
The actual key names (Site 1, 2, etc) are not important but have to be present; you can use whatever you like the most...
Then change the program to something like this:
code:
dim $Overrides ; Declare $Overrides
$OverrideIni = ".\overrides.ini" ; Choose ini filename and location
$Sep = "|" ; Character or string to seperate overrides
$Groups = ReadProfileString( $OverrideIni, "", "" ) ; Get all Groups defined in the .ini
if @ERROR = 0 ; If all went well
for each $Group in split( $Groups, Chr(10) ) ; Process each returned line in turn
if $Group ; Accounts for last "empty" item returned above
if InGroup( $Group ) ; If user is in this group
$Items = ReadProfileString( $OverrideIni, $Group, "" ) ; Get all overrides for the selected Group
for each $Item in split( $Items, Chr(10) ) ; Process each override in turn
if $Item ; Accounts for last "empty" item returned above
$Value = ReadProfileString( $OverrideIni, $Group, $Item ) ; Read it's value
$Overrides = $Overrides + $Sep + $Value ; And add it to the Overrides list
endif ; End if $Item
next ; End for each $Item in split( $Items, Chr(10) )
endif ; End if InGroup( $Group )
endif ; End if $Group
next ; End for each $Group in split( $Groups, Chr(10) )
if $Overrides ; If some override present
$Overrides = substr( $Overrides, 2 ) ; Eliminate spurious $Sep added at start
? $Overrides ; Print it or do whatever needed
else ; else (no overrides found)
? "No overrides found..." ; Act accordingly
endif ; End if $Overrides
else ; Else (error reading INI file)
? "Error reading $OverrideIni" ; Complain
endif ; End if @ERROR = 0
Sorry if it doesn't fit nicely on most displays, but I use a 1600x1200 desktop resolution on my Dell Latitude C810 and I tend to use that resolution...
I've "sort of" tested this, and it should work... I say "sort of", because I'm at home now and InGroup seems to require a "live" DC present to work properly...
This way of doing things has the advantage that the core script stays the same and you just have to edit the .INI file to add/delete/change stuff...
Hope this helps,
Fernando Madruga
[ 22. August 2002, 00:06: Message edited by: Fernando Madruga ]