Save panel... not returning anything?

I am building a save panel for one of my applications, and what I want this save panel to to do is get a path I can send to the unix command line.

So, I searched the forums and found this.

Then, I borrowed the save panel code and “on panel ended code” to build something like this:

on panel ended theObject with result withResult
	if theObject is the save panel then
		if withResult is 1 then
			set saveOut to (path name of save panel)
		end if
	end if
	set savepanelfinished to true
end panel ended

on askForSave()
	
	tell save panel
		set title to "Download file as..."
		set can choose directories to false
		set can choose files to true
		set prompt to "Download"
		set treat packages as directories to false
	end tell
	display save panel attached to window "fileWin"
	
end askForSave

Then, I have another part of the code that looks like this:

else if theObject is button "beginBtn" of window "fileWin" then
		askForSave()
		if savepanelfinished is true then
			display dialog saveOut
		end if
	end if

The goal? To wait for the panel to finish it’s save “getting path” stuff, and then I display the result. But at the end of choosing where to save, I get nothing. Not even an error… :frowning:

What’s going on?

Hi,

Because the panel is attached to the window the clicked handler doesn’t wait for the response. The response is passed to the on panel ended handler, and you should call the display dialog etc. from inside this handler. See the relevant page on Apple’s site (look at the examples section toward the end of the page).

Best wishes

John M

Wow, thanks, that works great!

My application is nearing completion… :cool: