On 10/29/01 11:09 PM, eugen helbling wrote: > Hi LiangTyan, > just to demonstrate that the new "split"(I like them) can do in case of > duplicate removing. > > for example you have a field/variable having something like > "nameA,firstnameB" & cr & "nameA,firstnameC" > in it, you can use "split" handler to select names witout duplicates. > > get "nameA,firstnameB" & cr & "nameA,firstnameC" > split it by return and comma > get the keys of it -- in it you have "nameA" only one time
This could be a good trick on eliminating duplicate records, but I realised it could be a problem on URL parsing. If you try to submit a series of check-buttons or radio-buttons with browser: <html><head><title>MetaCard split test</title></head> <body> <form action="http://localhost/cgi-bin/echo.mt" method="get"> <input type="checkbox" value=1 name="option" checked>Option 1 <p><input type="checkbox" value=2 name="option" checked>Option 2</p> <p><input type="checkbox" value=3 name="option" checked>Option 3</p> <p><input type="submit"> </form> </body></html> The browser constructs the the following string and pass onto the server: http://localhost/cgi-bin/echo.mt?option=1&option=2&option=3 Suppose you are using a split command to parse the query string in the echo.mt script: put $QUERY_STRING into x split x by "&" and "=" put keys(x) into xKeys you'll get only "option" in xKeys, and x["option"] gives you "3". Hmm..... should I bug report this? Regards, LiangTyan Fui > regards > eugen > > LiangTyan Fui wrote: > >> >> Here is a function that I've written quite some time ago. It takes a list of >> text theList, separated by theitemDel, remove duplicate items in the list, >> and returns a new list without duplicate items. >> Unfortunately, this function running rather slowly on a large list (a few >> thousands records) - that is why I am posting here as a little "open >> source", Request For Comment: Make it faster guys! >> Remember, the sequence of the records cannot be changed, that say you are >> not likely to use sort. >> >> Regards, >> LiangTyan Fui >> >> ##### >> >> function stripDup theList,theitemDel >> # verify param >> if theList= "" then return "" >> if theitemDel = "" then put cr into theitemDel >> >> # >> set theitemDel to char 1 of theitemDel >> >> put number of items of theList into theListItem >> put 1 into k >> repeat >> put item k of theList into key1 >> repeat with c = theListItem down to k+1 >> if key1 = item c of theList then >> delete item c of theList >> subtract 1 from theListItem >> end if >> end repeat >> if k >= theListItem then exit repeat >> add 1 to k >> end repeat >> return theList >> end stripDup >> >> Archives: http://www.mail-archive.com/[email protected]/ >> Info: http://www.xworlds.com/metacard/mailinglist.htm >> Please send bug reports to <[EMAIL PROTECTED]>, not this list. > Archives: http://www.mail-archive.com/[email protected]/ Info: http://www.xworlds.com/metacard/mailinglist.htm Please send bug reports to <[EMAIL PROTECTED]>, not this list.
