Problem with changing .plist booleans...

My Project File
Above is my project file for reference.

I am trying to make a simple GUI app to change two hidden dock preferences.
I have two buttons (in the project called HideApps and OpenApps) which ‘toggle’ the state of these two boolean preferences.
Here is my code for one of the button’s action handler:

[code] ProgressWheel1.Visible=true
OpenApps.Enabled=false
Dim s1 As Shell
s1 = New Shell
#If TargetMacOS Or TargetLinux Then
s1.Execute(“defaults read com.apple.dock single-app”)
#Endif
// MsgBox(s1.Result)
Label4.Text=("Current Value (Single-App): " + s1.Result)

App.SleepCurrentThread(300)

dim f as new shell
If Label4.Text = “Current Value (Single-App): 1” then
f.Execute (“defaults write com.apple.dock single-app -boolean false; killall Dock”)
elseif Label4.Text = “Current Value (Single-App): 0” then
f.Execute (“defaults write com.apple.dock single-app -boolean true; killall Dock”)
end if

App.SleepCurrentThread(300)

Dim s2 As Shell
s2 = New Shell
#If TargetMacOS Or TargetLinux Then
s2.Execute(“defaults read com.apple.dock single-app”)
#Endif
Label4.Text=("Current Value (Single-App): " + s2.Result)
OpenApps.Enabled=true
ProgressWheel1.Visible=false[/code]
For some reason, the middle block (which actually toggles the value) fails to disable it and only enables it.

Any ideas for some diff. code which works or something to fix in my code?

I seem to recall that defaults doesn’t use True or False, check the man page for defaults.

I would also recommend that you investigate doing this via NSUserDefaults which are APIs for manipulating application preferences.

There are diff. types of defaults, some are booleans, some are strings, etc.

I’ll check out NSUserDefaults. Is it implemented in Xojo?

You missed Sam’s point. Some booleans are YES/NO for Apple instead of TRUE/FALSE, and there could be other variations. Check the man page for defaults to find out what you need to use.

Yes, but running the individual commands from Terminal work. Running them from Shell (Terminal) in Xojo should be exactly the same, yeah?