...first, it is needed to create an empty file if there's no ini file, because there's no way to force OpenPreferences to do that for you
...CreatePreferences is not an option when having larger preference files or when including additional information (e.g. comments)
...but what, when the file is locked or set to read only?
There is no return value available for WritePreference commands and when trying to check a value by a ReadPreference the cached value will be displayed (see below):
Code: Select all
WonderIni.s="Test.ini"
If CreateFile(#Null,WonderIni)
CloseFile(#Null)
SetFileAttributes(WonderIni,#PB_FileSystem_ReadOnly)
EndIf
; Test code
If OpenPreferences(WonderIni)
Debug ReadPreferenceInteger("test",-1)
WritePreferenceInteger("test",9999)
Debug ReadPreferenceInteger("test",-1)
ClosePreferences()
EndIf