Hello
I'm working on a patch to make sequencial mouvements and i like to display some value of an array on a matrix module.
i like the approach of the script create comma text but i don't want to have to connect each output of the array on one integer to string and each integer to string on the create comma text entries .
more i have 120 value to connect.
So i wonder if someone could help me (or doing for me) a script which had one array input to get several value and make there a comma text.
thank you.
need help to make a script
hi joffo,
here is one exemple, but it's a bit unclear for me how to dynamically alter tstringList lenghts (anyone?), so it has a fixed max capacity ( i don't understand the use of Tstringlist.capacity...)
you can easy edit if need more values.
here is one exemple, but it's a bit unclear for me how to dynamically alter tstringList lenghts (anyone?), so it has a fixed max capacity ( i don't understand the use of Tstringlist.capacity...)
you can easy edit if need more values.
Code: Select all
//////////////////////////
// Array values (INTEGERS) to commaText
/////////////////////////
CONST MAX_ITEMS = 128;
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:= 0 to L-1 do begin
SL1.strings[i]:= IntToStr(trunc(getDataArrayValue(ArrayIn,i)));
end;
//Strace(SL1.commatext);
setStringValue(CommaOut,SL1.commatext);
end;
end;
END;//CB
////////////////////////////////////////
Procedure Destroy;
begin
SL1.free;
end;
///////////////////////////////hi
thank you 23fx23
and if you can have a look on my second question i think it can be very usefull.
ps. i don't understand at all what Tstringlist.capacity is
thank you 23fx23
and if you can have a look on my second question i think it can be very usefull.
ps. i don't understand at all what Tstringlist.capacity is
yup ive just seen your other question and showed ya a patch solution;), ill try to make a script later.
sorry lol never mind about tstringlist ( a delphi script object, kind of array of strings, or simply what we call a 'list' used to manipulate commatexts and elements). I was more asking to some eventual scripter reader if would know how to deal with their length, but now i remember martignasse had conclued we had to fill them first with various or blank text, so here it may not adapt to arrayIn length if it changes over time, so it is 'pre-filled-formated' of 128 elements of blank text, then will replace the items by array values. (but then i don't see what would be the use of the funtion tstringlist.capacity..., something i felt strange..)
but you shouldn't worry att all about that to use it
sorry lol never mind about tstringlist ( a delphi script object, kind of array of strings, or simply what we call a 'list' used to manipulate commatexts and elements). I was more asking to some eventual scripter reader if would know how to deal with their length, but now i remember martignasse had conclued we had to fill them first with various or blank text, so here it may not adapt to arrayIn length if it changes over time, so it is 'pre-filled-formated' of 128 elements of blank text, then will replace the items by array values. (but then i don't see what would be the use of the funtion tstringlist.capacity..., something i felt strange..)
but you shouldn't worry att all about that to use it
About TStringList, you don't have to fill it up like you do in Init. Just use SL1.Add(IntToStr(trunc(getDataArrayValue(ArrayIn,i)))) in a loop in Callback. That way you also don't have to think about MAX_SIZE as the array length will govern the length of the commatext.
No need to initialize SL1.Commatext right after Create either, it's empty anyway.
No need to initialize SL1.Commatext right after Create either, it's empty anyway.
Bjørn S
Who is online
Users browsing this forum: No registered users and 21 guests
