Re: Is it possible to use a reverse direction for offset

2023-03-23 Thread Alex Tweedly via use-livecode
Oh dear - replying to myself again :-) The 'itemDel' method still does the long search through the text - even though it does it at engine speed, and in neat tidy looking script. But, re-reading your earlier description, it occurred to me that (maybe) you are doing lots of different

Re: Is it possible to use a reverse direction for offset

2023-03-23 Thread Alex Tweedly via use-livecode
OK, I may be going in the wrong direction here, but put (the opening string) into temp set the itemDelimeter to temp put the number of chars in item 1 to -2 of theWholeText into theAnswer ?? Alex. On 23/03/2023 17:24, François via use-livecode wrote: Yes, this is the big picture. Plus,

Re: Is it possible to use a reverse direction for offset

2023-03-23 Thread François via use-livecode
Yes, this is the big picture. Plus, some environments may live within other environments. And yes, one of the things the app does all the time is finding matched opening strings and closing strings, like finding matched parentheses in a programming language. Fun, as you said! François > Le

Re: Is it possible to use a reverse direction for offset

2023-03-23 Thread Craig Newman via use-livecode
Fun, fun… So if you collect ALL the opening and closing strings, and hopefully these never overlap, then each pair can be “ordered”. Now identifying each is just a matter of thinking in terms of “pairs” of offsets. You can then identify each by their “paired” position in the forward direction.

Re: Is it possible to use a reverse direction for offset

2023-03-23 Thread François via use-livecode
An example of when a backwards search would be useful is the following: In the app, you have to find command environments. Environments are delimited by an opening string and a closing string. Usually, I search forward for the opening string, then search for the closing string afterwards. Once

Re: Is it possible to use a reverse direction for offset

2023-03-23 Thread Craig Newman via use-livecode
Francois. I am sure you know what you have and what you need. But just for my curiosity, if I had to do what you want, I would have used the “offset” function and its “charsToSkip” parameter to find all instances of the text to find, and then use those values in sequence to work backwards. But

Re: Is it possible to use a reverse direction for offset

2023-03-23 Thread François via use-livecode
The text source is not very big. However I implement transcoding from one language to another and I do an VERY large amount of search and replace. I think I have quite optimized my LC code but transcoding can take 5 minutes to do, and I need the whole process to chase unexpected bugs. This is

Re: Is it possible to use a reverse direction for offset

2023-03-23 Thread Craig Newman via use-livecode
Francois. Who wouldn’t? But unless you are working with VERY large datasets, I bet a handler would process quickly. Craig > On Mar 23, 2023, at 10:58 AM, François via use-livecode > wrote: > > @Ben > > Too bad… > > @ Craig > > I would rather have an optimized version, I do a lot of text

Re: Is it possible to use a reverse direction for offset

2023-03-23 Thread François via use-livecode
@Ben Too bad… @ Craig I would rather have an optimized version, I do a lot of text processing in my app. Thanks to both of you! François > Le 23 mars 2023 à 14:43, Craig Newman via use-livecode > a écrit : > > @Ben. > > 20 years! Congratulations!. > > @Francois > > This can be scripted

Re: Is it possible to use a reverse direction for offset

2023-03-23 Thread Craig Newman via use-livecode
@Ben. 20 years! Congratulations!. @Francois This can be scripted easily. Do you need help with that? Craig > On Mar 23, 2023, at 8:21 AM, Ben Rubinstein via use-livecode > wrote: > > https://quality.livecode.com/show_bug.cgi?id=584 (20th anniversary this > September!) > > Also >

Re: Is it possible to use a reverse direction for offset

2023-03-23 Thread Ben Rubinstein via use-livecode
https://quality.livecode.com/show_bug.cgi?id=584 (20th anniversary this September!) Also https://quality.livecode.com/show_bug.cgi?id=8353 On 23/03/2023 11:35, François via use-livecode wrote: I would like to search for a string within another string, starting at a given position, but

Is it possible to use a reverse direction for offset

2023-03-23 Thread François via use-livecode
I would like to search for a string within another string, starting at a given position, but backward. In some languages, you can achieve that by providing a negative number for the initial position of the search. Is this possible in LiveCode? TIA François