ArrayArrayArrayArrayArrayArray BrainModular BrainModular Users Forum 2026-01-22T11:28:22+02:00 https://www.brainmodular.com/forums/app.php/feed/topic/7424 2026-01-22T11:28:22+02:00 2026-01-22T11:28:22+02:00 https://www.brainmodular.com/forums/viewtopic.php?t=7424&p=46209#p46209 <![CDATA[Re: Script "Data Generator" generates even without a trigger]]> wasn't working, so I took the old code from the Usine distro and just add one line :

CODE:

if N <> Randomiz then exit //outputs will change only if trig ariseelse
so the whole thing is :

CODE:

//////////////////////////////////////////////////////// Random Pattern Array // Generates a Random array of 0 or 1 values according to // the DENSITY parameter// Connected to a Switch Sequenced module, // can be use to create random paterns //////////////////////////////////////////////////////const NB_ARRAY_OUT = 3;var ArrayLen : Tparameter;var Density  : Tparameter;var ArrayOut : array of Tparameter;var Randomiz : TParameter;//////////////////////////////////////////////////////// initialisation procedure//////////////////////////////////////////////////////procedure init;var i : integer;begin                      ArrayLen := CreateParam('array len',ptDataField,pioInput); ArrayLen.Min(1); ArrayLen.Max(1024); ArrayLen.DefaultValue(8); ArrayLen.asInteger(8);                                     Randomiz    := CreateParam('generate',ptButton,pioInput); Density    := CreateParam('density',ptDataFader,pioInput); Density.Symbol('%'); Density.Format('%.0f'); Density.Min(0); Density.Max(100); Density.DefaultValue(50); Density.asFloat(50);  SetArraylength(ArrayOut,NB_ARRAY_OUT); for i := 0 to NB_ARRAY_OUT-1  do begin   ArrayOut[i] := CreateParam('array out '+intTostr(i),ptArray,pioOutput);   ArrayOut[i].Length(0);     end;       ModuleColor($FFE91E63);    end;// Global Variablesvar vlen : integer;var j,i : integer;var vDens : single;      //////////////////////////////////////////////////////// CallBack//////////////////////////////////////////////////////// Callback procedureProcedure Callback(N:integer);  beginif N <> Randomiz then exit //outputs will change only if trig ariseelse   vDens := Density.asFloat/100;   vlen := ArrayLen.asInteger;     for j := 0 to NB_ARRAY_OUT-1    do begin     ArrayOut[j].Length(vlen);      for i := 0 to vlen-1      do begin                if random < vDens                           then ArrayOut[j].asArray(i,1)       else ArrayOut[j].asArray(i,0);     end;                                         end;end;

Statistics: Posted by oli_lab — 22 Jan 2026, 10:28


]]>
2026-01-22T09:31:41+02:00 2026-01-22T09:31:41+02:00 https://www.brainmodular.com/forums/viewtopic.php?t=7424&p=46208#p46208 <![CDATA[Re: Script "Data Generator" generates even without a trigger]]>

CODE:

 
to paste script !

Statistics: Posted by senso — 22 Jan 2026, 08:31


]]>
2026-01-21T16:05:47+02:00 2026-01-21T16:05:47+02:00 https://www.brainmodular.com/forums/viewtopic.php?t=7424&p=46206#p46206 <![CDATA[Re: Script "Data Generator" generates even without a trigger]]> With mine if a other input than Rendomiz change I stop the process

No problem !

Statistics: Posted by BM2F — 21 Jan 2026, 15:05


]]>
2026-01-21T15:10:05+02:00 2026-01-21T15:10:05+02:00 https://www.brainmodular.com/forums/viewtopic.php?t=7424&p=46205#p46205 <![CDATA[Re: Script "Data Generator" generates even without a trigger]]> yes, that's what i did, filtering the unwanted random events, but that was not very efficient.

I have had to changed two lines, otherwise the script would not compile : line 40 "can't assign int32 to array of int32

I just added [ i ] to the line 40 : ArrayOut[ i ] := CreateParam('array out '+intTostr(i),ptArray,pioOutput);

and the next one 41, see below

HERE IS THE PROBLEM : the forum can't display the [ i ] correctly (without spaces), so it probably disapeared in the code of your message, and the script couldn't compile in my session.

If i add [ i ] (without space) in my script, now it works as it should.

I'm not sure i'm very clear, but there is a problem in the display of the forum.

Anyway thanks a lot mate !

CODE:

