In Script Editor, you run a script in the foreground by holding the control key when running it, or pressing control-command-R. You can see the Run command change names in the Script menu when you hold down the control key. In ASObjC Explorer you check the 'Run in foreground' checkbox at the bottom of the script window.
use AppleScript version "2.4"
use scripting additions
use framework "Foundation"
-- make panel
set openPanel to current application's NSOpenPanel's openPanel()
tell openPanel
-- set main values
its setMessage:"Your message here" -- AS's prompt
-- other values you *can* set
its setDirectoryURL:(current application's NSURL's fileURLWithPath:(POSIX path of (path to desktop))) -- AS's default directory
its setAllowsMultipleSelection:true -- AS's multiple selections allowed
its setAllowedFileTypes:{"txt"} -- AS's of type. Provide missing value for all types
its setShowsHiddenFiles:false -- AS's invisibles; default is false
its setTreatsFilePackagesAsDirectories:false -- AS's showing package contents; default is false
its setTitle:"Choose a File" -- Panel's title; default is "Open"
its setPrompt:"Open" -- Override name on button; default is "Open"
its setCanChooseFiles:true -- whether it's like choose file; default is true
its setCanChooseDirectories:true -- whether it's like choose folder; default is false
its setResolvesAliases:true -- whether aliases are automatically resolved; default is true
end tell
-- show panel
set returnCode to openPanel's runModal()
if returnCode is (current application's NSFileHandlingPanelCancelButton) then
error number -128
end if
-- get chosen paths and tags
set thePosixPaths to (openPanel's |URL|()'s valueForKey:"path") as list
set theTags to openPanel's tagNames()
if theTags = missing value then
set theTags to {}
else
set theTags to theTags as list
end if
return {thePosixPaths, theTags}