handle documents

I set up a doucument based ASS App. I can save and open but have some circumstances I can not see why?

If I have no document open and open a saved one a new doc is build with the right content, if I have a doc open and open a saved one the content will be loaded to the already open window (independent of a potential content - it will be added if there is content) and a new blank document open up as well.

Also, when I added content to a doc and close it there’s no automatic option that says “it is not saved, do you want to save it now?”.

I tooked a deeper look to the “tasklist” example from apple and it seems, that I set all in the same way, but in “tasklist” everything wor like it should.

So what is wrong?

This is my data representation code:


on data representation theObject of type ofType
	set kara_window to window 1 of theObject
	set kara_source to data source of table view "view" of scroll view "view" of kara_window
	set kara_content to contents of every data cell of every data row of kara_source
	set kara_data to {names:kara_content}
	return kara_data
end data representation


on load data representation theObject of type ofType with data kara_data
	set kara_window to window 1 of theObject
	set kara_source to data source of table view "view" of scroll view "view" of kara_window
	append the kara_source with (names of kara_data)
	return true
end load data representation

thx -ph

From the looks of things, it appears that you are setting kara_window to the already open window. Try changing

set kara_window to window 1 of theObject

to:

set kara_window to item 1 of (window of theobject)

I found, looking at 1 of my projects, that the window comes in list form.

When you do something to modify the document, add the following to your code:

set the modified of the document of kara_window to true

Hope this helps,
Brad Bumgarner, CTA


set the modified of the document of kara_window to true

works great. The other works half and half. If I open the doc without another doc open I get a new doc with the content and the doc icon on top of the window. If I have an open doc and open my saved doc it loads the content to the already open doc and opens the doc without the expected content.

try putting a log statement in the load data representation statement for theObject, i.e.:

on load data representation theObject of type ofType with data kara_data
     log theObject
     . . .
     . . .
end data representation

I’ll admit, this is off the top of my head. I use log statements frequently to find out how data is handled. You may need to be more specific with the log statement.

Hope this helps,
Brad Bumgarner, CTA

The log file tells me the same for both cases. Hmmmm.

But i figured out, that the described case only happens, if the new document is unsaved.

Perhaps this lets you have another idea ;-).

But till here lot of thanks!

What verion of Applescript Studio are you using? There were changes made (dealing with documents, among other things) between vers. 1.2 and 1.3.

Other than that, I don’t have any other suggestions.
Brad Bumgarner, CTA

Have version 1.2 will upgrade now to 1.3 and see whats happen. Thank you very much!

Sorry to bump old threads, but I have this exact same problem with my application. Task List works fine; mine, which is based off Task List, does not.
Does anybody have any clues as to why this happens?

I suppose this is a rather minor issue, but I would like anyone with information about this to please post as this is very annoying…

I think there could be a possible workaround by getting the user to save the document before working on it, but how would this be done?