string compare

227 views
Skip to first unread message

acm...@columbia.edu

unread,
Feb 19, 2018, 7:15:02 PM2/19/18
to Bonsai Users
Hi Bonsai community,
I'm having some trouble finding a node that performs a 'string compare' logic. I have a list of different strings coming in through SerialStringRead and would like to catch a certain string and save the time stamp of its occurrence. I am sure there is a function for this already, but my searches so far were unsuccessful.

Thank you in advance for your help!

-Alice

Gonçalo Lopes

unread,
Feb 19, 2018, 7:23:43 PM2/19/18
to acm...@columbia.edu, Bonsai Users
Hi Alice,

What do you mean by "string compare"? From your description, it seems like you want to parse the string. If that's the case, you can use the Parse operator for that. You can match a string against a fixed template and extract basic data types.

For example, the following pattern: %i-%i will parse two integer numbers separated by a hyphen.

Hope this helps.

--
You received this message because you are subscribed to the Google Groups "Bonsai Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bonsai-users+unsubscribe@googlegroups.com.
Visit this group at https://groups.google.com/group/bonsai-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/bonsai-users/5bcdedb2-0078-4d96-bbae-b65ac2c1284f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Alice C Mosberger

unread,
Feb 19, 2018, 7:41:02 PM2/19/18
to Gonçalo Lopes, Bonsai Users
I'm not sure that does what I want. Sorry for not explaining it better.
What I would like is that for example, whenever the string "lick" comes in through the serial, I want to detect it and safe a timestamp of the event.
Thank you for your fast help, as ever.

goncal...@gmail.com

unread,
Feb 19, 2018, 8:15:05 PM2/19/18
to Alice C Mosberger, Bonsai Users

Ah, thanks for clarifying. In that case, it might be enough to just use the Equal operator to test whether the input string matches some fixed value.

 

After that you can use Condition, followed by Timestamp, to generate the output you want. You can use this pattern in multiple parallel branches.

 

Hope this helps.

 

From: Alice C Mosberger
Sent: 20 February 2018 00:41
To: Gonçalo Lopes
Cc: Bonsai Users
Subject: Re: [bonsai-users] string compare

 

I'm not sure that does what I want. Sorry for not explaining it better.

What I would like is that for example, whenever the string "lick" comes in through the serial, I want to detect it and safe a timestamp of the event.

Thank you for your fast help, as ever.

 

On Feb 19, 2018 7:23 PM, "Gonçalo Lopes" <goncal...@gmail.com> wrote:

Hi Alice,

 

What do you mean by "string compare"? From your description, it seems like you want to parse the string. If that's the case, you can use the Parse operator for that. You can match a string against a fixed template and extract basic data types.

 

For example, the following pattern: %i-%i will parse two integer numbers separated by a hyphen.

 

Hope this helps.

On 20 February 2018 at 00:15, <acm...@columbia.edu> wrote:

Hi Bonsai community,

I'm having some trouble finding a node that performs a 'string compare' logic. I have a list of different strings coming in through SerialStringRead and would like to catch a certain string and save the time stamp of its occurrence. I am sure there is a function for this already, but my searches so far were unsuccessful.

 

Thank you in advance for your help!

 

-Alice

--

You received this message because you are subscribed to the Google Groups "Bonsai Users" group.

To unsubscribe from this group and stop receiving emails from it, send an email to bonsai-users...@googlegroups.com.

Reply all
Reply to author
Forward
0 new messages