I started to use the StateManager. After downloading it and unzipping it, I copied StateManager.bas into my project where the other .bas files were located. I added it into the project as an existing module and it showed up as a tab so I could see the coding of the module. When I tried to save the project I got an error on the If statement. Is this module incomplete?
This is the If statement that gave the error:
B4X:
If Settings.IsInitialized = False Then
This is the Sub that has the If statement:
B4X:
Sub GetSetting2(Key As String, DefaultValue As String)
If Settings.IsInitialized = False Then
'load the stored settings
If File.Exists(File.DirInternal, settingsFileName) Then
Settings = File.ReadMap(File.DirInternal, settingsFileName)
Else
Return DefaultValue
End If
End If
Dim v As String
v = Settings.GetDefault(Key.ToLowerCase, DefaultValue)
Return v
End Sub
Actually, all I did was to copy and install the StateManager.bas code module and not use it yet.
Usually when I add a code module to my project I do a ctrl-s to save the project. That's when the error popped up. It popped up in the code module. Once I can get the code module saved then I will try to use it. Looks like there may be something missing from the coding of the StateManager.bas code module.
Did the StateManager get changed slightly? I'm using v1.01 and settings is in lowercase...?
ETA : Nope, that doesn't seem to be the problem - are you sure you haven't edited the bas file incorrectly in some way? I would suspect that something else, elsewhere is generating this error for you.
Sub GetSetting(Key As String)
Return GetSetting2(Key, "")
End Sub
I did get it to compile and run by adding a new map called SettingsEmad and changed all of the parts of the module that used to have Settings and even got a "False" when I ran this code from my "Main" module: