ArrayArrayArray BrainModular BrainModular Users Forum 2023-05-03T10:50:45+02:00 https://www.brainmodular.com/forums/app.php/feed/topic/7130 2023-05-03T10:50:45+02:00 2023-05-03T10:50:45+02:00 https://www.brainmodular.com/forums/viewtopic.php?t=7130&p=44766#p44766 <![CDATA[Re: script contest]]> i choose to do that by script only for learning.

Statistics: Posted by joffo78 — 03 May 2023, 10:50


]]>
2023-05-02T09:12:54+02:00 2023-05-02T09:12:54+02:00 https://www.brainmodular.com/forums/viewtopic.php?t=7130&p=44765#p44765 <![CDATA[Re: script contest]]> But I'm shure that you can do that very efficiently with simple modules ?

CODE:

////////////////////////////Simplest Callback exemple: check wich in changed/////////////////////////                                          const SIZE_ARRAY_MAX = 1024; // max size of array inputsconst NB_INPUTS = 3;type TmemoArray = array[0..SIZE_ARRAY_MAX-1] of single;var Inp : array [0..NB_INPUTS-1] of Tparameter;          var inputChanged    : Tparameter;var ValueChanged   : Tparameter;var ArrayIndexChanged : Tparameter;var memoArray : array[0..NB_INPUTS-1] of TmemoArray;//////////////////////////////////////   // Init is started on script compilation to create the in/outsPROCEDURE INIT;var i : integer;BEGIN                                      for i := 0 to NB_INPUTS-1  do Inp[i] := CreateParam('Input'+inttostr(i),PtArray,pioInput);     InputChanged:= CreateParam('InputChanged',PtDataField,pioOutput);  InputChanged.Max(2);  ValueChanged:= CreateParam('ValueChanged',PtdataField,pioOutput);  ArrayIndexChanged := CreateParam('ArrayIndexChanged',PtdataField,pioOutput);END;//////////////////////////////////////// Test changes                      Procedure TestChanged(N:integer);var mx,i : integer;var v : single;BEGIN   mx := minI(SIZE_ARRAY_MAX,inp[n].length);   for i := 0 to mx-1   do begin           v := inp[n].asArray(i);      if memoArray[n][i] <> v      then begin         ArrayIndexChanged.asinteger(i);         ValueChanged.asfloat(v);      end;      memoArray[n][i] := v;   end;   inputchanged.asInteger(n);END;//////////////////////////////////////// Callback procedure                      Procedure Callback(N:integer);             BEGIN                  if n<NB_INPUTS  then TestChanged(N);END;               

Statistics: Posted by senso — 02 May 2023, 09:12


]]>
2023-04-26T15:15:53+02:00 2023-04-26T15:15:53+02:00 https://www.brainmodular.com/forums/viewtopic.php?t=7130&p=44759#p44759 <![CDATA[script contest]]> I'm trying to learn about scripting.
To start I opened the script
simplest callback example which displays the index of the last input whose value has been modified.
I would like to :
1) to be able to add an output that would display the value of the last modified input
2) to reproduce the same script but with an array input.

Thank you to enlighten me.
Here attached the script :

CODE:

////////////////////////////Simplest Callback exemple: check wich in changed/////////////////////////                                          var In1 , In2 , In3 : Tparameter;          var inputChanged    : Tparameter;var ChangedValues   : Tparameter;//////////////////////////////////////   // Init is started on script compilation to create the in/outsPROCEDURE INIT;BEGIN                                      In1:= CreateParam('Input1',PtDataField,pioInput);   In2:= CreateParam('Input2',PtDataField,pioInput);   In3:= CreateParam('Input3',PtDataField,pioInput);     InputChanged:= CreateParam('InputChanged',PtDataField,pioOutput);  InputChanged.Min(0);  InputChanged.Max(2);  ChangedValues:= CreateParam('ValueChanged',PtdataField,pioOutput);END; //////////////////////////////////////// Callback procedure                      // inputs have an id (n) from first (top) to n last, the callback proc// scans the inputs to detect changes, // and notes the index if detecting one.// that will allows to launchs different process depending on wich kind of// inputs changedProcedure Callback(N:integer);             BEGIN                  if n<3  then inputchanged.asInteger(n);  END;                    : 

