Addition to circular buffer macro: search and return

Moderator: Benj

Post Reply
MJU
Posts: 502
Joined: Wed Nov 07, 2007 6:51 pm
Location: Antwerp Belgium
Has thanked: 121 times
Been thanked: 108 times
Contact:

Addition to circular buffer macro: search and return

Post 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.

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: Addition to circular buffer macro: search and return

Post 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 3258 times

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

Otherwise what your suggesting sounds possible.

MJU
Posts: 502
Joined: Wed Nov 07, 2007 6:51 pm
Location: Antwerp Belgium
Has thanked: 121 times
Been thanked: 108 times
Contact:

Re: Addition to circular buffer macro: search and return

Post 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

Post Reply