sorry if i’ve been asking a lot about this script, but i can’t find any other responsive places to post.
property bloggerApiKey : "0123456789ABCDEF" --Blogger API Key that anybody can use, it's not mine particularly
property publish : true
on clicked the_button
set the_button_name to name of the_button
if the_button_name = "publish button" then
tell window "Post Window"
set post_content to the contents of "post Field"
set post_title to the contents of "blog title"
end tell
try
tell application "http://plant.blogger.com/api/RPC2"
set postid to call xmlrpc {method name:"blogger.newPost", parameters:{bloggerApiKey, blogid, username, userPassword, post_title as Unicode text, post_content as Unicode text, publish}}
end tell
display dialog postid --you should just use a log statement if this is just for testing purposes: log postid
on error e
display dialog e -- log e
end try
close window "Post Window"
else if the_button_name = "about close" then
close window "About Page"
else if the_button_name = "prefs close" then
tell window "Preferences Window"
set blogid to contents of "blogidField"
set username to contents of "bloggeridField"
set userPassword to contents of "bloggerpwField"
close
end tell
else if the_button_name = "prefs button" then
show window "Preferences Window"
end if
end clicked
on choose menu item theObject
if the name of theObject is equal to "about page" then
show window "About Page"
end if
if the name of theObject is equal to "prefs window" then
show window "Preferences Window"
end if
if the name of theObject is equal to "hide menu" then
hide
end if
if the name of theObject is equal to "quit menu" then
quit
end if
if the name of theObject is equal to "new post" then
show window "Main Window"
end if
end choose menu item
whenever I try to debug it theres an NSCannotCreateScriptCommandError (10)
What do you do to invoke the error?
Lots of times, you have problems with object names or references to them. Eg, you’re calling text field “x” of window “y”, but the text field is unnamed or called “g” instead, or you are just calling text field “x” without refencing to window “y”…
Ie, you have:
I wasted nearly 4 days last month on a similar problem. I know my syntax was correct in trying to get the title of a popup menu of a window. I scoured the relevant dictionaries, “cleaned” the project, tried everything but would always get the NSCannotCreateScriptCommandError (10).
set userName to title of current menu item of popup button "usernames" of window "login"
which gives (inexplicably) the NSCannot… error, I use
set userName to call method "titleOfSelectedItem" of popup button "usernames" of window of theObject
which works everytime. It’s my humble opinion that if you intend to indulge in a lot of intensive non-vanillaish AS project building of any kind, it’s worth familiarizing yourself with this documentation.
first, try using “as Unicode text” and also use logging and try blocks to see what’s really going on:
on clicked the_button
try
set the_button_name to name of the_button as Unicode text
log "cllicked " & the_button_name
on error e
log "clicked error: " & e
end try
end clicked
is that supposed to be a test? because it still isn’t working. I guess i should change the title of this to “getting the buttons to work”. can someone help?
Are you sure your elements are connected to the main script in IB? It’s not enough to just have the actions checked but also the script to associate with those actions. Can you post your source so we can take a look? Yes, that was meant to be a test just to see what was being clicked. If you comment out your existing “on clicked” handler and insert the code above, it should log every button you click that is properly connected to your script in the Run Log when testing in Xcode or the System log viewable in the Console when running as a normal application.