setting buttons to do things

i’ve got a few buttons in an application that i’m making, and they’re not seeming to do anything. what i’ve got is:

on clicked the_button
	if the_button is equal to "publish button" then
		set post_content to the contents of "post Field"
		set post_title to the contents of "blog title"
		set content to post_content
		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, content as Unicode text, publish}}
				display dialog postid
			end tell
		end try
		close window "Post Window"
	end if
	if the_button is equal to "about close" then
		close window "About Page"
	end if
	if the_button is equal to "prefs close" then
		set blogid to contents of "blogidField"
		set username to contents of "bloggeridField"
		set userPassword to contents of "bloggerpwField"
		close window "Preferences Window"
	end if
	if the_button is equal to "prefs button" then
		show window "Preferences Window"
	end if
end clicked


i have also enabled each button for applescript in Interface Builder. can anybody help?

First, your code won’t do anything because you’re testing the buttons (which are objects with ID, names, titles, etc.) instead of the button names that you want to test against. Next, use a compound if-then-else statement.

You also need to specify the container of the text fields from which you are getting the content. Don’t use “content” as a variable name because it is a reserved property name (no need for a second variable anyway).

Don’t put the display dialog in the tell block of the xmlprc call, you probably want the dialog displayed by your AppleScript Studio app. Also, you probably don’t want a display dialog at all, but, rather a log command which will be sent to the run window when run from Xcode or the system log when run normally and viewable in the Console. You probably also want to capture the error returned in the same way.

This should help:

Jon


[This script was automatically tagged for color coded syntax by Convert Script to Markup Code]

will this approach to it work with applescript studio and that i’m using Interface Builder to make it?
if it doesn’t, does anybody know how to do it w/ applescript studio?

never mind! i found a way to do it. in my previous code you have to have “the name of” in the code, i.e.

if the name of the_button is "Whatever" then
             display dialog "whatever"
end if