Attached to won't work...

Hi,
I have a problem that totally confuses me… Near the start of the script, there is a piece of script that says "display window “license” attached to window “chooser”. Now, when that runs, I get the error “NSCannotCreateScriptCommandError (10)”. If I remove the “attached to” statement, it works fine. I can’t see anything wrong with the script, but maybe someone on here is clever enough to spot an error. :slight_smile:


on launched appstart
set configwin to window "config"
set license to window "license"
set mainw to window "main"
set regwin to window "registerwin"

-- display License

tell user defaults

if default entry "configon" exists then


set nol to contents of default entry "license"
if nol equals 0 -- display the panel

display license attached to window "chooser"
delay 0.1
tell license
set state of button "nol" to nol
end tell
end if



set hasrestart to contents of default entry "Restart"

if hasrestart equals "You Bet"
tell mainw
set contents of text field "restarttext" of tab view item "welcome" of tab view "maintabs" to "You don't need to restart"

set visible of button "reboot" of tab view item "welcome" of tab view "maintabs" to false
end tell
else
tell mainw
set contents of text field "restarttext" of tab view item "welcome" of tab view "maintabs" of mainw to "You must restart your Mac by clicking the restart button below."
end tell
end if

else

display configwin
end if
end tell



end launched

Thanks for your time!! :slight_smile:

-Elijah

In general I would try to avoid placing large portions of my code in tell blocks for odd objects since it is asking for problems. For example I would call user defaults only when I wanted something and then close the tell and keep the rest out.

If you move - display license attached to window “chooser” - from within the user defaults tell block to outside of it the error you report goes away. User defaults simply cannot do that.

I can’t shorten the tell block, because it has a few “if” statements inside it… :confused: