How to select a certain part of a text node?

[[Category:Code] Answered by: Brent Hartwig Last Updated: 2006-09-22 =Question by N.N.=

I'm trying to programmatically select a certain part of a text node. For instance, if the text node says: "this is some text" is there any way I can select just "some" ?

I know I can do: goto_oid and oid_select, but that will select the entire "this is some text" string.

=Brent Hartwig answers=

Once you programmatically determine where to start the selection and where it must end, you can use the "mark" command to create the selection. You must move the caret for this to work. Help 9019.

goto_oid( yourOid ); forward_char( 3 ); # however you figure out where to start clear_mark all; # clear any existing selection mark -selection -invert begin; forward_char( length( yourGlossaryWord ) ); mark end; # selection now created