Set insertion point for text field at end

I have a text field with some text inside. The insertion point is at the beginning. I would like to set the insertion point at the end of the text.

I have tried that without success,

set textcount to count of memValue
call method "setSelectedRange:" of (call method "currentEditor" of text field "screenview") with
parameter textcount



as far as I know it’s not possible to call the inherited method currentEditor of NSTextField in an AppleScript Studio environment.
Try this, please check the proper reference to the text field and the main window

set textField to a reference to text field "screenview" of window "main"
call method "makeFirstResponder:" of window "main" with parameters {textField}
set fieldEditor to call method "fieldEditor:forObject:" of window "main" with parameters {true, textField}
set textRange to {length of (get string value of textField), 0}
call method "setSelectedRange:" of fieldEditor with parameters {textRange}


Perfect! It works fine.

Thanks again,