Windows standalone puzzle
Peter M. Brigham
pmbrig at gmail.com
Wed Aug 28 12:40:25 EDT 2013
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
pmbrig at 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 <pmbrig at 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 at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
More information about the use-livecode
mailing list