"sorted data rows" of a data source __doesn't__ work every time

Hi *,
I’ve a hard :stuck_out_tongue: problem with property “sorted data rows” of my data source connected to a table view: it doesn’t work every time… :mad:

Here is my code:


set theDataSource to data source table view "x" of scroll view "x" of window "main"
set sortedDataRows to (sorted data rows of theDataSource) -- <-- this row doesn't work every time
set numSortedRows to (count of sortedDataRows)

P.S. Of course theDataSource’s “sorted” property is set to true and “sort column” set to one of his columns.

At run-time the error message of dialog box says: “AppleScript error: the variable sortedDataRows is not defined (-2753)” :frowning:
In “build and debug” mode with a breakpoint on the signed row of my code doesnt’ work every time: in “locals” sometime I see

Model: ;ac
AppleScript: 1.4
Browser: Firefox 1.0.4
Operating System: Mac OS X (10.4)

Sorry… :stuck_out_tongue:

…in “Locals” sometimes I see the correct “sortedDataRows” list but most of times i see nothing :frowning:

Same problem with XCode 2.0 and 2.1

Please, help me
Thanks,
sixware.

property sortedDataRows : null

???
(Don’t really know)

I use that code without parentheses and haven’t noticed it not selecting the correct rows. I don’t know why the parentheses would matter though.

Querty Denzel wrote:

I try your code but the problem remains unsolved.
I try “set sortedDataRows to {}” before
“set sortedDataRows to sorted data rows of theDataSource”,
but the result is the same (the variable “sortedDataRows” is not defined)

y2k wrote:

Same problem with or without parentheses…

Now, I think that I would have to implement a QuickSort function to do data source sorting by myself… :frowning:
Thanks for opinions,
sixware

Shouldn’t this be:

set theDataSource to data source of table view “x” of scroll view “x” of window “main”

Even though this tread started in 2005 I’ll post this hint for everyone like me, who couldn’t get the ‘set sortedDataRows to (sorted data rows of theDataSource)’ to work properly.

It seems that the ‘sorted data rows of theDataSource’ Statement only returns a result if the ‘theDataSource’ IS ACTUALLY sorted.

Otherwise the variable ‘sortedDataRows’ will not be defined.

So you 'll have to test the sort condition of ‘theDataSource’ first:

if sorted of theDataSource = true then
   set sortedDataRows to (sorted data rows) of theDataSource
else
   set sortedDataRows to data rows of theDataSource
end if

Hope someone will find this helpful.

Stephan