problem with counting words
Peter M. Brigham
pmbrig at gmail.com
Wed Oct 15 10:24:07 EDT 2014
While we're waiting to see what comes of language extensions, here's a function that I use to simplify getting items from lists with various delimiters:
function getItem tList,tIndex,tDelim
-- returns item # tIndex of tList, given itemdelimiter = tDelim
-- could just "get item tIndex of tList" in the calling handler but
-- then have to set and restore the itemDelimiter, so this is less hassle
-- and doesn't risk your forgetting to reset it
-- defaults to tDelim = comma
if tDelim = empty then put comma into tDelim
set the itemdelimiter to tDelim
return item tIndex of tList
end getItem
If tList = "a/b/c*dd*e/f,g/h*i" and you wanted to extract the "dd" then you would call:
put getItem(getItem(tList,3,"/"),2,"*")
-- Peter
Peter M. Brigham
pmbrig at gmail.com
http://home.comcast.net/~pmbrig
On Oct 14, 2014, at 4:10 PM, DunbarX at aol.com wrote:
> Richard.
>
> Right, and I am sure you know this, but it was never particularly a speed issue,rather more a mental and organizational one, that would be even more opaque if you had, say a handful of nested delimiters instead of just two.
>
> Craig
>
> -----Original Message-----
> From: Richard Gaskin <ambassador at fourthworld.com>
> To: use-livecode <use-livecode at lists.runrev.com>
> Sent: Tue, Oct 14, 2014 3:46 pm
> Subject: Re: problem with counting words
>
> FWIW, changing the itemdel takes only about 0.00012 ms on a relatively
> slow (2.16GHz) Mac, and about a third as long (0.000043 ms) on my custom
> Linux box (3.0 GHz).
More information about the use-livecode
mailing list