From pasteboard to table view column

Hi,

all things are from beginning now!

One (of a lot of) problem(s) for me is how to manage in ASOC to set a list (i.e. a list of names) into a table view’s column.
The" old" AS-method:
set thecontent to contents of pasteboard “general”, etc. doesn’t operate obviously.

Greetings
Heiner

Depending on what you’re trying to achieve, you may do best to use bindings.

Hi Shane,
thanks for your reply;

my first problem is to get access to the pasteboard itself. I had a look in the documentation. There I found that NSPasteboard is inherited from NSObject (so far so good), but I can’t ‘tanslate’ ObjC to ASOC yet. What I need is a basic sample how to use a pasteboard. I add the handler (in ASS) which I have to replace.


on setNames() -- a handler in ASStudio
	set oldTextItemDelimiters to AppleScript's text item delimiters
	set AppleScript's text item delimiters to return
	set preferred type of pasteboard "general" to "string"
	
	if pasteboard "general" is not "" then
		try
			set theContents to contents of pasteboard "general"
			set theCount to (count of text items of theContents)
			if last text item of theContents is "" then -- a return after last name
				set theCount to theCount - 1
			end if
			set update views of myDataSource to false
			repeat with n from 1 to theCount
				set theDataRow to make new data row at the end of data rows of myDataSource
				set contents of data cell "name" of theDataRow to text item n of theContents
			end repeat
			set update views of myDataSource to true
			set modified of document of window "main" to true
		on error
			display alert "Error!" message "Pasteboard is empty." as critical default button "OK" attached to window "main"
		end try
	end if
	set AppleScript's text item delimiters to oldTextItemDelimiters
end setNames

Thanks in advance

Heiner

PS: I have examined your example ‘Coming to Florida’. Thanks for that example!

You might think about using AS to get the clipboard – it’s simpler than pasteboards. Then, if you have the contents bound to a variable, you can set the value of the variable to the contents of the clipboard as a list.

Thank you Shane!

I got it and that’s my solution:


property parent : class "NSObject"
	
	property theData : missing value
	
	property theName : ""
	
	
	-- IB Actions (button clicks)
	on setNames_(sender)
		try
			set theContents to the clipboard as string
		end try
		set oldTextItemDelimiters to AppleScript's text item delimiters
		set AppleScript's text item delimiters to return
		set theCount to (count text items of theContents)
		repeat with i from theCount to 1 by -1 -- otherwise it's in inverse direction; ('first in, last out' ?)
			set my theData to {{theName:text item i of theContents, nr1:"", nr2:"", nr3:"", sum:""}} & my theData
		end repeat
		set AppleScript's text item delimiters to oldTextItemDelimiters
	end setNames_
	
	##########################
	-- Application
	
	on awakeFromNib()
		set my theData to {{theName:"", nr1:"", nr2:"", nr3:"", sum:""}} -- it seems to be necessarily (otherwise the app hangs; but I get an empty line in the table view
	end awakeFromNib
	

Maybe there is a better solution. I’m very interested in that.

Heiner