/////////////////////////////////////////////////////// Random Pattern Array// Generates a Random array of 0 or 1 values according to// the DENSITY parameter// Connected to a Switch Sequenced module,// can be use to create random paterns//////////////////////////////////////////////////////const NB_ARRAY_OUT = 2;var ArrayLen : Tparameter;var Density : Tparameter;var ArrayOut : array of Tparameter;var Randomiz : TParameter;//////////////////////////////////////////////////////// initialisation procedure//////////////////////////////////////////////////////procedure Init;var i : integer;beginArrayLen := CreateParam('array len',ptDataField,pioInput);ArrayLen.Min(1);ArrayLen.Max(1024);ArrayLen.DefaultValue(8);ArrayLen.asInteger(8);Randomiz := CreateParam('generate',ptButton,pioInput);Density := CreateParam('density',ptDataFader,pioInput);Density.Symbol('%');Density.Format('%.0f');Density.Min(0);Density.Max(100);Density.DefaultValue(50);Density.asFloat(50);SetArraylength(ArrayOut,NB_ARRAY_OUT);for i := 0 to NB_ARRAY_OUT-1do beginArrayOut[i] *****problem**** := CreateParam('array out '+intTostr(i),ptArray,pioOutput);ArrayOut[i]*****problem**** .Length(0);end;ModuleColor($FFE91E63);end;// Global Variablesvar vlen : integer;var j,i : integer;var vDens : single;//////////////////////////////////////////////////////// CallBack//////////////////////////////////////////////////////// Callback procedureProcedure Callback(N:integer);beginif N <> Randomiz then exitelsevDens := Density.asFloat/100;vlen := ArrayLen.asInteger;for j := 0 to NB_ARRAY_OUT-1do beginArrayOut[j].Length(vlen);for i := 0 to vlen-1do beginif random < vDensthen ArrayOut[j].asArray(i,1)else ArrayOut[j].asArray(i,0);end;end;end;

Statistics: Posted by Charlie O. — 21 Jan 2026, 14:10


]]>
2026-01-21T11:52:51+02:00 2026-01-21T11:52:51+02:00 https://www.brainmodular.com/forums/viewtopic.php?t=7424&p=46203#p46203 <![CDATA[Re: Script "Data Generator" generates even without a trigger]]>
The issue was in Callback, the script compute whatever parameters changed.
You can solve it with a pass before input script (triggered by you generate trigger)
or modifie the script :

Happy patching !

CODE:

//////////////////////////////////////////////////////// Random Pattern Array // Generates a Random array of 0 or 1 values according to // the DENSITY parameter// Connected to a Switch Sequenced module, // can be use to create random paterns //////////////////////////////////////////////////////const NB_ARRAY_OUT = 3;var ArrayLen : Tparameter;var Density  : Tparameter;var ArrayOut : array of Tparameter;var Randomiz : TParameter;//////////////////////////////////////////////////////// initialisation procedure//////////////////////////////////////////////////////procedure Init;var i : integer;begin                      ArrayLen := CreateParam('array len',ptDataField,pioInput); ArrayLen.Min(1); ArrayLen.Max(1024); ArrayLen.DefaultValue(8); ArrayLen.asInteger(8);                                     Randomiz    := CreateParam('generate',ptButton,pioInput); Density    := CreateParam('density',ptDataFader,pioInput); Density.Symbol('%'); Density.Format('%.0f'); Density.Min(0); Density.Max(100); Density.DefaultValue(50); Density.asFloat(50);  SetArraylength(ArrayOut,NB_ARRAY_OUT); for i := 0 to NB_ARRAY_OUT-1  do begin   ArrayOut[i] := CreateParam('array out '+intTostr(i),ptArray,pioOutput);   ArrayOut[i].Length(0);     end;       ModuleColor($FFE91E63);    end;// Global Variablesvar vlen : integer;var j,i : integer;var vDens : single;      //////////////////////////////////////////////////////// CallBack//////////////////////////////////////////////////////// Callback procedureProcedure Callback(N:integer);  beginif N <> Randomiz then exitelse   vDens := Density.asFloat/100;   vlen := ArrayLen.asInteger;     for j := 0 to NB_ARRAY_OUT-1    do begin     ArrayOut[j].Length(vlen);      for i := 0 to vlen-1      do begin                if random < vDens                           then ArrayOut[j].asArray(i,1)       else ArrayOut[j].asArray(i,0);     end;                                         end;end;

Statistics: Posted by BM2F — 21 Jan 2026, 10:52


]]>
2026-01-20T23:33:25+02:00 2026-01-20T23:33:25+02:00 https://www.brainmodular.com/forums/viewtopic.php?t=7424&p=46202#p46202 <![CDATA[Script "Data Generator" generates even without a trigger]]>
I have a problem with one of the scripts from the Browser/Modules/Data/Generators, the "Data Generator Random Pattern Array" script. It has three inputs : Array In, Generate (trigger type), and Density (data float).

