Jacqueline,
I'm trying to start at a very basic level - first of all to understand
how to apply the 'selectedChunk' which seems crucial to my whole problem.
My script looks right to me but throws up an error -surprise, surprise.

I understand the principle of what selectedChunk achieves, but how to test
for that is not immediately apparent to me. Although the 'Documentation'
references describe the various functions, I find them not descriptive enough.
They each really need a complete example so that the snippet can be seen
in some kind of context. This is not adequate for me, as it does not show
how to retrieve and startChar or endChar values...

the selectedChunk
put the selectedChunk into storedChunk

 I'm afraid even this basic stuff stumps me at the moment.

on keyDown theKey
if the selectedChunk (theKey, field "insertionField") is -1 then
  answer "endChar is -1"
else
if the selectedChunk (theKey, field "insertionField") is +1 then
    answer "endChar is +1"
  else
if the selectedChunk (theKey, field "insertionField") is 0 then
      beep
      end if
  end if
  end if
end keyDown

What am I missing?
Many thanks,
Adrian
______________________
Club Type
http://www.clubtype.co.uk
[EMAIL PROTECTED]

On 1 Oct 2006, at 19:22, J. Landman Gay wrote:

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
_______________________________________________
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