Sort Command in 3.5 is adding lines to a variable

Alex Tweedly alex at tweedly.net
Thu Jul 2 15:07:55 EDT 2009


Pierre Sahores wrote:
> Try this ;
>
> Put "Dog" & cr & \
>      "Cat" & cr into tTemp
>  Put number of lines in word 1 to -1 of tTemp into tPreSortCount
>  sort tTemp
>  Put number of lines in word 1 to -1 of tTemp into tPostSortCount
>  Put "Pre-Sort, variable tTemp has" && tPreSortCount && "lines."& 
> return &\
>  "Post-Sort, variable tTemp has" && tPostSortCount && "lines."

That gives 2 and 2. But if you remove the "word 1 to -1 of" in each 
case, to simply use
> Put "Dog" & cr & \
>      "Cat" & cr into tTemp
>  Put number of lines in tTemp into tPreSortCount
>  sort tTemp
>  Put number of lines in tTemp into tPostSortCount
>  Put "Pre-Sort, variable tTemp has" && tPreSortCount && "lines."& 
> return &\
>  "Post-Sort, variable tTemp has" && tPostSortCount && "lines." 
then you get
Pre-Sort, variable tTemp has 2 lines.
Post-Sort, variable tTemp has 3 lines.

However, if you go back to 3.0, then both versions of the script give you
Pre-Sort, variable tTemp has 2 lines.
Post-Sort, variable tTemp has 2 lines.

So it is certainly a change in the result between 3.5 and earlier 
versions. I have a very vague feeling I saw something about this 
(discussion, bug report, ????) but cannot find it again. Could it have 
been a deliberate change in behaviour - i.e. fixing a previous "bug" ?  
I'm sorry that I can't remember what it was i saw (or imagined) about 
this - but I can confirm it is a change in result between the recent 
versions.

(Maybe Pierre was suggesting using "word 1 to -1 of" as a work-around 
that gives the same result in all versions ?
 if so, another work-around is to delete the trailing CR before the sort 
is done)

-- Alex.






More information about the use-livecode mailing list