Welcome to %s forums

BrainModular Users Forum

Login Register

[script] splitting comma text

I need help on a Patch
Post Reply
woodslanding
Member
Posts: 1327
Contact:

Unread post by woodslanding » 05 Jan 2010, 10:04

I'd like to take a comma text input and split it out to seperate outputs. The opposite of concatenate. (I have to name 20 effect returns (20 times!) so I can mix them all together, and it's a huge number of usine objects to name. Like to autoname them from a script.)

Has this been done? I couldn't find an example. Does comma-text have quotes on each element that have to be stripped out? Commas?

I think I can figure it out, but not tonight--too late. But any tips welcome.

Wouldn't be necessary at all if usine mixed busses same as other objects :(

but this is "not how it's done".

Thanks!
-e
Custom Ryzen 5900x MATX build, Win10, Fireface UFX, touchscreen
Custom 2 manual midi keyboard
Usine, Kontakt, Reaktor, Synthmaster, Byome, Arturia, Soundtoys, Unify

23fx23
Member
Posts: 2545
Contact:

Unread post by 23fx23 » 05 Jan 2010, 10:34

bsork did a great script for that callled "comma text to separate elements" should be in addons.

or to make it in patch, I usually cascade several list box with same comma in, to each next I add 1 to input.
so that first list ouputs text 1, second text 2 ect, but from same comma in that will update all if changed.

In my square add on I made a system like this:
every bus name is linked to the text output of a list box. all list box receive same comma text from a bus "comma text"
then bus 1 list box is set on 1, bus 2 on 2 ect, update master list will update all as well.
hope it helps.

look like this:
Image

woodslanding
Member
Posts: 1327
Contact:

Unread post by woodslanding » 06 Jan 2010, 09:55

here's the answer in case it helps somebody else someday:

Code: Select all

/// commastring splitter by emoon//////

const stringCount = 6;  // if this is too small, it doesn't like it.....

var outputs    : array of Tparameter;
var input      : Tparameter;
var strings    : array of String;
var commatext  : String;

// destroy

// initialisation : create parameters
procedure init;

var digit  : string;
var i  : integer; 

begin
    input := CreateParam('commaText',ptTextField);
    SetIsOutput(input,false);
    
    setArrayLength(strings, stringCount);
    setArrayLength(outputs, stringCount); 
    
    for i := 0 to (stringCount - 1) do begin
        digit := IntToStr(i + 1);
        outputs[i] := CreateParam('String ' + digit,ptTextField);
        SetIsInPut(Outputs[i],false);
    end;
end;



procedure Callback(n:integer);
var charCount : integer;
var i : integer;
var ch: string;
var pos: integer;


begin
     commatext := ' ' + getStringValue(Input) + ',';

     i := 0;
     charCount := 0;
     for pos := 1 to length(commatext) do
     begin
        ch := copy(commatext,pos,1);       
        if (ch = ',') then 
        begin
            strings[i] := copy(commatext,pos - charCount + 1, charCount - 1);
            SetStringValue(Outputs[i],strings[i]);
            strace('in loop ' + strings[i]);
            // a little bounds checking
            if (i = length(strings)) then break; 
            i := i + 1;
            charCount := 0;           
        end;
        charCount := charCount + 1; 
          
     end;       
end;

// no process bloc
Custom Ryzen 5900x MATX build, Win10, Fireface UFX, touchscreen
Custom 2 manual midi keyboard
Usine, Kontakt, Reaktor, Synthmaster, Byome, Arturia, Soundtoys, Unify

23fx23
Member
Posts: 2545
Contact:

Unread post by 23fx23 » 06 Jan 2010, 10:31

I will check that ,cool thanks for sharing.

amiga909
Member
Posts: 324
Contact:

Unread post by amiga909 » 06 Jan 2010, 10:55

nice script, thanks!

23fx23
Member
Posts: 2545
Contact:

Unread post by 23fx23 » 09 Mar 2010, 00:03

hey woodslanding, i use a lot your script, i was wondering if you hadn't a reverse version maybe?, from severals text in create a comma text? i make my patch version but it would be more efficient with script i suppose , arf, i reaaly need to dive into!

Post Reply

Who is online

Users browsing this forum: No registered users and 16 guests