Adding a new row to an empty outline

Hi,
I’m trying to catch an edge condition where an outline has had all its rows deleted. I am unable to fathom how my Applescript can add a new row. I have tried may different ways but all have failed.
Any ideas welcomed.
Here is a code snip :
try
– Record the position of the selected row
set tSelectedRow to last selected row of tDocument
on error
– ‘last selected row’ will raise an error if there are zero selected rows; add the
– new rows at the top level in this case

		--set tSelectedRow to make new row at (begining of every row) --**FAILS**
		make new row ?????
	end try

best wishes
Simon

You could try this code:

tell application "OmniOutliner"
    set oDoc to first document of it
    set oRow to make new row with properties {topic: "Hello World"} at end of rows of oDoc
    return oRow
end tell
1 Like

unlocked2412 - many many thanks for your code snip : I added it to my outline of really useful Applescript and the script I have been working on. I’m kicking myself because I tried a very similar syntax which I think use to work in OO3 but did not specify where the row should be created so obviously it failed.

:-)

best wishes
Simon

You’re welcome, @Simon.

FWIW, the at parameter takes a location specifier.

1 Like

What’s wrong with…

make new row

The location specifier is optional. Note that this assumes you are telling the document.

Mockman

Blockquote What’s wrong with…

make new row

far to simple ! ;-)

1 Like