function to calculate string length...

Chipp Walters chipp at chipp.com
Tue Dec 28 20:08:02 EST 2004


Thanks for this, would you mind explaining what it does?

Thanks again
Chipp

Wouter wrote:
>> Re: function to calculate string length...
>>
>> Chipp Walters
>> Sun, 26 Dec 2004 04:21:44 -0800
>> Well, I cobbled this together from some of the archives...
>> Anyone see an obvious place to optimize?
>>
>>
>> on formatFld pFldName, pTxt
>>   lock screen
>>   put the width of fld pFldName into tW
>>   set the width of fld "formatCheck" to tW
>>   repeat for each line L in pTxt
>>     put L into fld "formatCheck"
>>     put false into tIsTooLong
>>     repeat while the formattedwidth of fld "formatCheck" > tW
>>       delete last char of fld "formatCheck"
>>       put true into tIsTooLong
>>     end repeat
>>     if tIsTooLong is true then
>>       put fld "formatCheck" after tList
>>       delete char -5 to -1 of tList
>>       put "..." & cr after tList
>>     else
>>       put L & cr after tList
>>     end if
>>   end repeat
>>   delete last char of tList
>>   put tList into fld pFldName
>>   unlock screen
>> end formatFld
>>
>>
>> Chipp Walters wrote:
>> Looking for some help.
>>
>>  I have a list field and want to add an elipsis (...) at the end of 
>> lines which are truncated and won't fit in the field. I was wondering 
>> if anyone out there may have a function to do this quickly?
> 
> 
> Sorry for posting this on the metacard list, because for the moment I 
> cannot post to the use-rev list.
> But as this can be used in both IDE, I hope you don't mind.
> Here is a different approach to the problem (further adaptation may be 
> needed).
> 
> Use a temporary field with the same props as the listfield except for 
> the dontwrap property (which should be false).
> Instead of the name of the field use the short id of the field to call 
> this handler.
> 
> on formatFld pFldID
>   put fld id pFldID into y
>   put y into fld "temp"
>   put the formattedtext of fld "temp" into x
>   put "" into fld "temp"
>   repeat for each line i in y
>     put 1 into tC
>     repeat for each line h in x
>       if tC = 1 then
>         put h into tTemp
>         put h into tRetain
>       else put space & h after tTemp
>       if tTemp = i then
>         if tC = 1 then put i & cr after tList
>         else put tRetain & numtoChar(201)  & cr after tList
>         delete line 1 to tC of x
>         exit repeat
>       else add 1 to tC
>     end repeat
>   end repeat
>   put word 1 to -1 of tList into fld id pFldID
> end formatFld
> 
> Greetings and best wishes to everybody,
> WA
> 
> _______________________________________________
> metacard mailing list
> metacard at lists.runrev.com
> http://lists.runrev.com/mailman/listinfo/metacard
> 
> 


More information about the metacard mailing list