Page 1 of 2
content management
Posted: Thu Oct 03, 2013 8:03 pm
by tester
I just noticed, that the old modules I use - will not fit here. Guess this is ruby'ish part.
I'm looking for some content management tool, that allows to split and join data according to separators.
Let say that I have something like this:
a,b,c,d,e|x,y,z,v|q,w,e,r,t,y
p,f,g,h|3,5,6,2|b,6,4,k
So I have line separators, comma separators and column separators, and string (textual+numeric) data.
Loading from the text file - how to split these data according to various separators?
Saving file - how to mix it again according the same separators?
Are there limits on how long a single line can be?
Re: content management
Posted: Thu Oct 03, 2013 8:22 pm
by billv
tester wrote:I'm looking for some content management tool, that allows to split and join data according to separators.
You may have missed this one from nubeat7....
Works great and does what you need..
http://www.dsprobotics.com/support/viewtopic.php?f=3&t=1592#p7069
Re: content management
Posted: Thu Oct 03, 2013 8:34 pm
by tester
I'm totally split between two very different topics, so I'm missing everything I can...
Thanks!
Re: content management
Posted: Thu Oct 03, 2013 9:40 pm
by Nubeat7
Re: content management
Posted: Thu Oct 03, 2013 9:42 pm
by trogluddite
Also worth noting, you don't have to use the RegEx's for the 'split' method - you can use any string (even whole words) as the split points...
There are also a few strings that have special behaviour...
Split the string at ANY whitespace - that's; space, continuous runs of spaces, tab or new-lines.
Code: Select all
@my_string.split(" ") # A single space sharacter.
Character codes...
You can specify many special characters using this 'backslash' notation - a backslash followed by a single character. The string must be inside double quotes for this to work ( " ", NOT ' ' ). The most useful are...
"\t" = TAB
"\v" = Vertical tab.
"\n" = New-line
"\r" = Carriage return
"\0xNN" = NN is a hex number, gives you the corresponding ACSII character
To reliably split lines...
There are different standards for terminating lines - sometimes 'newline', sometimes 'return', sometimes both - depending on where the string came from. Using 'split' with no separator value ensures that all possibilities are taken care of.
@Nubeat - nice tutorial links. Cheers!
Re: content management
Posted: Fri Oct 04, 2013 7:13 am
by RJHollins
Great stuff Guys !!
This stuff about RUBY is so helpful. I've been trying to use it more and more, spending most of the time hitting Google ... but there are plenty of times I've had to come back to the FS forum to really help.
I would be so good to have an FS database of RUBY stuff that could be searched out. It would probably be a nitemare to organize, but would be invaluable.
Nonetheless ... these posts help a lot !

Re: content management
Posted: Fri Oct 04, 2013 2:23 pm
by trogluddite
Oh yes - just spotted that you asked how to join them back together.
Very simple...
The separator string (e.g. ","), works mostly like the examples for the .split method shown earlier - except for when you want to join lines.
'.join()' with no argument, just joins everything end to end with no separator. To join whole lines, you need to use the 'backslash' codes. I've found, that for best compatibility with FS text displays etc. it's best to use 'return' AND 'new-line'...
Code: Select all
@my_string = @my_array.join("\r\n")
In any case, the array doesn't have to contain only strings - numbers etc. will automatically get converted.
Re: content management
Posted: Fri Oct 04, 2013 10:12 pm
by tester
Trog - could you put your thoughts into copy/paste modules to play with? I have no idea what/how to deal with it.
Meanwhile I will try to get my thoughts on what exactly I need to get.
Re: content management
Posted: Sat Oct 05, 2013 1:44 pm
by trogluddite
Copy/paste of knob/switch etc. control values, yes?
So, I'm thinking something like - copying all settings from one oscillator to another one, and that kind of thing.
This is something, I think, to consider for my "meta project"...
Maybe it seems that I have many unfinished project posted here lately - Knob, XML parsing, Graphics classes, Table displays etc. But I am working steadily to bring all of these together to make a coherent system - one "Master" module to handle MIDI parameters, undo/redo, copy/paste, 'linked' controls, user preference files etc. - and a simple module that can drop into any control design to enable the features.
Sharing data between Ruby blocks is the key to this - and the MIDI learn from those knobs I posted a few days ago is a breakthough, I think; finally a robust design for such data sharing - previous things I built had too many chances of Ruby errors. That is crucial because I think this system needs to work without the user ever needing to edit any Ruby code - it must be as simple as the VST parameter/manager to use, just a couple of modules and handful of wireless links.
That is still a long way off, so in the meantime, as far as copy/paste goes, I have done it before in one of my old SM projects. In practice, it was a lot of "wiring" and duplicate parts, but in principle quite simple...
Copy = take current value and store into a sample-and-hold prim' (the 'clipboard')
Paste = read out the S&H into the destination.
It's effective enough, but laborious to set up - separate 'clipboards' for each module type (e.g. oscillator, filter, envelope etc.)
I have also used another method - using a small text file in place of the many S&H primitives. This is the best way IMHO - because the clipboard is on the HDD, settings can be copied between different plugin instances and projects.
I will look and see if there is anything from those old designs that I can post as a practical example.
Re: content management
Posted: Sat Oct 05, 2013 1:52 pm
by tester
I mean - I read fractions of your ruby code, but have no idea where to paste them and what else to modify in order to make the ruby module work.
Playing with dozens of green connections in visual modular mode - at least the amount of choices is limited, this is how I see it; I often find solutions there even if I don't know how I did it. Playing with ruby content - "hmm... you are screaming, I don't know - did I just cut your leg?", I have no vague idea what is going on.