Page 1 of 1

Addition to circular buffer macro: search and return

Posted: Sun Sep 06, 2020 11:35 pm
by MJU
Me and the circular buffer will never be a good match. I don't know why but this never seem to work when I try things with it.

A great addition for me would be a "find and return" action that can be used in this macro.
This would search in the buffer for a certain string, and return the X'th value behind that search string.

If the buffer would contain:
%%%%%%%ABC9876543210%%%%%%... and so on.
and the search string would be "ABC" and the return value would be 4, this would in this buffer return "6".
So the 4th byte after the last part of the search string should be returned.

If there would be an option of keep the content of the buffer or erase it, this would be great to find response from devices and use them in a chart.
In a project I'm working on I could search for a certain pattern and return data that are always in a certain place after a certain string in a bunch of data.

Re: Addition to circular buffer macro: search and return

Posted: Tue Sep 08, 2020 11:52 am
by Benj
Hello,

Would this do a similar thing for you.

The first icon removes content from the buffer until it finds the text "ABC"

Then we skip over the bytes were not interested in "987" and return the byte we want.

CB_Demo.jpg
CB_Demo.jpg (25.73 KiB) Viewed 3927 times

Then this would be left in the buffer "543210%%%%%%"

Otherwise what your suggesting sounds possible.

Re: Addition to circular buffer macro: search and return

Posted: Tue Sep 08, 2020 11:43 pm
by MJU
Benj wrote:
Tue Sep 08, 2020 11:52 am
Hello,

Would this do a similar thing for you.

The first icon removes content from the buffer until it finds the text "ABC"

Then we skip over the bytes were not interested in "987" and return the byte we want.


CB_Demo.jpg


Then this would be left in the buffer "543210%%%%%%"

Otherwise what your suggesting sounds possible.
I saw this example already and I used it for another project, but thanks again!!
Appreciate it (like always)!

But can I conclude that after the search has a positive result, the "pointer" of the CB is right after the last byte of the search result?
Maybe this info can be put in the Wiki for this component?

This is something I wasn't sure of.

An addition for this component would be great in the future.
Thanks