Support

If you have a problem or need to report a bug please email : support@dsprobotics.com

There are 3 sections to this support area:

DOWNLOADS: access to product manuals, support files and drivers

HELP & INFORMATION: tutorials and example files for learning or finding pre-made modules for your projects

USER FORUMS: meet with other users and exchange ideas, you can also get help and assistance here

NEW REGISTRATIONS - please contact us if you wish to register on the forum

Users are reminded of the forum rules they sign up to which prohibits any activity that violates any laws including posting material covered by copyright

stock substring find inconsistency

For general discussion related FlowStone

stock substring find inconsistency

Postby tester » Wed Nov 06, 2013 11:46 pm

I just found an inconsistency in stock "string array find" primitive.
It looks that it finds only first matching "rows" not "substrings" (associated with indexed rows).
Another primitive to upgrade or replace with ruby. :o
Generally it is enough if it finds first match, and points in which line is it (index)...
...but for geeks it could generate a list of all indexes (not needed here).

Was this topic earlier touched, or I'm starting to have deja vu? :)

//edit: silly me; I have can get that index directly. from other place.
Attachments
substring-search-issue.fsm
(299 Bytes) Downloaded 854 times
Need to take a break? I have something right for you.
Feel free to donate. Thank you for your contribution.
tester
 
Posts: 1786
Joined: Wed Jan 18, 2012 10:52 pm
Location: Poland, internet

Re: stock substring find inconsistency

Postby billv » Thu Nov 07, 2013 12:12 am

That's how it should work isn't tester..?
In the second example it dosn't find the string cause the string don't exist...
Its searching array for index of sub-string, not searching each string for your string.
billv
 
Posts: 1157
Joined: Tue Aug 31, 2010 3:34 pm
Location: Australia

Re: stock substring find inconsistency

Postby tester » Thu Nov 07, 2013 12:23 am

by "substring" ("substring to find") I understand a fraction of a longer string (string array is also a string, just with line separators witnin it, isn't it?). I would expect that it finds first match (even if it's a single letter) and points index of a line. It's confusing and not obvious.
Need to take a break? I have something right for you.
Feel free to donate. Thank you for your contribution.
tester
 
Posts: 1786
Joined: Wed Jan 18, 2012 10:52 pm
Location: Poland, internet

Re: stock substring find inconsistency

Postby billv » Thu Nov 07, 2013 2:31 am

tester wrote:by "substring" ("substring to find") I understand a fraction of a longer string (string array is also a string, just with line separators witnin it, isn't it?

Yes is also a string, but the "string array find" don't care, cause it's looking
in every array slot for an exact match.
if you try the 'string find' instead of"string array find", it does pick up the index,
note that gives the index where the sub-string ends...not where it
starts....... not sure why its the preferred behavior...
.
billv
 
Posts: 1157
Joined: Tue Aug 31, 2010 3:34 pm
Location: Australia

Re: stock substring find inconsistency

Postby tester » Thu Nov 07, 2013 2:00 pm

Typical non-programmer (who uses excel/word from time to time) "natural expectation". ;-)
Need to take a break? I have something right for you.
Feel free to donate. Thank you for your contribution.
tester
 
Posts: 1786
Joined: Wed Jan 18, 2012 10:52 pm
Location: Poland, internet

Re: stock substring find inconsistency

Postby trogluddite » Thu Nov 07, 2013 9:23 pm

Here's a module that does a much more versatile form of string array searching - I made it for scanning the patch names listed by one of my MIDI FX...
String Finder.fsm
(2.54 KiB) Downloaded 911 times

...might be a cool thing to add to the preset manager one day...

INPUTS...
- Items: An array of strings that you want to search
- Find: The string that you're looking for.
- Position: An integer index representing the place in the string that you want to find the search term...
...0 -> Find the search term anywhere in the string.
...1 -> Only if the search term is at the start of the string.
...2 -> Only if the search term is at the end of the string.
...3 -> Must match the whole string from beginning to end.
...4 -> Find only the whole word (i.e. separated from other words with whitespace)
- Match case: Set true for case sensitive matches, otherwise case is ignored.
- Do it: Trigger to begin the search.

OUTPUTS...
- Indexes: An integer array of the indexes where a match was found.
- Matches: A string array of the found items.
All schematics/modules I post are free for all to use - but a credit is always polite!
Don't stagnate, mutate to create!
User avatar
trogluddite
 
Posts: 1730
Joined: Fri Oct 22, 2010 12:46 am
Location: Yorkshire, UK

Re: stock substring find inconsistency

Postby tester » Thu Nov 07, 2013 9:43 pm

Thanks!

Because these "little useful things" can be explored with ruby - I'm afraid nothing will change for most original green prims. It's a paradox somewhat. On one hand - a lot of thigs can be done in ruby, but on the other - only a few people (i.e. small percentage) know (or will know) how to implement it correctly, completely and performance efficiently. So I guess - the focus on new prims, will be only on these, that perform certain tasks faster in regards to other solutions in general FS.

I wonder what new will bring the incoming update (besides this CPU related fix). Should be posted within few days as far I remember.
Need to take a break? I have something right for you.
Feel free to donate. Thank you for your contribution.
tester
 
Posts: 1786
Joined: Wed Jan 18, 2012 10:52 pm
Location: Poland, internet

Re: stock substring find inconsistency

Postby RJHollins » Thu Nov 07, 2013 10:08 pm

Really nice TROG !!!

This might be able using PRIMS ... but given all the search options available to this RUBY module ... it could get complex wiring up PRIMS to do the equivalent ... I don't know.

This Ruby version goes in the ToolBox !

Thanks TROG !
:D
RJHollins
 
Posts: 1571
Joined: Thu Mar 08, 2012 7:58 pm

Re: stock substring find inconsistency

Postby trogluddite » Thu Nov 07, 2013 11:37 pm

You're welcome, folks! :D

I've kind of always seen Ruby as the "green" equivalent of the "stream" assembly primitive...
DSPr is basically one programmer, Malc, and he is the only guy that can make primitives - but he also must do all of the bug fixing and 'core' upgrades. So I treat Ruby/ASM as something like an API - a way for at least some of us to extend the set of "tools" for everybody.
Bear in mind that most competing products - e.g. SynthEdit, only offer these kind of 'user upgrades' using an extremely complex C++ API - you need a ton of extra software, have to learn an extremely ugly programming language, fight with compositors and compilers, and have to wait ages to see the result of the simplest program edits. (seriously, if you ever tried C++, you would know why I think of Ruby as 'elegant'!)

I agree with tester about the 'paradox', though. The big advantage of FS is that the visual linking style is a very simple and quick way to program, for beginners and experienced programmers alike - but that requires the supply of intuitive primitives/modules to make it work - which, in turn, needs some people, either here or at DSPr, to keep on building them. Trouble is, the module makers are mostly keen "hobbyists", with their own projects on the go, and their own personal tastes for what they make and how they should work - considering that, the quantity and quality of stuff that gets posted is really quite amazing, but there's just too few of us (yet?!?).
All schematics/modules I post are free for all to use - but a credit is always polite!
Don't stagnate, mutate to create!
User avatar
trogluddite
 
Posts: 1730
Joined: Fri Oct 22, 2010 12:46 am
Location: Yorkshire, UK

Re: stock substring find inconsistency

Postby RJHollins » Sat Nov 16, 2013 10:06 am

I'm working on a slight brain tweezer here for part of a project idea.

This 'String Finder' routine is very nice, and I'm trying to figure out how it could help solve for a result I need.

From the String Finder example, searching for 'cats' ... we can get several different find results along with an index.

Here is what I need to add ...

I have 2 lists of arrays. The 1st is like the example list: Names. But I have a 2nd list with a corresponding number.
[this 'number' is NOT an Index, but it is directly related to the Name.

When a search is done on the NAME list, I need the corresponding 'number' from the 2nd list so that both list stay in separate arrays.

As I read more about RUBY arrays, I realize there are so many ways to do this ... I seem to be getting confused early in the process :roll: I looked at combining the 2 arrays into a 2-dimensional array and then figure out how to search just the Name portion. It didn't go well. Plus, the OUTPUT was in a format that I could not change ... I need plain Text and numeric output to be used for display and as MIDI data.

Personally, I could also use 'Da Id-gits Guide to Ruby Arrays' ... anyone know where a copy can be found :lol:
RJHollins
 
Posts: 1571
Joined: Thu Mar 08, 2012 7:58 pm

Next

Return to General

Who is online

Users browsing this forum: Google [Bot] and 72 guests