The PropertyFile component represents a persistent set of key=value pairs (properties). The properties can be loaded from or saved to a file. Each key and its corresponding value in the property list is a string.
The following example creates a properties file:
propFile = Fuego.Io.PropertiesFile("C:\\tmp\\config.properties")
put propFile using key = "user.email", value = "some@email.test"
put propFile using key = "user.profile", value = "expert"
store propFile
The following example retrieves the value for a given key. If the key does not exist, the default value is displayed.
propFile = Fuego.Io.PropertiesFile("C:\\tmp\\config.properties")
emailProperty = get(propFile, key : "user.email", defaultValue : "No Value")
display ("Value for key 'email' : " + emailProperty)
The following example loads and displays all properties from a file:
configFile = Fuego.Io.PropertiesFile("/tmp/config.properties")
for prop in configFile.values
do
propValue = configFile.values[prop]
display prop + "="+ propValue
end