The problem is that when the density fluctuates, the module generates randoms arrays, even without a trigger.

Here is the code, if somebody has an idea and can help me how to correct it ?

CODE:

//////////////////////////////////////////////////////// Random Pattern Array// Generates a Random array of 0 or 1 values according to// the DENSITY parameter// Connected to a Switch Sequenced module,// can be use to create random paterns//////////////////////////////////////////////////////const NB_ARRAY_OUT = 2;var ArrayLen : Tparameter;var Density  : Tparameter;var ArrayOut : array of Tparameter;var Randomiz : TParameter;//////////////////////////////////////////////////////// initialisation procedure//////////////////////////////////////////////////////procedure init;var i : integer;begin                     ArrayLen := CreateParam('array len',ptDataField,pioInput); ArrayLen.Min(1); ArrayLen.Max(1024); ArrayLen.DefaultValue(8); ArrayLen.asInteger(8);                                     Randomiz    := CreateParam('generate',ptButton,pioInput); Density    := CreateParam('density',ptDataFader,pioInput); Density.Symbol('%'); Density.Format('%.0f'); Density.Min(0); Density.Max(100); Density.DefaultValue(50); Density.asFloat(50);  SetArraylength(ArrayOut,NB_ARRAY_OUT); for i := 0 to NB_ARRAY_OUT-1 do begin   ArrayOut[i] := CreateParam('array out '+intTostr(i),ptArray,pioOutput);   ArrayOut[i].Length(0);     end;       ModuleColor($FFE91E63);    end;// Global Variablesvar vlen : integer;var j,i : integer;var vDens : single;      //////////////////////////////////////////////////////// CallBack//////////////////////////////////////////////////////// Callback procedureProcedure Callback(N:integer);  begin   vDens := Density.asFloat/100;   vlen := ArrayLen.asInteger;     for j := 0 to NB_ARRAY_OUT-1   do begin     ArrayOut[j].Length(vlen);     for i := 0 to vlen-1     do begin               if random < vDens                           then ArrayOut[j].asArray(i,1)       else ArrayOut[j].asArray(i,0);     end;                                         end;end;
Thank's a lot !

Statistics: Posted by Charlie O. — 20 Jan 2026, 22:33


]]>
BrainModular BrainModular Users Forum 2026-01-22T11:28:22+02:00 https://www.brainmodular.com/forums/app.php/feed/topic/7424 2026-01-22T11:28:22+02:00 2026-01-22T11:28:22+02:00 https://www.brainmodular.com/forums/viewtopic.php?t=7424&p=46209#p46209 <![CDATA[Re: Script "Data Generator" generates even without a trigger]]> wasn't working, so I took the old code from the Usine distro and just add one line :

CODE:

if N <> Randomiz then exit //outputs will change only if trig ariseelse
so the whole thing is :

CODE:

//////////////////////////////////////////////////////// Random Pattern Array // Generates a Random array of 0 or 1 values according to // the DENSITY parameter// Connected to a Switch Sequenced module, // can be use to create random paterns //////////////////////////////////////////////////////const NB_ARRAY_OUT = 3;var ArrayLen : Tparameter;var Density  : Tparameter;var ArrayOut : array of Tparameter;var Randomiz : TParameter;//////////////////////////////////////////////////////// initialisation procedure//////////////////////////////////////////////////////procedure init;var i : integer;begin                      ArrayLen := CreateParam('array len',ptDataField,pioInput); ArrayLen.Min(1); ArrayLen.Max(1024); ArrayLen.DefaultValue(8); ArrayLen.asInteger(8);                                     Randomiz    := CreateParam('generate',ptButton,pioInput); Density    := CreateParam('density',ptDataFader,pioInput); Density.Symbol('%'); Density.Format('%.0f'); Density.Min(0); Density.Max(100); Density.DefaultValue(50); Density.asFloat(50);  SetArraylength(ArrayOut,NB_ARRAY_OUT); for i := 0 to NB_ARRAY_OUT-1  do begin   ArrayOut[i] := CreateParam('array out '+intTostr(i),ptArray,pioOutput);   ArrayOut[i].Length(0);     end;       ModuleColor($FFE91E63);    end;// Global Variablesvar vlen : integer;var j,i : integer;var vDens : single;      //////////////////////////////////////////////////////// CallBack//////////////////////////////////////////////////////// Callback procedureProcedure Callback(N:integer);  beginif N <> Randomiz then exit //outputs will change only if trig ariseelse   vDens := Density.asFloat/100;   vlen := ArrayLen.asInteger;     for j := 0 to NB_ARRAY_OUT-1    do begin     ArrayOut[j].Length(vlen);      for i := 0 to vlen-1      do begin                if random < vDens                           then ArrayOut[j].asArray(i,1)       else ArrayOut[j].asArray(i,0);     end;                                         end;end;

