ArrayArrayArrayArrayArrayArrayArrayArrayArrayArray
Statistics: Posted by multiphone — 14 Nov 2010, 22:58 Statistics: Posted by 23fx23 — 14 Nov 2010, 18:51 Statistics: Posted by multiphone — 14 Nov 2010, 11:16 CODE: Statistics: Posted by 23fx23 — 13 Nov 2010, 20:56
Thank for explication.
I try to unproved the script with an supplementary inlet for choose the number active of out (maybe can i patch that more easily) and a random determination of N elements in one list.
]]>
once you catched the in/out creation, more explained in the 'basics scripts' section in wiki,
the only thing to catch is Tstringlist, it's kind of delphi object that can pick a commatext, and let acces the individual
elements via indexes in it's internal memory. the script just reassingn elements to same output nb.
it just need a protection to assign only if an element exists,, via checking if index (i) is within the total number of elements
given by the SL1.count , otherwise it sets a blank name ''.
hope it helps.
]]>
Very nice !
Thanks for efficiency.
I look your code deeper.
]]>
here is the equivalent with tstringlist. /////////////////////////////////////////////// Spread CommaText Elmts to individual outs////////////////////////////////////////////Const NB_ELMTS = 8; // adjust for nb of output wanted////////////////////////////// parameters declarationvar CommaIN : Tparameter;var outputs : Array of Tparameter;var sl1 : TStringList;var i : integer;/////////////////////////procedure Destroy;begin sl1.free;end;////////////////////////////procedure init;begin CommaIN := CreateParam('Comma_In',ptTextField); SetIsOutPut(CommaIN,false);setArrayLength(OUTPUTS,NB_ELMTS); for i:=0 to NB_ELMTS -1 do begin outputs[i] := CreateParam('out'+ intToStr(i),ptTextField); SetIsInPut(Outputs[i],false); end; Sl1 := TStringList.Create; end;//////////////////////////////////////////procedure Callback(n:integer);begin if (n=commaIn) then begin SL1.commatext:= getStringValue(CommaIN); for i:= 0 to NB_ELMTS -1 do begin if i < SL1.count then begin setStringValue(outputs[i],Sl1.strings[i]); end else begin setStringValue(outputs[i],''); end; end; end;end;//////////////////////////////////////////////
]]>
Statistics: Posted by multiphone — 11 Nov 2010, 19:35
CODE:
for i:=0 to SL.count -1 do begin outputs[i] := SL.strings[i] end;Statistics: Posted by 23fx23 — 11 Nov 2010, 19:26
Statistics: Posted by multiphone — 11 Nov 2010, 18:59
CODE:
/// 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 parametersprocedure 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 blocStatistics: Posted by nay-seven — 11 Nov 2010, 18:40
Statistics: Posted by multiphone — 11 Nov 2010, 18:06
Statistics: Posted by multiphone — 14 Nov 2010, 22:58
Statistics: Posted by 23fx23 — 14 Nov 2010, 18:51
Statistics: Posted by multiphone — 14 Nov 2010, 11:16
CODE:
/////////////////////////////////////////////// Spread CommaText Elmts to individual outs////////////////////////////////////////////Const NB_ELMTS = 8; // adjust for nb of output wanted////////////////////////////// parameters declarationvar CommaIN : Tparameter;var outputs : Array of Tparameter;var sl1 : TStringList;var i : integer;/////////////////////////procedure Destroy;begin sl1.free;end;////////////////////////////procedure init;begin CommaIN := CreateParam('Comma_In',ptTextField); SetIsOutPut(CommaIN,false);setArrayLength(OUTPUTS,NB_ELMTS); for i:=0 to NB_ELMTS -1 do begin outputs[i] := CreateParam('out'+ intToStr(i),ptTextField); SetIsInPut(Outputs[i],false); end; Sl1 := TStringList.Create; end;//////////////////////////////////////////procedure Callback(n:integer);begin if (n=commaIn) then begin SL1.commatext:= getStringValue(CommaIN); for i:= 0 to NB_ELMTS -1 do begin if i < SL1.count then begin setStringValue(outputs[i],Sl1.strings[i]); end else begin setStringValue(outputs[i],''); end; end; end;end;//////////////////////////////////////////////Statistics: Posted by 23fx23 — 13 Nov 2010, 20:56
Statistics: Posted by multiphone — 11 Nov 2010, 19:35
CODE:
for i:=0 to SL.count -1 do begin outputs[i] := SL.strings[i] end;Statistics: Posted by 23fx23 — 11 Nov 2010, 19:26
Statistics: Posted by multiphone — 11 Nov 2010, 18:59
CODE:
/// 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 parametersprocedure 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 blocStatistics: Posted by nay-seven — 11 Nov 2010, 18:40
Statistics: Posted by multiphone — 11 Nov 2010, 18:06