Hi Aaron, Thanks man, this one did have me puzzled, as I was unclear whether the actual INIFile object could create a file and open it. My understanding of it was I had to create and open the file then read from it, and then close it afterwards. Cheers!!! Warm regards. Martin Webster.
--- On Wed, 2/8/12, Aaron Smith <[email protected]> wrote: > From: Aaron Smith <[email protected]> > Subject: Re: help with the INIFile object > To: [email protected] > Date: Wednesday, February 8, 2012, 1:21 PM > Martin, > > INIFile is a Window-Eyes object. You're trying to set it to > a > FileSystemObject instead, which isn't going to work. INIFile > handles all > the reading and writing to INI files. You don't need to > involve any > additional file system objects. > > Your routine should look like this: > > Sub ReadIni() > iniString = > INIFile(ClientInformation.ScriptPath& > "\test.ini").GetINISectionNames() > iniArray = Split(iniString, vbNullChar) > For Each iniName In iniArray > Speak iniName > Next > End Sub > > You could shorten that even more by replacing the iniString > with the call to INIFile, like this: > > Sub ReadIni() > iniArray = > Split(INIFile(ClientInformation.ScriptPath& > "\test.ini").GetINISectionNames(), vbNullChar) > For Each iniName In iniArray > Speak iniName > Next > End Sub > > Aaron > > On 2/8/2012 1:22 AM, martin webster wrote: > > Hi All, > > How do I use the INIFile object. I am trying to get the > GetSectionNames example working from the ap developers > manual with no success what so ever. I created the structure > in notepad and saved it as a text file with a dot INI > extention called test.ini. > > The structure Follows. > > > > [Bosses] > > boss1=Doug > > boss2=Dan > > [Support] > > name1=Mike > > name2=Raul > > name3=Aaron > > > > I then wrote the following VBScript to attempt to > retrieve the section names. I keep getting the error object > doesn't support this property or wrong number of arguments, > and when I tried without calling the file system object, I > got the error no object or some such. > > > > Begin VBScript > > > > Dim MyHotkey > > Set MyHotkey = > Keyboard.RegisterHotkey("Control-Shift-Windows-i", > "ReadIni") > > Sub ReadIni() > > Dim FSO, ScriptPath > > Const ForReading = 1 > > ScriptPath = ClientInformation.ScriptPath& > "\test.ini" > > Set FSO = CreateObject("Scripting.FileSystemObject") > > Set INIFile = FSO.OpenTextFile(ScriptPath, ForReading) > > iniString = INIFile.GetINISectionNames() > > iniArray = Split(iniString, vbNullChar) > > For Each iniName In iniArray > > Speak iniName > > Next > > End Sub > > > > Output should be bosses and support. > > > > Please help, I have no ideas left here apart from just > writing a routine in VBScript to do the job of this object. > > Warm regards. > > Martin Webster. > > -- > Aaron Smith > Web Development * App Development * Product Support > Specialist > GW Micro, Inc. * 725 Airport North Office Park, Fort Wayne, > IN 46825 > 260-489-3671 * gwmicro.com > > To insure that you receive proper support, please include > all past > correspondence (where applicable), and any relevant > information > pertinent to your situation when submitting a problem report > to the GW > Micro Technical Support Team. > >
