SynthMaker

*FIXED* Comma's in string arrays

Archive · 2010 35 old posts

From the original SynthMaker forum (2004–2014), with its members’ names and dates.

mwvdlee ·

I'm sure somebody thought this was a good idea, but seriously... WTF? Comma's are translated to new lines in string to string array conversion? How is that useful for anything other than CSV file parsing? Am I missing a hidden option to turn this off? Am I doing something really stupid? Can I have comma's in the strings of a string array in some other way?

*FIXED*: v2.0.3 upwards (actually earlier versions too, but they broke other functionality, so v2.0.3 is the first version on par with v1.7 that fixes this bug).

Tzarls ·

Funny, if you connect the string to text directly (bypassing the module) it works as it should, without the parsing thing. A bug maybe?

exonerate ·

I've had to get around this before.

There's a module in the dev toolkit called "char find and replace" I had to use that to replace all the commas with an underscore feed that to the string array and then when extracting from the array put them back.

I agree though there should be a way to turn this behaviour off. 🙂

Cheers 😉

Exo

mwvdlee ·

exonerate wrote: There's a module in the dev toolkit called "char find and replace" I had to use that to replace all the commas with an underscore feed that to the string array and then when extracting from the array put them back.

Actually I made my own char find & replace (which seems to be a little bit faster than the dev toolkit one). Trouble is that I'm working with an array that can easily be several hundred long lines and with either my own or the dev tookit's S&R, it takes way to long to be usable. In my particular case I might be able to do another workaround, but it's still a workaround for something that, IMHO, should not be happening.

infuzion ·

mwvdlee wrote: exonerate wrote: There's a module in the dev toolkit called "char find and replace" I had to use that to replace all the commas with an underscore feed that to the string array and then when extracting from the array put them back.

Actually I made my own char find & replace (which seems to be a little bit faster than the dev toolkit one).

I'd be interested in that. Here is what came to mind right away for a workaround:

mwvdlee ·

infuzion wrote: Here is what came to mind right away for a workaround:

Perhaps I should have sent a different example. Although your solution works fine for a single string, I was using a loaded file, moving that into a string array display (or whatever its called) to split into lines, then moving that to the string array where commas also seem to split lines.

exonerate ·

mwvdlee wrote: exonerate wrote: There's a module in the dev toolkit called "char find and replace" I had to use that to replace all the commas with an underscore feed that to the string array and then when extracting from the array put them back.

Actually I made my own char find & replace (which seems to be a little bit faster than the dev toolkit one). Trouble is that I'm working with an array that can easily be several hundred long lines and with either my own or the dev tookit's S&R, it takes way to long to be usable. In my particular case I might be able to do another workaround, but it's still a workaround for something that, IMHO, should not be happening.

Yes I agree this behaviour should be changed.

Tzarls ·

mwvdlee wrote: Although your solution works fine for a single string, I was using a loaded file, moving that into a string array display (or whatever its called) to split into lines, then moving that to the string array where commas also seem to split lines.

How about something like this as workaround?

infuzion ·

mwvdlee wrote: infuzion wrote: Here is what came to mind right away for a workaround:

Perhaps I should have sent a different example. Although your solution works fine for a single string, I was using a loaded file, moving that into a string array display (or whatever its called) to split into lines, then moving that to the string array where commas also seem to split lines.

Well, if you can use the String Array primitive for a single string, you can use it for multiple strings like Tzarls is saying. It is a pain to make sure you avoid the use of the Text or avoid using commas as a delimiter, but it can be done.

It is good to report "undocumented & confusing behaviors" in the bug forum, since at least a record of this needs to go somewhere. Would be better to be in the official docs, or at least the WiKi. Now after years of this behavior though, I'm not sure if it could be "fixed", since there may be other OSMs that need this.

I guess a module that will delimit text properly would help, & well as something to warn if there are commas present in a text. But I don't SM was ever created to be a word-processor program. 😉

mwvdlee ·

Tzarls wrote: How about something like this as workaround?

