Glad you got it working. Just a nitpick but you want to consider using numToChar(133) instead of "...".so you only take up 1 char instead of 3. Of course nothing's ever that simple 'cause then you'd have to use ISOToMac as well when on a Mac..
Pete lcSQL Software <http://www.lcsql.com> On Wed, Aug 28, 2013 at 9:40 AM, Peter M. Brigham <pmb...@gmail.com> wrote: > Inventive approaches, thank you. I continued to have trouble with using > any function at all to trim the lines in a Windows standalone though > everything I tried worked in the Mac IDE. It started working fine in the > standalone when I put the identical code into the calling handlers. I still > don't understand this, but I've got it working now. > > Re scalability, it's just for a short list of text snippets for a popup > button, max length <= 20 or so. > > -- Peter > > Peter M. Brigham > pmb...@gmail.com > http://home.comcast.net/~pmbrig > > On Aug 28, 2013, at 3:54 AM, Geoff Canyon wrote: > > > On Mon, Aug 19, 2013 at 9:43 PM, Peter M. Brigham <pmb...@gmail.com> > wrote: > > > >> function shorten tList > >> repeat with n = 1 to the number of lines of tList > >> put line n of tList into lineText > >> if length(lineText) < 75 then next repeat > >> put empty into tBefore > >> put empty into tAfter > >> if char 43 of line n of tList = space then > >> put space into tBefore > >> end if > >> if char -25 of line n of tList = space then > >> put space into tAfter > >> end if > >> put tBefore & "..." & tAfter into char 43 to -25 of of line n of > >> tList > >> -- 3 periods, not a numtochar(201) > >> end repeat > >> return tList > >> end shorten > >> > > > > > > Just saw this because of wonky spam filters. You can get identical > results > > to the above (without the errors) with: > > > > function shorten2 tList > > repeat for each line L in tList > > if length(L) < 75 then > > put L & cr after R > > else > > put (char 1 to 42 of L) & char (2 - offset(" ",char 43 of L)) to > > (-2 + offset(" ",char -25 of L)) of " ... " & (char -24 to -1 of L) & cr > > after R > > end if > > end repeat > > return R > > end shorten2 > > > > That returns variable-length shortened lines, as does the original. If > > there isn't a special reason for that, then this is even simpler, and has > > the shortening parameters as variables. Just call it with 75 and 43 to > get > > similar to the original. > > > > function trimLines tList, trimTo, elipseAfter > > repeat for each line L in tList > > if length(L) <= trimTo then put L & cr after R else put (char 1 to > > elipseAfter of L) & "..." & (char (elipseAfter - trimTo + 3) to -1 of L) > & > > cr after R > > end repeat > > return R > > end trimLines > > > > Both of these scale roughly linearly. For menus it's not likely to be a > > factor, but on 3500 lines the original takes about a second on my > machine, > > and each of these take about a hundredth of a second. > > > > gc > > _______________________________________________ > > 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 > > > _______________________________________________ > 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 > _______________________________________________ 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