/* StrayRemDup - Removes duplicates in an array-string DESCRIPTION Removes duplicates in Stray and returns the result. Elements are defined by two seperators as ASCII coded characters: isep1 defaults to 32 (= space), isep2 defaults to 9 (= tab). If just one seperator is used, isep2 equals isep1. Requires the UDOs StrayLen and StrayGetEl SYNTAX Srem StrayRemDup Stray [, isep1 [, isep2]] INITIALIZATION Stray - a string as array isep1 - the first seperator (default=32: space) isep2 - the second seperator (default=9: tab) Srem - the resulting output string CREDITS joachim heintz april 2010 / january 2012 */ opcode StrayRemDup, S, Sjj ;removes duplicates in Stray and returns the result. elements are defined by two seperators as ASCII coded characters: isep1 defaults to 32 (= space), isep2 defaults to 9 (= tab). if just one seperator is used, isep2 equals isep1. ;requires the UDOs StrayLen and StrayGetEl Stray, isepA, isepB xin isep1 = (isepA == -1 ? 32 : isepA) isep2 = (isepA == -1 && isepB == -1 ? 9 : (isepB == -1 ? isep1 : isepB)) Sep1 sprintf "%c", isep1 Sep2 sprintf "%c", isep2 ilen1 StrayLen Stray, isep1, isep2 Sres = "" if ilen1 == 0 igoto end1 indx1 = 0 loop1: Sel StrayGetEl Stray, indx1, isep1, isep2; get element ires = 0 ilen StrayLen Sres, isep1, isep2; length of Sres if ilen == 0 igoto end indx = 0 loop: ;iterate over length of Sres Snext StrayGetEl Sres, indx, isep1, isep2 icomp strcmp Snext, Sel if icomp == 0 then ires = 1 igoto end endif loop_lt indx, 1, ilen, loop end: if ires == 0 then ;if element is not already in Sres, append Sdran sprintf "%s%s", Sep1, Sel Sres strcat Sres, Sdran endif loop_lt indx1, 1, ilen1, loop1 end1: Sout strsub Sres, 1; remove starting sep1 xout Sout endop