I would like to be able to read some data from a configuration file and put it in to an array.So far i've got :-
code:
$i = 0
DIM $groupname[3]
DIM $driveletter[3]
DIM $sharepath[3]
do
$groupname[$i] = readprofilestring("c:\config.ini","map_drives","$groupname[$i]")
$driveletter[$i] = readprofilestring("c:\config.ini","map_drives","$driveletter[$i]")
$sharepath[$i] = readprofilestring("c:\config.ini","map_drives","$sharepath[$i]")
if $groupname[$i] = "" or ingroup($groupname[$i])
use $driveletter[$i] $sharepath[$i]
if @error = 0
? "Connected " + $driveletter[$i] + " to " + $sharepath[$i]
else
? "Error connecting " + $driveletter[$i] + " to " + $sharepath[$i]
endif
$i = $i + 1
else
$i = $i + 1
endif
until $i = 3
The config file is formatted like:-
code:
[map_drives]$groupname[0] = ""
$driveletter[0] = "x:"
$sharepath[0] = "\\something\something"
$groupname[1] = ""
$driveletter[1] = "y:"
$sharepath[1] = "\\something\something"
$groupname[2] = ""
$driveletter[2] = "t:"
$sharepath[2] = "\\something\something"
The problem is I would like the script to work out the number of objects in the array and also the
code:
until $i =
.
So my questions is, is there a way of counting/reading the number of lines in a section of a config file?