Statistics: Posted by oli_lab — 22 Jan 2026, 10:28


]]>
2026-01-22T09:31:41+02:00 2026-01-22T09:31:41+02:00 https://www.brainmodular.com/forums/viewtopic.php?t=7424&p=46208#p46208 <![CDATA[Re: Script "Data Generator" generates even without a trigger]]>

CODE:

 
to paste script !

Statistics: Posted by senso — 22 Jan 2026, 08:31


]]>
2026-01-21T16:05:47+02:00 2026-01-21T16:05:47+02:00 https://www.brainmodular.com/forums/viewtopic.php?t=7424&p=46206#p46206 <![CDATA[Re: Script "Data Generator" generates even without a trigger]]> With mine if a other input than Rendomiz change I stop the process

No problem !

Statistics: Posted by BM2F — 21 Jan 2026, 15:05


]]>
2026-01-21T15:10:05+02:00 2026-01-21T15:10:05+02:00 https://www.brainmodular.com/forums/viewtopic.php?t=7424&p=46205#p46205 <![CDATA[Re: Script "Data Generator" generates even without a trigger]]> yes, that's what i did, filtering the unwanted random events, but that was not very efficient.

I have had to changed two lines, otherwise the script would not compile : line 40 "can't assign int32 to array of int32

I just added [ i ] to the line 40 : ArrayOut[ i ] := CreateParam('array out '+intTostr(i),ptArray,pioOutput);

and the next one 41, see below

HERE IS THE PROBLEM : the forum can't display the [ i ] correctly (without spaces), so it probably disapeared in the code of your message, and the script couldn't compile in my session.

If i add [ i ] (without space) in my script, now it works as it should.

I'm not sure i'm very clear, but there is a problem in the display of the forum.

Anyway thanks a lot mate !

CODE:

/////////////////////////////////////////////////////// Random Pattern Array// Generates a Random array of 0 or 1 values according to// the DENSITY parameter// Connected to a Switch Sequenced module,// can be use to create random paterns//////////////////////////////////////////////////////const NB_ARRAY_OUT = 2;var ArrayLen : Tparameter;var Density : Tparameter;var ArrayOut : array of Tparameter;var Randomiz : TParameter;//////////////////////////////////////////////////////// initialisation procedure//////////////////////////////////////////////////////procedure Init;var i : integer;beginArrayLen := CreateParam('array len',ptDataField,pioInput);ArrayLen.Min(1);ArrayLen.Max(1024);ArrayLen.DefaultValue(8);ArrayLen.asInteger(8);Randomiz := CreateParam('generate',ptButton,pioInput);Density := CreateParam('density',ptDataFader,pioInput);Density.Symbol('%');Density.Format('%.0f');Density.Min(0);Density.Max(100);Density.DefaultValue(50);Density.asFloat(50);SetArraylength(ArrayOut,NB_ARRAY_OUT);for i := 0 to NB_ARRAY_OUT-1do beginArrayOut[i] *****problem**** := CreateParam('array out '+intTostr(i),ptArray,pioOutput);ArrayOut[i]*****problem**** .Length(0);end;ModuleColor($FFE91E63);end;// Global Variablesvar vlen : integer;var j,i : integer;var vDens : single;//////////////////////////////////////////////////////// CallBack//////////////////////////////////////////////////////// Callback procedureProcedure Callback(N:integer);beginif N <> Randomiz then exitelsevDens := Density.asFloat/100;vlen := ArrayLen.asInteger;for j := 0 to NB_ARRAY_OUT-1do beginArrayOut[j].Length(vlen);for i := 0 to vlen-1do beginif random < vDensthen ArrayOut[j].asArray(i,1)else ArrayOut[j].asArray(i,0);end;end;end;

Statistics: Posted by Charlie O. — 21 Jan 2026, 14:10


]]>
2026-01-21T11:52:51+02:00 2026-01-21T11:52:51+02:00 https://www.brainmodular.com/forums/viewtopic.php?t=7424&p=46203#p46203 <![CDATA[Re: Script "Data Generator" generates even without a trigger]]>
The issue was in Callback, the script compute whatever parameters changed.
You can solve it with a pass before input script (triggered by you generate trigger)
or modifie the script :

Happy patching !

CODE:

