Piotr, 1. I think you will need to use ST GET PLAIN TEXT to get all the text after the specified range and then look for the first return character in that selection. I believe this is the only way to get an accurate position with styled text.
2. Again, use ST GET PLAIN TEXT to get a range of text from the cursor position back n characters or to the beginning of the text. HTH Pat On Tue, 12 Jun 2018 at 10:02, Piotr Chabot Stadhouders via 4D_Tech < 4d_tech@lists.4d.com> wrote: > Hi all, > > We are in the progress of migrating from 4D Write to Write Pro > A lot of things are going fine, but there is one area that seems easy but > I am having difficulties with it and that is programmatically manipulating > text > > I give 2 examples that maybe seem obvious to others but are not for me: > > 1. I am in a procedure where I have an Write Pro object (not perce an > area on screen, could be a range) and an expression has been selected via > $type:=ST Get content type($wp_obj;$start;$end;$startBlock;$endBlock). I > call the command ST SET TEXT($wp_obj;$text;$startBlock;$endBlock) to > replace the selected expression. So far no problems, but here it comes... > Now I want to find the first occurrence of a carriage return in the text > that comes after the replaced text (end inserted text - end whole text). > What is the best / easiest way to do this? Remember, this text can contain > styled text and/or expressions and/or pictures > 2. Example 2 is like example 1 but now with an actual visual area. The > user types a couple of characters. At a certain point after typing I want > to procedurally replace the typed text from the cursor back until the first > space and replace it with another text. Maybe somebody knows "Type it for > me", this is what I am talking about. So, what is the best way to find the > first occurrence of a space from the cursor back and replace this text with > another text? > > Thanks in advance, > > Piotr > > ********************************************************************** > 4D Internet Users Group (4D iNUG) > FAQ: http://lists.4d.com/faqnug.html > Archive: http://lists.4d.com/archives.html > Options: https://lists.4d.com/mailman/options/4d_tech > Unsub: mailto:4d_tech-unsubscr...@lists.4d.com > ********************************************************************** -- ************************************************* CatBase - Top Dog in Data Publishing tel: +44 (0) 207 118 7889 w: http://www.catbase.com skype: pat.bensky ************************************************* ********************************************************************** 4D Internet Users Group (4D iNUG) FAQ: http://lists.4d.com/faqnug.html Archive: http://lists.4d.com/archives.html Options: https://lists.4d.com/mailman/options/4d_tech Unsub: mailto:4d_tech-unsubscr...@lists.4d.com **********************************************************************