how to sort lines with a $ amount

Geoff Canyon gcanyon at gmail.com
Tue Apr 1 05:06:32 CEST 2014


No fair, Jacque, I *just* finished testing:

function dollarsAsNumber D
   if char 1 of D is "$" then return char 2 to -1 of D else return D
end dollarsAsNumber

gc


On Mon, Mar 31, 2014 at 10:02 PM, J. Landman Gay
<jacque at hyperactivesw.com>wrote:

> On 3/31/14, 9:03 PM, larry at significantplanet.org wrote:
>
>> I can sort the lines of the field just fine on word 1 (date),  word 2
>> (name) and word 3 (number)
>>
>> But when I try to sort on word 4, I don't know how to get it to come
>> out right because the $ in front makes it a string and not a number.
>>
>
> You can sort using a custom function and that's what I'd do here. If the
> values are in field 1, then:
>
> on mouseUp
>   sort lines of fld 1 numeric by moneySort(each)
> end mouseUp
>
> function moneySort pItem
>   if char 1 of pItem = "$" then delete char 1 of pItem
>   return pItem
> end moneySort
>
> Custom function sorting can do all kinds of clever things. The "each" is
> passed to the function and the sort uses the return value to determine the
> final order.
>
> --
> Jacqueline Landman Gay         |     jacque at hyperactivesw.com
> HyperActive Software           |     http://www.hyperactivesw.com
>
>
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>


More information about the use-livecode mailing list