Nope:

You can't actually extract the lines from that array any more.

Attached is the schematic of that picture, which also includes an example of my character replacement:

Here's a possible solution, let's call it a "feature request to fix a bug": introduce a new primitive that would convert from String datatype to String Array datatype without converting commas to newlines. A primitive should be able to do it at as fast (or faster) than the current direct conversion method. That way old code remains working and we could actually work with normal text files as well. Alternatively perhaps extend that primitive module with an extra "delimited" input; feed it with NL to break lines at NL, feed it with "," to break lines at ",", feed it with nothing to not break lines as all. It's not as clean as having the basic datatype conversion be without side-effects, but atleast it wouldn't break code already written.

oddson ·

In terms of an efficient work-around; the Parser components are probably the best way to make a module that will extract lines into string array elements -- but I can't remember how it works as I don't use it enough.

I wrote a WIKI article on it but I'm a little rusty on the subject. [old link]

I agree a primitive that takes a string parameter for what delimiter to use in building the array would be nice... but maybe I'll try to build a Parser based module tomorrow to restore my skills.

mwvdlee ·

oddson wrote: In terms of an efficient work-around; the Parser components are probably the best way to make a module that will extract lines into string array elements -- but I can't remember how it works as I don't use it enough.

The parser is a lot faster, but the main problem here is that the parser doesn't support characters beyond 0x7F, eliminating áll öf thøsë fünñÿ çhåræçhtêrs. It also skips over whitespace characters, making it impossible to preserve linebreaks.

infuzion ·