//////////////////////////////////////////////////////// Random Pattern Array // Generates a Random array of 0 or 1 values according to // the DENSITY parameter// Connected to a Switch Sequenced module, // can be use to create random paterns //////////////////////////////////////////////////////const NB_ARRAY_OUT = 3;var ArrayLen : Tparameter;var Density  : Tparameter;var ArrayOut : array of Tparameter;var Randomiz : TParameter;//////////////////////////////////////////////////////// initialisation procedure//////////////////////////////////////////////////////procedure Init;var i : integer;begin                      ArrayLen := CreateParam('array len',ptDataField,pioInput); ArrayLen.Min(1); ArrayLen.Max(1024); ArrayLen.DefaultValue(8); ArrayLen.asInteger(8);                                     Randomiz    := CreateParam('generate',ptButton,pioInput); Density    := CreateParam('density',ptDataFader,pioInput); Density.Symbol('%'); Density.Format('%.0f'); Density.Min(0); Density.Max(100); Density.DefaultValue(50); Density.asFloat(50);  SetArraylength(ArrayOut,NB_ARRAY_OUT); for i := 0 to NB_ARRAY_OUT-1  do begin   ArrayOut[i] := CreateParam('array out '+intTostr(i),ptArray,pioOutput);   ArrayOut[i].Length(0);     end;       ModuleColor($FFE91E63);    end;// Global Variablesvar vlen : integer;var j,i : integer;var vDens : single;      //////////////////////////////////////////////////////// CallBack//////////////////////////////////////////////////////// Callback procedureProcedure Callback(N:integer);  beginif N <> Randomiz then exitelse   vDens := Density.asFloat/100;   vlen := ArrayLen.asInteger;     for j := 0 to NB_ARRAY_OUT-1    do begin     ArrayOut[j].Length(vlen);      for i := 0 to vlen-1      do begin                if random < vDens                           then ArrayOut[j].asArray(i,1)       else ArrayOut[j].asArray(i,0);     end;                                         end;end;

Statistics: Posted by BM2F — 21 Jan 2026, 10:52


]]>
2026-01-20T23:33:25+02:00 2026-01-20T23:33:25+02:00 https://www.brainmodular.com/forums/viewtopic.php?t=7424&p=46202#p46202 <![CDATA[Script "Data Generator" generates even without a trigger]]>
I have a problem with one of the scripts from the Browser/Modules/Data/Generators, the "Data Generator Random Pattern Array" script. It has three inputs : Array In, Generate (trigger type), and Density (data float).

The problem is that when the density fluctuates, the module generates randoms arrays, even without a trigger.

Here is the code, if somebody has an idea and can help me how to correct it ?

CODE:

//////////////////////////////////////////////////////// Random Pattern Array// Generates a Random array of 0 or 1 values according to// the DENSITY parameter// Connected to a Switch Sequenced module,// can be use to create random paterns//////////////////////////////////////////////////////const NB_ARRAY_OUT = 2;var ArrayLen : Tparameter;var Density  : Tparameter;var ArrayOut : array of Tparameter;var Randomiz : TParameter;//////////////////////////////////////////////////////// initialisation procedure//////////////////////////////////////////////////////procedure init;var i : integer;begin                     ArrayLen := CreateParam('array len',ptDataField,pioInput); ArrayLen.Min(1); ArrayLen.Max(1024); ArrayLen.DefaultValue(8); ArrayLen.asInteger(8);                                     Randomiz    := CreateParam('generate',ptButton,pioInput); Density    := CreateParam('density',ptDataFader,pioInput); Density.Symbol('%'); Density.Format('%.0f'); Density.Min(0); Density.Max(100); Density.DefaultValue(50); Density.asFloat(50);  SetArraylength(ArrayOut,NB_ARRAY_OUT); for i := 0 to NB_ARRAY_OUT-1 do begin   ArrayOut[i] := CreateParam('array out '+intTostr(i),ptArray,pioOutput);   ArrayOut[i].Length(0);     end;       ModuleColor($FFE91E63);    end;// Global Variablesvar vlen : integer;var j,i : integer;var vDens : single;      //////////////////////////////////////////////////////// CallBack//////////////////////////////////////////////////////// Callback procedureProcedure Callback(N:integer);  begin   vDens := Density.asFloat/100;   vlen := ArrayLen.asInteger;     for j := 0 to NB_ARRAY_OUT-1   do begin     ArrayOut[j].Length(vlen);     for i := 0 to vlen-1     do begin               if random < vDens                           then ArrayOut[j].asArray(i,1)       else ArrayOut[j].asArray(i,0);     end;                                         end;end;
Thank's a lot !

Statistics: Posted by Charlie O. — 20 Jan 2026, 22:33


]]>