#153210 - 2005-12-09 02:27 PM
ReadProfileString Used In a Loop?
|
tylan
Starting to like KiXtart
Registered: 2005-11-17
Posts: 115
Loc: Johnstown, PA
|
Can I use ReadProfileSttring in a loop?
INI File is formatted as so: [ComputerName] User=USERNAME IP=IPADDRESS Mac=MACADDRESS
How would I read each computername? The file has about 65 entries formatted as the example. I've done loops with the readline command, but I'm not exactly sure how to make the readprofile string work in a similar fashion. I want to have a variable extracted that is only one computername. Then the next time I read the file, I want the next computername, and so on.....
Thanks in advance.
|
|
Top
|
|
|
|
#153213 - 2005-12-09 02:44 PM
Re: ReadProfileString Used In a Loop?
|
Radimus
Moderator
   
Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
|
|
|
Top
|
|
|
|
#153214 - 2005-12-09 02:46 PM
Re: ReadProfileString Used In a Loop?
|
Radimus
Moderator
   
Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
|
Code:
$sections = split(readprofilestring($SoftFile,'',''),chr(10)) for each $section in $sections if $section > " " $SoftInv = Getini($SoftFile,$section,chr(9)) for each $entry in $SoftInv ... next endif next
|
|
Top
|
|
|
|
#153216 - 2005-12-09 03:45 PM
Re: ReadProfileString Used In a Loop?
|
tylan
Starting to like KiXtart
Registered: 2005-11-17
Posts: 115
Loc: Johnstown, PA
|
You guys amaze me. I've never seen a message board with such quick responses! Thanks. I'll take a look at each suggestion!
|
|
Top
|
|
|
|
#153217 - 2005-12-09 04:41 PM
Re: ReadProfileString Used In a Loop?
|
tylan
Starting to like KiXtart
Registered: 2005-11-17
Posts: 115
Loc: Johnstown, PA
|
I don't quite understand the usage of the CHR command. I know it's a chracter code, but I don't see why it's in the examples.
|
|
Top
|
|
|
|
#153219 - 2005-12-30 07:05 PM
Re: ReadProfileString Used In a Loop?
|
tylan
Starting to like KiXtart
Registered: 2005-11-17
Posts: 115
Loc: Johnstown, PA
|
What's wrong with this code? Code:
BREAK ON $file1 = Open(1,"activeusers.csv",5) $inifile = "C:\Documents and Settings\Administrator.SOMEHOSP\Desktop\Admin Tools\KIX-Work\active-users.ini" $listOfSections = readprofilestring($inifile,"","") $splittedList = split($listOfSections,chr(10))
for each $section in $splittedList $user=readprofilestring($inifile,$section,"user") $os=readprofilestring($inifile,$section,"os") $ip=readprofilestring($inifile,$section,"ip") $date=readprofilestring($inifile,$section,"lastbootdate") $x = Writeline(1, $section + ","+ $user + "," + $os + "," + $ip +","+ $date + @crlf) $section + ","+ $user + "," + $os + "," + $ip +","+ $date + @crlf ;sleep 1 next
The CSV file has the first 48 or so lines correct, then it duplictes the INI file section names over again. It seems to do it as many times as I have the $section in the for..next loop.
Thanks in advance.
|
|
Top
|
|
|
|
#153221 - 2005-12-31 03:45 AM
Re: ReadProfileString Used In a Loop?
|
tylan
Starting to like KiXtart
Registered: 2005-11-17
Posts: 115
Loc: Johnstown, PA
|
Thanks. I will check it out.
|
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
0 registered
and 2220 anonymous users online.
|
|
|