Welcome to %s forums

BrainModular Users Forum

Login Register

comma text to arry

I need help on a Patch
Post Reply
joffo78
Member
Posts: 1033
Contact:

Unread post by joffo78 » 15 Jan 2013, 12:21

Hello.
I don't think i'll be complicated to do but does someone could help me to create a script
that get a comma text to create array ?
I try to transform string to integer by changing tparameter by tarray but it doesn't work

User avatar
nay-seven
Site Admin
Posts: 5684
Location: rennes France
Contact:

Unread post by nay-seven » 15 Jan 2013, 13:37

can't really help you but I've found this in my archives , exactly the inverse of what you're looking for, maybe a inspiration source

Code: Select all

//////////////////////////
// Array values (INTEGERS) to commaText
/////////////////////////
CONST MAX_ITEMS = 160;
var ArrayIn, CommaOUT: Tparameter;
var SL1: TstringList;
/////////////////////////////
procedure init;
var i: integer;
begin
  ArrayIn:= CreateParam('ArrayIn', PtArray);
  SetIsOutput(ArrayIn,False); SetMin(ArrayIn,0); setMax(ArrayIn,MAXINT);

  CommaOUT:= CreateParam('CommaOUT',PtTextField);
  setisINPUT(commaOut,false);
   
  SL1:= Tstringlist.create;
  SL1.commatext:='';
  for i:= 0 to MAX_ITEMS -1 do begin SL1.add(' ');end;

END;//INIT
///////////////////////////////////////////
Procedure Callback(N:integer); 
var i, L: integer;
begin
      if (n=ArrayIn) then begin
         L:= getLength(ArrayIn);
         if L< MAX_ITEMS then begin
            For i&#58;= 0 to L-1 do begin
               SL1.strings&#91;i&#93;&#58;= IntToStr&#40;trunc&#40;getDataArrayValue&#40;ArrayIn,i&#41;&#41;&#41;;
            end;
         //Strace&#40;SL1.commatext&#41;;
         setStringValue&#40;CommaOut,SL1.commatext&#41;;
       end;
      end;
END;//CB
////////////////////////////////////////
Procedure Destroy;
begin
SL1.free;
end;
///////////////////////////////

joffo78
Member
Posts: 1033
Contact:

Unread post by joffo78 » 15 Jan 2013, 19:32

For who are interested (i wonder why someone could be interested by this except me :D ) :
//////////////////////////
// Array values (INTEGERS) to commaText
/////////////////////////
var ArrayOut, CommaIn: Tparameter;
var SL1: TstringList;
/////////////////////////////
procedure init;
var i: integer;
begin
CommaIn:= CreateParam('Comma In',PtTextField);
setisOutput(commaIn,false);

ArrayOut:= CreateParam('Array Out', PtArray);
SetIsInput(ArrayOut,False);
SetMin(ArrayOut,0);
setMax(ArrayOut,MAXINT);

SL1:= Tstringlist.create;
SL1.commatext:='';
END;//INIT
///////////////////////////////////////////
Procedure Callback(N:integer);
var i, L: integer;
begin
SL1.CommaText := GetStringValue(CommaIn);
Strace(SL1.commatext);
L := SL1.Count;
SetLength(ArrayOut,L);
For i :=0 to L-1
do SetDataArrayValue(ArrayOut,i,StrtoFloat(SL1.strings));
END;//CB
////////////////////////////////////////
Procedure Destroy;
begin
SL1.free;
end;
///////////////////////////////

Thank to senso.

percuson
Member
Posts: 105
Location: Leipzig, Germany
Contact:

Unread post by percuson » 16 Jan 2013, 00:46

Thanks Joffo and Senso, I was searching for that a few weeks ago, but forgot why....
Maybe I'll find out again :-)

woodslanding
Member
Posts: 1327
Contact:

Unread post by woodslanding » 05 Feb 2013, 01:41

Oh, I use that.....

I will see if this code is cleaner than what I'm using (probably so, if it's from Senso!)
Custom Ryzen 5900x MATX build, Win10, Fireface UFX, touchscreen
Custom 2 manual midi keyboard
Usine, Kontakt, Reaktor, Synthmaster, Byome, Arturia, Soundtoys, Unify

Post Reply

Who is online

Users browsing this forum: No registered users and 107 guests