Open Panel Ended - Error

yep - i think third thread today LOL

in any case.

i used to have this to choose my folder:

on set_choose_folder()
	set the_site_folder to (choose folder) as string
end set_choose_folder

it has now turned into this:

on set_choose_folder()
	-- set the_site_folder to (choose folder) as string
	
	set can choose directories of open panel to true
	set can choose files of open panel to false
	display open panel attached to window "main"
	
	
end set_choose_folder

on panel ended theObject with result withResult
	if withResult is 1 then
		
		set the_site_folder to item 1 of (path name of open panel as list)
		
		set the_site_folder to the_site_folder as string
	end if
end panel ended

I am now getting a error of cant getting alias/

any ideas?

i got this open panel code from this: http://developer.apple.com/documentation/AppleScript/Reference/StudioReference/sr10_panel_suite/sr_panel.html#//apple_ref/doc/uid/20011224-ASKPanelSuite.Classes.NSOpenPanel

the script itself seems to be working - but my other scripts need the the_site_folder as a string or in the way it got received from the original script i had.
what i basically want is the open panel to be attached to the main window :smiley:

lastly, one more thing. if i hit the choose folder button. it works once. then, if i try to do it again, i get the funk sound. is it restricted in some way? can it be told to run several times (to open the open panel)?

phew - :stuck_out_tongue:

the path returned of a panel is a POSIX path (slash delimited),
to get an alias, you must coerce it


.
set the_site_folder to POSIX file the_site_folder as alias
.

fix this first, then we can think about the other error

hey stefan,

again thanks.

this works now:


		
		
		
		set the_site_folder to (item 1 of (path name of open panel as list)) as string
		
		set the_site_folder to POSIX file the_site_folder as string

any ideas on why it only allows me to open the open panel once?

max

No, maybe it’s something wrong with the on clicked handler

Side note:path names returns a list of Unicode text; path name returns a single path as Unicode text. Use whichever one is appropriate and remove the unnecessary coercions.

-- Single Item
set the_site_folder to path name of open panel

-- Multiple Items
set the_site_folder to path names of open panel

okay i changed that.

any ideas on why it only allows me to open the panel once?

max