The Omni Group Forums

The Omni Group Forums (http://forums.omnigroup.com/index.php)
-   OmniFocus Extras (http://forums.omnigroup.com/forumdisplay.php?f=44)
-   -   Delete paragraph from rich text (http://forums.omnigroup.com/showthread.php?t=13364)

ganwell 2009-08-11 01:08 AM

Delete paragraph from rich text
 
Hello

This is actually an applescript problem, but Omnifocus related.

I like to delete a line (paragraph) from a task's note. Here is the method:

[QUOTE]
on removeTotal(myNote)
set myLines to paragraphs of myNote
repeat with i from (count myLines) to 1 by -1
if item i of myLines contains mySpentMark then
tell myNote to delete paragraph i
end if
end repeat
end removeTotal
[/QUOTE]

tell myNote to delete paragraph i

is the line that doesn't work. I get the message: "The note as text" doesn’t understand the delete message.

I tried quite a number of syntax variations, this one I took from a TextEdit example. The rich text class understands delete, is myNote not a rich text anymore? But it understands paragraphs !?

Here is the complete script:

[url]http://pastebin.com/m55cd8e7c[/url]

Thanks for any hint!

Best,
Ganwell

ganwell 2009-08-12 06:56 AM

I found the error by myself. The set-command somehow converted the note. I passed the container of the note to the event and it works:

[CODE]
on removeTotal(myContainer)
set myLines to paragraphs of note of myContainer
set myCount to count of myLines

repeat with i from myCount to 1 by -1
if item i of myLines contains mySpentMark then
tell note of myContainer to delete paragraph i
end if
end repeat
end removeTotal
[/CODE]

Best,
Ganwell


All times are GMT -8. The time now is 05:22 PM.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, vBulletin Solutions, Inc.