Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

getting the result of an open panel



the following clicked handler is attached to a button, the panel ended
handler is attached to the main window of my application.
The window has a table view called "names" which is already loaded (
using an awake from nib handler) with the names of the files in my
desktop folder.
I am attempting to change the source folder of the table view to the
folder chosen(result) of the open panel.
I keep getting "NSCannotCreateScriptCommandError (10)" errors
any thoughts?

many thanks
Peter

(* ==== Properties ==== *)
property theFolder : ""
property folderName : ""
property tableData : {}
property fileList : {}


(*------- handlers-------*)
on clicked theObject
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 clicked

on panel ended theObject with result withResult
if withResult is 1 then

set theFolder to (path names of open panel as list)

tell application "Finder"

set fileList to name of every file in folder theFolder as list
repeat with fileItem in fileList
copy fileItem as list to end of tableData
end repeat
end tell

-- Create the data source
set theDataSource to make new data source at end of data sources with
properties {name:"names"}

-- Create each of the data columns, including the sort information
for each column
make new data column at end of data columns of theDataSource with
properties {name:"name", sort order:ascending, sort type:alphabetical,
sort case sensitivity:case sensitive}

-- Make this a sorted data source
set sorted of theDataSource to true

-- Set the "name" data column as the sort column
set sort column of theDataSource to data column "name" of
theDataSource

-- Set the data source of the table view to the new data source
set data source of theObject to theDataSource

-- Add the table data (using the new "append" command)
log tableData

append theDataSource with tableData

tell window 1
tell table view "names" to update
end tell
end if
end panel ended
_______________________________________________
applescript-studio mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/applescript-studio
Do not post admin requests to the list. They will be ignored.



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.