ArrayArrayArrayArrayArray BrainModular BrainModular Users Forum 2024-11-07T17:46:36+02:00 https://brainmodular.com/forums/app.php/feed/topic/7295 2024-11-07T17:46:36+02:00 2024-11-07T17:46:36+02:00 https://brainmodular.com/forums/viewtopic.php?t=7295&p=45561#p45561 <![CDATA[Re: trouble with callback on matrix input]]> Statistics: Posted by woodslanding — 07 Nov 2024, 16:46


]]>
2024-11-07T01:09:06+02:00 2024-11-07T01:09:06+02:00 https://brainmodular.com/forums/viewtopic.php?t=7295&p=45558#p45558 <![CDATA[Re: trouble with callback on matrix input]]> I tried to understand your patch, and I re-did it with modules from HH6
Hope it helps

Olivar

Statistics: Posted by oli_lab — 07 Nov 2024, 00:09


]]>
2024-11-06T23:36:16+02:00 2024-11-06T23:36:16+02:00 https://brainmodular.com/forums/viewtopic.php?t=7295&p=45556#p45556 <![CDATA[Re: trouble with callback on matrix input]]> On my end, text doesn't react, but matrix input works as expected. 😉
Sorry, i haven't found time to dive into your script too much.
Sylvain

Statistics: Posted by SylvainT — 06 Nov 2024, 22:36


]]>
2024-11-02T20:54:52+02:00 2024-11-02T20:54:52+02:00 https://brainmodular.com/forums/viewtopic.php?t=7295&p=45554#p45554 <![CDATA[Re: trouble with callback on matrix input]]>
MatrixSwitchTestAgain.pat
Again, if I change the value of the first cell, all arrayOUT values update correctly. But even though the callback method always gets called, it only works when the first arrayIN value changes.

Thanks
MatrixSwitchTest.pat

Statistics: Posted by woodslanding — 02 Nov 2024, 19:54


]]>
2024-11-02T21:30:50+02:00 2024-11-02T20:39:17+02:00 https://brainmodular.com/forums/viewtopic.php?t=7295&p=45553#p45553 <![CDATA[trouble with callback on matrix input]]>
Basically the output array only changes if the first item in the input array changes. I don't know why.. It sets the output array correctly for all items, but only when the first value in the input array has changed.

Thanks

CODE:

//////////////////////////////////////////////////////// read matrix data newspaper style in columns//e moon Nov 2022////////////////////////////////////////////////////const FAVTAG = '-';var rowsIN, colsIN,ctIN,valsIN : Tparameter;var ctOUT,dispCtOUT,valsOUT: Tparameter;var gTextin, gTextOut, gDisplayText : TstringList;  var row, col : integer;// Globally enable/disable logging/////////////////////////////////////// const DTAG = 'matrix Sw> ';const DBUG_ON = TRUE;procedure debug(s: string); begin if DBUG_ON then strace(DTAG + s); end;procedure iDebug(s: string; num : integer); begin debug(s + '= ' + intToStr(num)); end;procedure fDebug(s: string; num : single); begin debug(s + '= ' + floatToStr(num)); end;// Always log, whether debug is on or not.procedure Error(s: string); begin strace('ERROR-' + DTAG + s); end;procedure fError(s: string; num : single); begin strace('ERROR-' + DTAG + s + '= ' + floatToStr(num)); end;//////////////////////////////////////////////////////////////////////////procedure init;begin       colsIN := CreateParam('col ct',ptDatafield,pioInput);     rowsIN := CreateParam('row ct',ptDatafield,pioInput);    ctIN := CreateParam('ctext',ptTextField,pioInput);    valsIN := CreateParam('values',ptArray,pioInput);    ctOUT := CreateParam('ct out',ptTextField,pioOutput);    dispCtOUT := CreateParam('display ct',ptTextField,pioOutput);    valsOUT := CreateParam('values out',ptArray, pioOutput);    ModuleColor($FF8E44AD);     gTextin.create; gTextOut.create; gDisplayText.create;end;// destroyprocedure Destroy; begin gTextIn.free; gTextOut.free; gDisplayText.free; end; procedure Callback(n:integer);var i,j,len: integer;var val: float;var text,displayT: string;var options: TReplaceFlags;VAR values : ARRAY OF float;begin        //setArrayLength(values, 0);     //if n = valsIN then    //begin        len := valsIN.Length;        valsOUT.Length(len);        debug('vals in changed');        j := 0;        for col := 0 to (colsIN.asInteger - 1) do         begin            for row := 0 to (rowsIN.asInteger - 1) do             begin                 i := (colsIN.asInteger * row) + col;                                                     valsOUT.asArray(j,valsIN.asArray(i));                //values[j] := valsIN.asArray(i));                //iDebug('setting output array position',j);                //iDebug('to value',i);                j := j + 1;            end;        end;        gTextIn.clear; gTextOut.clear; gDisplayText.clear;        gTextIn.setCommaText(ctIN.asString);        options := [];                for row := 0 to (rowsIN.asInteger - 1) do         begin            for col := 0 to (colsIN.asInteger - 1) do             begin                                                      i := (rowsIN.asInteger * col) + row;                if i >= gTextIn.count then text := '' else text := gTextIn.getStrings(i);                            gTextOut.add(text);                //trim leading '-' from names for display                if text.startsWith(FAVTAG) then displayT := StringReplace(text, FAVTAG,'', options) else displayT := text;                gDisplayText.add(displayT);                j := j + 1;            end;        end;        ctOUT.asString(gTextOut.GetCommatext);         dispCtOUT.asString(gDisplayText.GetCommatext);    //end;     end;
Thanks,
-eric

