### Map save & restore Settings

To use a Map to save and restore settings, following example with two settings UserID and Password
being saved in a text file settings.txt stored in the DirApp folder.
Note: The method CreateMap used is available as from B4J v2.00.
Example
' Define the global map
`Sub Process_Globals
' Global Map holding the settings
Public SettingsMap As Map
' Define the settings file which is read by the global settings map
Public SettingsFile As String = "settings.txt"
End Sub`
'Check if the settings file exists, else create a new file
If File.Exists(File.DirApp, SettingsFile) Then
SettingsMap = File.ReadMap(File.DirApp, SettingsFile)
Else
'Create a new map and save
SettingsMap = CreateMap ("Sortlist": "False", "ButtonTitles": "False")
File.WriteMap(File.DirApp, SettingsFile, SettingsMap)
End If
' Get the settings from the global map.
' IMPORTANT: Use exact case for the keys
Log("Get setting...")
If SettingsMap.Get("ButtonTitles") = "False" Then
btnInsert.Text = ""
End If
' If changes to the settings are made, save the changes to the global map
File.WriteMap(File.DirApp, SettingsFile, SettingsMap)
Example content of the settings file
#Sat Apr 12 09:24:03 CEST 2014
Sortlist=false
ButtonTitles=false

Changed: , Category: Map, File: T6C217M1600.htm, ID: 1600