Statistics: Posted by joffo78 — 26 Apr 2023, 15:15


]]>
BrainModular BrainModular Users Forum 2023-05-03T10:50:45+02:00 https://www.brainmodular.com/forums/app.php/feed/topic/7130 2023-05-03T10:50:45+02:00 2023-05-03T10:50:45+02:00 https://www.brainmodular.com/forums/viewtopic.php?t=7130&p=44766#p44766 <![CDATA[Re: script contest]]> i choose to do that by script only for learning.

Statistics: Posted by joffo78 — 03 May 2023, 10:50


]]>
2023-05-02T09:12:54+02:00 2023-05-02T09:12:54+02:00 https://www.brainmodular.com/forums/viewtopic.php?t=7130&p=44765#p44765 <![CDATA[Re: script contest]]> But I'm shure that you can do that very efficiently with simple modules ?

CODE:

////////////////////////////Simplest Callback exemple: check wich in changed/////////////////////////                                          const SIZE_ARRAY_MAX = 1024; // max size of array inputsconst NB_INPUTS = 3;type TmemoArray = array[0..SIZE_ARRAY_MAX-1] of single;var Inp : array [0..NB_INPUTS-1] of Tparameter;          var inputChanged    : Tparameter;var ValueChanged   : Tparameter;var ArrayIndexChanged : Tparameter;var memoArray : array[0..NB_INPUTS-1] of TmemoArray;//////////////////////////////////////   // Init is started on script compilation to create the in/outsPROCEDURE INIT;var i : integer;BEGIN                                      for i := 0 to NB_INPUTS-1  do Inp[i] := CreateParam('Input'+inttostr(i),PtArray,pioInput);     InputChanged:= CreateParam('InputChanged',PtDataField,pioOutput);  InputChanged.Max(2);  ValueChanged:= CreateParam('ValueChanged',PtdataField,pioOutput);  ArrayIndexChanged := CreateParam('ArrayIndexChanged',PtdataField,pioOutput);END;//////////////////////////////////////// Test changes                      Procedure TestChanged(N:integer);var mx,i : integer;var v : single;BEGIN   mx := minI(SIZE_ARRAY_MAX,inp[n].length);   for i := 0 to mx-1   do begin           v := inp[n].asArray(i);      if memoArray[n][i] <> v      then begin         ArrayIndexChanged.asinteger(i);         ValueChanged.asfloat(v);      end;      memoArray[n][i] := v;   end;   inputchanged.asInteger(n);END;//////////////////////////////////////// Callback procedure                      Procedure Callback(N:integer);             BEGIN                  if n<NB_INPUTS  then TestChanged(N);END;               

Statistics: Posted by senso — 02 May 2023, 09:12


]]>
2023-04-26T15:15:53+02:00 2023-04-26T15:15:53+02:00 https://www.brainmodular.com/forums/viewtopic.php?t=7130&p=44759#p44759 <![CDATA[script contest]]> I'm trying to learn about scripting.
To start I opened the script
simplest callback example which displays the index of the last input whose value has been modified.
I would like to :
1) to be able to add an output that would display the value of the last modified input
2) to reproduce the same script but with an array input.

Thank you to enlighten me.
Here attached the script :

CODE:

////////////////////////////Simplest Callback exemple: check wich in changed/////////////////////////                                          var In1 , In2 , In3 : Tparameter;          var inputChanged    : Tparameter;var ChangedValues   : Tparameter;//////////////////////////////////////   // Init is started on script compilation to create the in/outsPROCEDURE INIT;BEGIN                                      In1:= CreateParam('Input1',PtDataField,pioInput);   In2:= CreateParam('Input2',PtDataField,pioInput);   In3:= CreateParam('Input3',PtDataField,pioInput);     InputChanged:= CreateParam('InputChanged',PtDataField,pioOutput);  InputChanged.Min(0);  InputChanged.Max(2);  ChangedValues:= CreateParam('ValueChanged',PtdataField,pioOutput);END; //////////////////////////////////////// Callback procedure                      // inputs have an id (n) from first (top) to n last, the callback proc// scans the inputs to detect changes, // and notes the index if detecting one.// that will allows to launchs different process depending on wich kind of// inputs changedProcedure Callback(N:integer);             BEGIN                  if n<3  then inputchanged.asInteger(n);  END;                    : 

Statistics: Posted by joffo78 — 26 Apr 2023, 15:15


]]>