Dwayne Rothe wrote:
Here's a simple function (and test script - you need a field "inField" to get the input)Hi All, Trying to find the easiest way to rename a (new)string if it already exists in a list! If a user tries to add an existing name to a list I want it to be named the same but adding a digit to the end. e.g Example exists so name new entery to Example(2), Example(2) exists so name new to Example(3) e.t.c
any ideas woold be appreciated thanx.............
local lList = "ss, tt, ss(1), ss(2)," -- start with some values already there
on mouseUp
put field "inField" into t
put generateString(t, lList) & comma after lList
put "now have " && lList & cr after msg
end mouseUp
function generateString p, pList
if p is among the items of pList then
put 1 into i
repeat while p & "(" & i & ")" is among the items of pList
add 1 to i
end repeat
return p & "(" & i & ")"
else
return p
end if
end generateString-- Alex Tweedly http://www.tweedly.net
-- No virus found in this outgoing message. Checked by AVG Anti-Virus. Version: 7.0.308 / Virus Database: 266.8.6 - Release Date: 30/03/2005
_______________________________________________ use-revolution mailing list [email protected] http://lists.runrev.com/mailman/listinfo/use-revolution
