Sort bug

Alex Tweedly alex at tweedly.net
Thu Aug 31 19:53:23 EDT 2023


On 01/09/2023 00:37, Bob Sneidar via use-livecode wrote:
> The function is adding the value of two chunks together and returning the result. How does that even compute? Unless the + operator is doing something totally different here…

The code said:

> sort lines tVariable by myVal(each)
>
> where the function is for example
>
> function myVal pStr
>     return item 1 of pStr + item 2 of pStr
> end myval
since it's sorting the lines of the container, it calls the custom 
function with each line in turn. The function simply adds together the 
first two items from the passed-in line, and returns that. The returned 
value is associated with the corresponding line - and then the container 
is sorted by those associated values.

This works fine if the input variable is well formatted (i.e. first and 
second items of each line are numeric), but fails to give an error when 
something goes wrong - such as a non-numeric item.

(and, yes - the dictionary description is misleading, if not simply 
incorrect. However, the "Tip" at the end describes the use of ustom 
functions).

Alex.




More information about the use-livecode mailing list