Colin Holgate <[EMAIL PROTECTED]> wrote:
> there are difficulties, as you'll discover if you select a
> range of characters. That can be taken care of as well...
Hi Michael, Kurt and Colin,
Here's a handler to take care of this.
Cheers,
James
PS: the Filter Input Characters behavior is supposed to do everything that
Michael is looking for. Unfortunately the D8+ version is buggy. If anyone
wants a revised version, please let me know.
----------------------------------------------------------------------
on mInsert(aMember, aString, aSelection) -----------------------------
-- INPUT: <aMember> is a text or field member
-- <aString> is a character string
-- <aSelection> may be a two item list indicating the
-- start and end points for inserting <aString>
-- ACTION: Places <aString> at the appropriate place in the member
-- Places the insertion point immediately after the added
-- string
--------------------------------------------------------------------
isField = (aMember.type = #field)
tLength = aString.char.count
-- Determine whether to insert or replace
if listP(aSelection) then
tStartChar = aSelection[1]
tEndChar = aSelection[2]
else if isField then
tStartChar = the selStart
tEndChar = the selEnd
else
tStartChar = aMember.selection[1]
tEndChar = aMember.selection[2]
end if
-- Add the string to the member
tText = aMember.text
if tStartChar = tEndChar then
put aString after char tStartChar of tText
else
put aString into char tStartChar + 1 to tEndChar of tText
end if
aMember.text = tText
-- Update insertion point
if isField then
the selEnd = tStartChar + tLength
the selStart = tStartChar + tLength
else
aMember.selection = [tStartChar + tLength, tStartChar + tLength]
end if
end mInsert
[To remove yourself from this list, or to change to digest mode, go to
http://www.penworks.com/lingo-l.cgi To post messages to the list, email
[EMAIL PROTECTED] (Problems, email [EMAIL PROTECTED]). Lingo-L is for
learning and helping with programming Lingo. Thanks!]