how to set the textStyle of word 1 of the selection?
Andre.Bisseret
Andre.Bisseret at inria.fr
Tue Mar 16 13:01:23 EDT 2010
Peter,
Thank you a lot for your attention to my problem. I am impressed by
the way you think about a problem.
Very nice solutions really; works well :-))
Meanwhile, I am trying to edit the selection made by the user, using a
repeat loop to delete the possible spaces (and/or tab) before the
selection, for several spaces might be selected before a word.
In fact, my field does not include text. It is populated by the day
numbers of the twelve months (one line for each month). Generally two
numbers are separated by one space (weeks are separated by tab).
But before the first of a month there can be several spaces (when the
month don't begin on the first day of a week.). Not likely the user'
selection would included much spaces, but 2 or 3 could be possible!
Thank you again Peter
Best regards
André
Le 16 mars 10 à 15:59, Peter Brigham MD a écrit :
> On Mar 16, 2010, at 6:40 AM, BNig wrote:
>
>> André,
>> I would test Peters solution a little more. If you start your
>> selection with
>> a space the word before the space will be the one that is targeted
>> for your
>> textstyle. The same with return and tab.
>> regards
>> Bernd
>
>
> True. I was assuming that the beginning of the selection would be a
> character and not white space. Here's a function that tells you if
> the character in a field is white space or not:
>
> function isWhiteSpace charNbr,fldRef
> put value(fldRef) into fldText
> put the number of words of char 1 to charNbr of fldText \
> into firstPartCount
> put the number of words of char charNbr to -1 of fldText \
> into secondPartCount
> return firstPartCount + secondPartCount = \
> the number of words of fldText
> end isWhiteSpace
>
> So incorporating that into the handler would give:
>
> on mouseup
> put the selectedchunk into selCh
> if the selectedtext = empty then exit mouseup
> put the long id of the selectedfield into fldRef
> put value(fldRef) into fldText
> put word 2 of selCh into startChar
> put the number of words of char 1 to startChar \
> of fldText into wordNbr
> if isWhiteSpace(startChar,fldRef) then add 1 to wordNbr
> set the textstyle of word wordNbr of \
> fldRef to "link"
> end mouseup
>
> On a different note, I'm confused about the behavior of full control
> references, eg, fldRef in the above example, which contains a long
> id of a field. The last line of the mouseup handler works, because
> the engine evaluates the variable fldRef before executing the
> command, but if instead of "set the textstyle of word wordNbr of
> fldRef" you do this:
> put word wordNbr of fldRef
> you get the corresponding word of "field id 3521 of card id 1009 of
> stack..." -- ie, the unevaluated string contained in the variable
> fldRef.
>
> So under what circumstances does Rev evaluate a full control
> reference? It's clearly not in all contexts.
>
>
> -- Peter
>
> Peter M. Brigham
> pmbrig at gmail.com
> http://home.comcast.net/~pmbrig
>
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-revolution
More information about the use-livecode
mailing list