Hi Guys,
The function below reads in each section and it's data from a config file into an array. The array is then rename to the section name. This works ok when each section has data, but as soon as one of the sections doesn't have any data it screws up. The script reads in the data from the next section into an incorrectly named array.
Any idea on how to fix the problem?
code:
FUNCTION ReadProfileSectionData()
DO
IF INSTR($line, "[") = 1
$pos_start = INSTR($line, "[") + 1
$pos_finish = INSTR($line, "]") - 2
$section_name = SUBSTR($line, $pos_start, $pos_finish)
$section_name = LCASE($section_name)
GLOBAL $section_data[0]
$i = 0
DO
$line = READLINE(1)
SELECT
CASE $line = ""
CASE INSTR($line, ";") = 1
CASE INSTR($line, "[") = 1
CASE 1
REDIM PRESERVE $section_data[$i]
$section_data[$i] = $line
$i = $i + 1
ENDSELECT
UNTIL INSTR($line, "[") = 1
$result = EXECUTE("$$$section_name = $section_data")
ELSE
$line = READLINE(1)
ENDIF
UNTIL $line = "[END]"
ENDFUNCTION
code:
config.ini
[TESTLAB]
subnet=192.168.99
[EXCLUDED_HOSTS]
hostname=12345
hostname=12345
hostname=12345
hostname=12345
hostname=12345
hostname=12345
hostname=12345
hostname=12345
[SHARES]
share0_groupname=domain admins
share0_driveletter=S
share0_path=\\eee\installs$
share1_groupname=staff
share1_driveletter=W
share1_path=\\eee\temp
share2_groupname=
share2_driveletter=X
share2_path=\\eee\data
[END]
(MCA: complete subject)
[ 18 July 2002, 08:43: Message edited by: MCA ]