[quote="oddson"I agree a primitive that takes a string parameter for what delimiter to use in building the array would be nice... but maybe I'll try to build a Parser based module tomorrow to restore my skills.[/quote]Why bother, you just have to hack the CSV to List parser:

infuzion ·

mwvdlee wrote: oddson wrote: In terms of an efficient work-around; the Parser components are probably the best way to make a module that will extract lines into string array elements -- but I can't remember how it works as I don't use it enough.

The parser is a lot faster, but the main problem here is that the parser doesn't support characters beyond 0x7F, eliminating áll öf thøsë fünñÿ çhåræçhtêrs. It also skips over whitespace characters, making it impossible to preserve linebreaks.

Oh, that is anther bug in itself IMHO; forcing whitespace atleast. related UTF: full Unicode unavailable [0.9.3w]

mwvdlee ·

infuzion wrote: Why bother, you just have to hack the CSV to List parser:

...which loses all the ümlaut characters and such. You can't have müsic without umlauts. :P Besides, it's still way too slow for really big files like big directory listings.

rl ·

Indeed. The parsers special threatment of whitespace is a problem here.

This example implements a parser. When using a pipe symbol '|' as a line delimiter, the parser works pretty well. But when replacing the '|' with a newline the parser breaks. My assumption is, the parser wasn't built for line by line parsing in the same manner as (for example) line breaks are not significant in most programming languages or XML syntax.

.. and yes, the parser does not support special chars beyond 127 ##@!X%#@&!! 🙁

mwvdlee ·

rl wrote: My assumption is, the parser wasn't built for line by line parsing in the same manner as (for example) line breaks are not significant in most programming languages or XML syntax

The parser, as it is, is (IMHO) of limited use. Line breaks are significant in many programming languages (i.e. C/C++/SM's Code and ASM modules; preprocessor statements and line comments) and XML (for certain types of content). It's great for parsing your own custom file formats designed to work around the parsers' limitations but not so much for existing, standard file formats. Anyway, my issues with the parser can fill an entire thread on it's own, so I won't go into it much deeper here 🙂

rl ·

right, file a feature request and I will vote for it!

infuzion ·

rl wrote: right, file a feature request and I will vote for it!

Or is it more of a bug, since Float Array & parsers (mis?)treat whitespaces differently from other characters?

mwvdlee ·

infuzion wrote: rl wrote: right, file a feature request and I will vote for it!

Or is it more of a bug, since Float Array & parsers (mis?)treat whitespaces differently from other characters?

Whether it's really a bug or not isn't relevant to the reality that it is highly unlikely this functionality will be changed due to possible backwards compatibility issues. A new primitive is the more likely solution, so I've filed a feature request here: String Array

Tried to be as precise as possible in describing the wanted behaviour. Please let me know if you guys disagree with the description.

Large ·

Regarding the subject of commas, can someone PLEASE post an OSM of a text file, full of values, being converted to a single string, with all the values SEPARATED by a comma?

The "BUS" won't work unless it has a string with each of the values separated by a comma.

oddson ·

Large wrote: ...post an OSM of a text file, full of values, being converted to a single string, with all the values SEPARATED by a comma...

What's the text file use to delim items?

BTW - Bus will also take a text field with returns instead of commas!

Large ·

Why won't the BUS pass the data to the floats? You can see the data already inside the bus, yet all the connected floats read "0".

Large ·

And here's the OSM.

Can someone please make it work? I'm stuck 🙁

mwvdlee ·

Large wrote: And here's the OSM.

Can someone please make it work? I'm stuck 🙁

That's not really how a bus is supposed to work. The string at the top should contain the NAMES of the variables in the bus, then you have to use the Bus Create module to put the variables in the bus.

Large ·

mwvdlee wrote: That's not really how a bus is supposed to work. The string at the top should contain the NAMES of the variables in the bus, then you have to use the Bus Create module to put the variables in the bus.

Which brings me back to my original question. How does one convert the text file into a string with all the values separated by a comma? So it will work with the bus?

Could someone post an OSM of this working properly?

. . .

mwvdlee ·

Large wrote: Which brings me back to my original question. How does one convert the text file into a string with all the values separated by a comma? So it will work with the bus?

I'm not really understanding the question. Perhaps if you gave an example of what the input would look like and how you'd like the output to look like?

oddson ·

mwvdlee wrote: How does one convert the text file into a string with all the values separated by a comma?

mwvdlee wrote: Could someone post an OSM of this working properly?

oddson ·

And if you really need to get data from an list into a bus as separate parameters.

Large ·

oddson wrote: And if you really need to get data from an list into a bus as separate parameters.

Yes, thanks Oddson!

This is what I needed.

🙂

infuzion ·

Should be "fixed" or feature? Test: [old link]

mwvdlee ·

infuzion wrote: Should be "fixed" or feature? Test: [old link]

I'm holding off on marking this "Fixed" until I get a version of SM2 which is equal or better than the one with this bug. Since I'm having significant issues with SM2, SM1.7 is still the most recent full release, IMHO. Apparently 2.0.3 will revert the envelope bugfix to fix the current issues I'm having with audio (and hopefully provide a different fix), at which point there is indeed an SM2 which is atleast equal or better in every feature I'm aware of.

trogluddite ·

aliasant ·

trogluddite wrote:

Thanx. Nice explanation 🙂

Sasu Honka ·

I had not found that. Very handy when parsing together various list arrays. Thanks!

Wrote something here? To have a post removed or your name hidden, write to [email protected].

Before your first post

A few rules keep this a friendly place. You agree to them once.

Shown next to what you post, here and in the app. It doesn’t have to be your real name: 3–24 lower-case letters, digits or _ (capitals become lower case, spaces become _).

    Then your post goes up straight away.

    Delete this reply?

    Open it in SynthMaker?

    It goes on the track you’re editing there, in place of that track’s sound, and into My sounds. Your other tracks stay as they are.

    Want to keep that track’s sound? Start a new song in SynthMaker first (Song › New song), then open this.

    Report this reply?

    Only the developer reads reports. The person isn’t told who reported them.

    What’s wrong with it?

    Block this person?

    You won’t see their posts and replies here any more. They aren’t told, and you can unblock them at any time.

    People you’ve blocked

    Their posts and replies are hidden from you. Unblock someone to see them again.

    The community rules

    A few rules keep this a friendly place. Everyone agrees to them once, before their first post.