Almost every application needs to use some sort of configuration file to store configurable values.
The attached Properties module, can load and save keys and values in a simple syntax.
This library uses hashtables from agraham's collections library to store the pairs of keys and values in an efficient data structure.
You can use this module to work with any number of properties files.
A (very) small example is also included in the zip file.
The file syntax is:
The attached Properties module, can load and save keys and values in a simple syntax.
This library uses hashtables from agraham's collections library to store the pairs of keys and values in an efficient data structure.
You can use this module to work with any number of properties files.
A (very) small example is also included in the zip file.
B4X:
Sub App_Start
'Load an existing properties file:
[B]p = Properties.Load("test.ini")[/B] 'Returns the handle to the properties table.
ListBox1.Add("Width: " & [B]Properties.GetProperty(p,"Width")[/B])
ListBox1.Add("Height: " & [B]Properties.GetProperty(p,"Height")[/B])
ListBox1.Add("Name: " & [B]Properties.GetProperty(p,"Name")[/B])
Form1.Show
'Change some properties and save the file:
[B]Properties.AddProp(p,"Width",333)
Properties.AddProp(p,"Height",111)
Properties.AddProp(p,"Name","New Name")
Properties.Save(p,"test.ini")[/B]
End Sub
The file syntax is:
B4X:
'This is a comment
'Key=Value
Width=200
Name=Some Name
Height=300