Code: Select all
;
; ------------------------------------------------------------
;
; MacOS User-Level Application Preferences
;
; using the CoreFoundation Framework
;
; example by AIR.
;
; Prefs file is saved to ~/Library/Preferences automatically
; ------------------------------------------------------------
;
textColorKey.s="defaultTextColor"
app_plist.s="org.pcode.testapp"
ImportC "/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation"
CFPreferencesSetAppValue(l1,l2,l3)
CFPreferencesCopyAppValue(l1,l2)
CFStringCreateWithCString(l1,s1.s,l2)
CFStringGetCStringPtr(l1,l2)
CFPreferencesAppSynchronize(l1)
EndImport
Procedure SetProperty(key.s,value.s,plist.s)
CFPreferencesSetAppValue(CFStringCreateWithCString(0,key,0),CFStringCreateWithCString(0, value, 0),CFStringCreateWithCString(0, plist ,0))
EndProcedure
Procedure SavePlist(plist.s)
CFPreferencesAppSynchronize(CFStringCreateWithCString(0, plist, 0))
EndProcedure
Procedure.s GetProperty(key.s,plist.s)
chkVal = CFPreferencesCopyAppValue(CFStringCreateWithCString(0,key,0),CFStringCreateWithCString(0, plist ,0))
If chkVal
*tmpPtr = CFStringGetCStringPtr(chkVal,0)
*tmp.String = @*tmpPtr
ProcedureReturn *tmp\s
Else
ProcedureReturn ""
EndIf
EndProcedure
SetProperty(textColorKey,"GREAN is MISSPELLED!",app_plist)
SetProperty("Author","Armando I. Rivera",app_plist)
SavePlist(app_plist)
Debug GetProperty(textColorKey,app_plist)
Debug GetProperty("Author",app_plist)
Code: Select all
defaults read org.pcode.testapp