You have probably solved your problem already, but here's what I use for counting occurrences of strings in containers:
function howmany tg,container -- how many tg = <target string> is in container -- note that howmany("00","000000") returns 3, not 5 -- if you want to allow overlapping matches, use: -- number of items of offsets(tg,container,"true") -- (see offsets() function) -- requires getDelimiters() put getDelimiters(container) into divChar replace tg with divChar in container set the itemdelimiter to divChar put the number of items of container into h if char -1 of container = divChar then return h -- trailing delimiter is ignored return h-1 end howmany function getDelimiters tText,nbr -- returns a cr-delimited list of <nbr> characters (default = 1) -- not found in the variable tText -- use for delimiters for, eg, parsing text files -- usage: put getDelimiters(CSVtext,2) into tDelims -- put line 1 of tDelims into lineDivider -- put line 2 of tDelims into itemDivider -- set the linedelimiter to lineDivider -- ... etc. if nbr = empty then put 1 into nbr -- default 1 delimiter put "2,3,4,5,6,7,8" into dList -- could use other non-printing ASCII values put the number of items of dList into maxNbr if nbr > maxNbr then return "Error: max" && maxNbr && "delimiters." repeat with tCount = 1 to nbr put true into failed repeat with i = 1 to the number of items of dList put item i of dList into testNbr put numtochar(testNbr) into testChar if testChar is not in tText then -- found one, store and get next delim put false into failed put testChar into line tCount of delimList exit repeat end if end repeat if failed then if nbr = 1 then return "Cannot get delimiter!" else return "Cannot get" && nbr && "delimiters!" end if end if delete item i of dList end repeat return delimList end getDelimiters -- Peter Peter M. Brigham pmb...@gmail.com http://home.comcast.net/~pmbrig -- View this message in context: http://runtime-revolution.278305.n4.nabble.com/Syntax-for-incrementing-a-numeric-word-tp4651342p4651355.html Sent from the Revolution - User mailing list archive at Nabble.com. _______________________________________________ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode