I thought I would be smart and sort a table field using the first item and only lines 2 to the number of lines in the table.
The reason is to preserve "Default settings" called Default in item 1 of the first line, to remain in the first line.
Default
Armitage
Base
...... etc
by using
sort line 2 to NumberOfLines of field "SortedTable" ascending text by item 1 of each -- sorts from second item, text, ascending
This compiles, but will not run. It fails saying
"button "ID 1251": execution error at line 15 (sort: error sorting), char 1"
So, what is wrong with it, it makes sense to me?
A bit out of SORTS
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
Hi user#606,
I think "sort" will only accept one complete "container" to work with.
Try this:
...
put line 2 to -1 of fld "table field" into tField
set itemdel to TAB
sort lines of tField by item 1 of each
## DEFAULT = ascending and text
put tField into line 2 to -1 of fld "table field"
...
Not tested but should work
Best
Klaus
I think "sort" will only accept one complete "container" to work with.
Try this:
...
put line 2 to -1 of fld "table field" into tField
set itemdel to TAB
sort lines of tField by item 1 of each
## DEFAULT = ascending and text

put tField into line 2 to -1 of fld "table field"
...
Not tested but should work

Best
Klaus
-
- VIP Livecode Opensource Backer
- Posts: 10052
- Joined: Sat Apr 08, 2006 7:05 am
- Contact:
I don't know of a way to use chunk expressions to sort only part of a container, but you could write a function to handle that:
Code: Select all
on mouseUp
put SortAllButFirstLine(fld 1) into fld 2
end mouseUp
function SortAllButFirstLine pList
put line 1 of pList into tSaveLine
delete line 1 of pList
sort lines of pList
return tSaveLine &cr& pList
end SortAllButFirstLine
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
Sorted the SORT
I suspected there was no alternative but to introduce more variables to hold, sort and replace.
Thank you for your help though.
Thank you for your help though.