Statistics: Posted by woodslanding — 02 Nov 2024, 19:39


]]>
BrainModular BrainModular Users Forum 2024-11-07T17:46:36+02:00 https://brainmodular.com/forums/app.php/feed/topic/7295 2024-11-07T17:46:36+02:00 2024-11-07T17:46:36+02:00 https://brainmodular.com/forums/viewtopic.php?t=7295&p=45561#p45561 <![CDATA[Re: trouble with callback on matrix input]]> Statistics: Posted by woodslanding — 07 Nov 2024, 16:46


]]>
2024-11-07T01:09:06+02:00 2024-11-07T01:09:06+02:00 https://brainmodular.com/forums/viewtopic.php?t=7295&p=45558#p45558 <![CDATA[Re: trouble with callback on matrix input]]> I tried to understand your patch, and I re-did it with modules from HH6
Hope it helps

Olivar

Statistics: Posted by oli_lab — 07 Nov 2024, 00:09


]]>
2024-11-06T23:36:16+02:00 2024-11-06T23:36:16+02:00 https://brainmodular.com/forums/viewtopic.php?t=7295&p=45556#p45556 <![CDATA[Re: trouble with callback on matrix input]]> On my end, text doesn't react, but matrix input works as expected. 😉
Sorry, i haven't found time to dive into your script too much.
Sylvain

Statistics: Posted by SylvainT — 06 Nov 2024, 22:36


]]>
2024-11-02T20:54:52+02:00 2024-11-02T20:54:52+02:00 https://brainmodular.com/forums/viewtopic.php?t=7295&p=45554#p45554 <![CDATA[Re: trouble with callback on matrix input]]>
MatrixSwitchTestAgain.pat
Again, if I change the value of the first cell, all arrayOUT values update correctly. But even though the callback method always gets called, it only works when the first arrayIN value changes.

Thanks
MatrixSwitchTest.pat

Statistics: Posted by woodslanding — 02 Nov 2024, 19:54


]]>
2024-11-02T21:30:50+02:00 2024-11-02T20:39:17+02:00 https://brainmodular.com/forums/viewtopic.php?t=7295&p=45553#p45553 <![CDATA[trouble with callback on matrix input]]>
Basically the output array only changes if the first item in the input array changes. I don't know why.. It sets the output array correctly for all items, but only when the first value in the input array has changed.

Thanks

CODE:

//////////////////////////////////////////////////////// read matrix data newspaper style in columns//e moon Nov 2022////////////////////////////////////////////////////const FAVTAG = '-';var rowsIN, colsIN,ctIN,valsIN : Tparameter;var ctOUT,dispCtOUT,valsOUT: Tparameter;var gTextin, gTextOut, gDisplayText : TstringList;  var row, col : integer;// Globally enable/disable logging/////////////////////////////////////// const DTAG = 'matrix Sw> ';const DBUG_ON = TRUE;procedure debug(s: string); begin if DBUG_ON then strace(DTAG + s); end;procedure iDebug(s: string; num : integer); begin debug(s + '= ' + intToStr(num)); end;procedure fDebug(s: string; num : single); begin debug(s + '= ' + floatToStr(num)); end;// Always log, whether debug is on or not.procedure Error(s: string); begin strace('ERROR-' + DTAG + s); end;procedure fError(s: string; num : single); begin strace('ERROR-' + DTAG + s + '= ' + floatToStr(num)); end;//////////////////////////////////////////////////////////////////////////procedure init;begin       colsIN := CreateParam('col ct',ptDatafield,pioInput);     rowsIN := CreateParam('row ct',ptDatafield,pioInput);    ctIN := CreateParam('ctext',ptTextField,pioInput);    valsIN := CreateParam('values',ptArray,pioInput);    ctOUT := CreateParam('ct out',ptTextField,pioOutput);    dispCtOUT := CreateParam('display ct',ptTextField,pioOutput);    valsOUT := CreateParam('values out',ptArray, pioOutput);    ModuleColor($FF8E44AD);     gTextin.create; gTextOut.create; gDisplayText.create;end;// destroyprocedure Destroy; begin gTextIn.free; gTextOut.free; gDisplayText.free; end; procedure Callback(n:integer);var i,j,len: integer;var val: float;var text,displayT: string;var options: TReplaceFlags;VAR values : ARRAY OF float;begin        //setArrayLength(values, 0);     //if n = valsIN then    //begin        len := valsIN.Length;        valsOUT.Length(len);        debug('vals in changed');        j := 0;        for col := 0 to (colsIN.asInteger - 1) do         begin            for row := 0 to (rowsIN.asInteger - 1) do             begin                 i := (colsIN.asInteger * row) + col;                                                     valsOUT.asArray(j,valsIN.asArray(i));                //values[j] := valsIN.asArray(i));                //iDebug('setting output array position',j);                //iDebug('to value',i);                j := j + 1;            end;        end;        gTextIn.clear; gTextOut.clear; gDisplayText.clear;        gTextIn.setCommaText(ctIN.asString);        options := [];                for row := 0 to (rowsIN.asInteger - 1) do         begin            for col := 0 to (colsIN.asInteger - 1) do             begin                                                      i := (rowsIN.asInteger * col) + row;                if i >= gTextIn.count then text := '' else text := gTextIn.getStrings(i);                            gTextOut.add(text);                //trim leading '-' from names for display                if text.startsWith(FAVTAG) then displayT := StringReplace(text, FAVTAG,'', options) else displayT := text;                gDisplayText.add(displayT);                j := j + 1;            end;        end;        ctOUT.asString(gTextOut.GetCommatext);         dispCtOUT.asString(gDisplayText.GetCommatext);    //end;     end;
Thanks,
-eric

Statistics: Posted by woodslanding — 02 Nov 2024, 19:39


]]>