PDA

View Full Version : Read ini file from the web to listbox


Ham
05-22-2006, 10:39 AM
Hello all

How can i Read a ini file from the web to a listbox?

the code i use to read a ini from the source file:

ListBox.SetEnabled("ListBox1", true);

ListBox.DeleteItem("ListBox1", -1);

result = INIFile.GetSectionNames(_SourceFolder .."\\AutoPlay\\Docs\\Menu List.ini");

for i,v in result do
inivalue = INIFile.GetValue("AutoPlay\\Docs\\Menu List.ini", "", v);
ListBox.AddItem("ListBox1", v, inivalue);
end

-- Sets The Focus to ListBox1
Page.SetFocus("ListBox1");

-- Sets Focus to First Item in list box
ListBox.SelectItem("ListBox1", 1)

And now i want to let it read form a domain.

Thanks in advance:yes

TheSpy
05-22-2006, 11:54 AM
You just need to download the INI file to the temp folder and do what is needed. I use the binary mode because some servers have problems sending in ASCII (text) mode.

Here's the code:


ListBox.SetEnabled("ListBox1", true);

ListBox.DeleteItem("ListBox1", -1);

-- download the ini file
HTTP.Download("http://www.domain.com/files/inifile.ini", _TempFolder.."\\inifile.ini", MODE_BINARY, 60, 80, nil, nil, nil);

result = INIFile.GetSectionNames(_TempFolder.."\\inifile.ini");

for i,v in result do
inivalue = INIFile.GetValue(_TempFolder.."\\inifile.ini", "", v);
ListBox.AddItem("ListBox1", v, inivalue);
end

-- Sets The Focus to ListBox1
Page.SetFocus("ListBox1");

-- Sets Focus to First Item in list box
ListBox.SelectItem("ListBox1", 1)