Adrian Williams wrote:
Martin,
Thanks for your suggestion. It did not work for me - reporting:

Type    Function: error in function handler
Object    edtText
Line    put Lookupchar(char beforecharpos of me) into newbeforechar
Hint    Lookupchar

Martin was assuming you would write your own function "lookupchar" to do the actual work, but since you are new at this, the function is actually exactly what you are asking about.


The object field is "edtText" but if I change me to edtText
that throws up an error too.

To reference a field, you'd need to add the object descriptor. That is, change "me" to "field 'edtText'". But "me" is okay, leave it that way as long as the script is in the field itself.

To explain a little more why the cursor position is important...
User entering text can be dealt with as keyDown.
But if User goes back and inserts cursor in an existing word,
I need to know what is either side so that those characters can
be matched against a list and replaced if necessary.

Look up the "selectedChunk" term in the dictionary. This gives you the position of the insertion point, or the position of any selected text, in the format:

  char x to y of field "whatever"

If x is smaller than y, a range of characters is selected. If x is larger than y, the insertion point is blinking between two characters. Your script should check to see whether x is smaller than y. If so, you've got a selection that spans characters, and x-1 would be the previous character, and y+1 would be the next one. If x is larger than y, the insertion point is between characters and x+1 would be the next character and y-1 would be the previous one.

Once you have determined whether you have a range of text or not, you can put extra text either in front of or after the selected chunk:

  put "abc" before char x of field "whatever" -- works for a range
  put "abc" after char y of field "whatever" -- works for a range

  put "abc" before char y of field "whatever" -- for non-range
  put "abc" after char x of field "whatever" -- for non-range


--
Jacqueline Landman Gay         |     [EMAIL PROTECTED]
HyperActive Software           |     http://www.hyperactivesw.com
_______________________________________________
use-revolution mailing list
[email protected]
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution

Reply via email to