Hi, Larry.
Here's a technique that may be faster, especially for longer lists, because it does not seek line n of each list for each and every n.
Code: Select all
function joinLines pList1, tList2, pLineDelimiter, pItemDelimiter -- join lines on line number
   local tLineNumber, tJoin
   split tList2 by pLineDelimiter
   set the lineDelimiter to pLineDelimiter
   repeat for each line tLine in pList1
      add 1 to tLineNumber
      put tLine & pItemDelimiter & tList2[ tLineNumber ] & pLineDelimiter after tJoin
   end repeat
   return tJoin
end joinLines
Here's a test the above function passes:
Code: Select all
on testJoinLines
   local t1 = "1,2,3", t2 = "a,b,c"
   replace comma with cr in t1
   replace comma with cr in t2
   
   get joinLines( t1, t2, cr, comma )
   breakpoint
end testJoinLines
By the way, if you're having trouble reading sample code in emails from the forum, you'll find it much easier to read in the forum.
-- Dick