ArrayArrayArrayArrayArrayArrayArrayArrayArrayArrayArrayArrayArrayArrayArrayArray BrainModular BrainModular Users Forum 2010-03-31T11:11:50+02:00 https://www.brainmodular.com/forums/app.php/feed/topic/2087 2010-03-31T11:11:50+02:00 2010-03-31T11:11:50+02:00 https://www.brainmodular.com/forums/viewtopic.php?t=2087&p=13089#p13089 <![CDATA[[script] max array]]> really happy i could get your examples in concrete really helping situations. thanks once more.
im quite sure not everything is avaible in scripts, but as well not everything is listed in script reference, as i found some shr or other fonctions not listed, so..exploring!

Statistics: Posted by 23fx23 — 31 Mar 2010, 11:11


]]>
2010-03-31T11:03:03+02:00 2010-03-31T11:03:03+02:00 https://www.brainmodular.com/forums/viewtopic.php?t=2087&p=13088#p13088 <![CDATA[[script] max array]]>
Any tricks on concating array, do we need to manually fill the bigger with "for i to" or there is a function, or is it +?
"+" only works on strings AFAIK (remember, strings are essentially arrays of characters). I've taken a look at some Delphi documentation and found the Copy command, but I dont' know if that one will work in Usine - it's not listed in the scripting language Wiki.

There are a lot of Delphi resources on the Net, probably of varying quality, but the one I've been using most is Delphi Basics, which I find well written with good tutorials. Not everything in Delphi is available in scripts of course, but it doesn't hurt to try, does it? :)


[Edit] Sorry, I was too quick when looking at the Copy command: As you cannot specify any target index, the copied elements will always be put into the first elements of the target array. There is a Concat command though, but that one's for strings.

Statistics: Posted by bsork — 31 Mar 2010, 11:03


]]>
2010-03-31T09:41:59+02:00 2010-03-31T09:41:59+02:00 https://www.brainmodular.com/forums/viewtopic.php?t=2087&p=13086#p13086 <![CDATA[[script] max array]]>
Any tricks on concating array, do we need to manually fill the bigger with "for i to" or there is a function, or is it +?

Statistics: Posted by 23fx23 — 31 Mar 2010, 09:41


]]>
2010-03-30T14:53:52+02:00 2010-03-30T14:53:52+02:00 https://www.brainmodular.com/forums/viewtopic.php?t=2087&p=13060#p13060 <![CDATA[[script] max array]]>
I just tried the matrix [i,j] and manage to make a 8x extract subarray using it, start to understand, will try to go further checking valuesin subarrays, your help is like god light for me hehe, reaaaallly appreciate it, thanks once more, that rocks..

Statistics: Posted by 23fx23 — 30 Mar 2010, 14:53


]]>
2010-03-30T14:31:17+02:00 2010-03-30T14:31:17+02:00 https://www.brainmodular.com/forums/viewtopic.php?t=2087&p=13059#p13059 <![CDATA[[script] max array]]> first occurence of a value, since it's another loop construct and can be easier on the CPU as it jumps out of the loop when the value is found:

[c]
var i, firstPos : integer;
begin
firstPos := -1;
i := 0;
while ((firstPos = -1) and (i < GetLength(arr))) do
if (GetDataArrayValue(arr, i) = 1.0) then // checking for first occurence with value = 1
firstPos := i
else
i := i + 1;
[/c]

When done this way, you'd probably have a IF-test elsewhere in the program checking whether firstPos >= 0 before doing anything.


Another variety if you're only interested to find whether a value is present in an array without bothering with where it's located, also showing how you can assign values to a boolean without using IF-statements:

[c]
var valFound : boolean;
var i : integer;
begin
i := 0;
while ((not valFound) and (i < GetLength(arr))) do begin
valFound := (GetDataArrayValue(arr, i) = 1.0);
i := i + 1;
end;
[/c]

Statistics: Posted by bsork — 30 Mar 2010, 14:31


]]>
2010-03-30T13:58:44+02:00 2010-03-30T13:58:44+02:00 https://www.brainmodular.com/forums/viewtopic.php?t=2087&p=13056#p13056 <![CDATA[[script] max array]]> Statistics: Posted by 23fx23 — 30 Mar 2010, 13:58


]]>
2010-03-30T13:49:05+02:00 2010-03-30T13:49:05+02:00 https://www.brainmodular.com/forums/viewtopic.php?t=2087&p=13055#p13055 <![CDATA[[script] max array]]>
what i try do deal is making a "for j = 0 to 7" then do "for i = 0 to 7", but all my tries fail., any enlightment or tip to use?
mmm is it related to "bi-dimentional" arrays i also try to test with benjamin pdf, but without success yet, or no just correctly set
the 64 arry with good indexes..arf im lost
...

CODE:

VAR i, j OF Integer;FOR i &#58;= 0 TO 7 DO BEGIN   FOR j &#58;= 0 TO 7 DO BEGIN      matrix&#91;i, j&#93; &#58;= round&#40;GetDataArrayValue&#40;inArr, i*8+j&#41;&#41;;      ...   END;END;...
maybe this thread can help you to understand array manipulation by script ;)
http://www.sensomusic.com/forums/viewtopic.php?pid=11983#p11983

Statistics: Posted by martignasse — 30 Mar 2010, 13:49


]]>
2010-03-30T08:49:48+02:00 2010-03-30T08:49:48+02:00 https://www.brainmodular.com/forums/viewtopic.php?t=2087&p=13042#p13042 <![CDATA[[script] max array]]>
For example, in scripts with a number of input parameters where nothing much is happening when those parameters change, I practically always have at least two variables; the input parameter and an internal one. Take for instance a bypass switch in a MIDI script. In most cases I would do something like this:
[c]
VAR pBypass : tParameter;
VAR pMidiIn, pMidiOut : tParameter;
...
VAR cntIn : Integer; // number of midi messages received
VAR bypass : Boolean;
...
PROCEDURE Init;
BEGIN
pBypass := CreateParam('bypass', ptSwitch); SetIsOutput(pBypass, FALSE);
pMidiIn := CreateParam('midi in', 'ptMidi); SetIsOutput(pMidiIn, FALSE);
pMidiOut := CreateParam('midi out', 'ptMidi); SetIsInput(pMidiOut, FALSE);
bypass := FALSE;
...

PROCEDURE Callback(n : Integer);
BEGIN
CASE n OF
pBypass : bypass := (GetValue(n) > 0);
pMidiIn : cntIn := GetLength(n);
...
END;
...
[/c]

About the 8*8 matrix, here's an example assuming an input array of size 64 with only whole numbers:

[c]
VAR matrix ARRAY[0..7, 0..7] OF Integer;
...
VAR i, j OF Integer;
FOR i := 0 TO 7 DO BEGIN
FOR j := 0 TO 7 DO BEGIN
matrix[i, j] := round(GetDataArrayValue(inArr, i*8+j));
...
END;
END;
...
[/c]
(In case the only thing you're doing within the loops are getting/setting the value (or any other single statement), you can drop BEGIN..END.)

Statistics: Posted by bsork — 30 Mar 2010, 08:49


]]>
2010-03-30T07:00:27+02:00 2010-03-30T07:00:27+02:00 https://www.brainmodular.com/forums/viewtopic.php?t=2087&p=13041#p13041 <![CDATA[[script] max array]]>
so here is whole script, with ew comments hope can help, if copy and paste should work directly ...like to see if that's the good way do do it, i usually set some "tmp" variable that only at the end set "tparameters", is that the good way of doing master bsork?
Thansk 23fx23!! It works a treat - the notes are very helpful too - I'll be scouring through this later... :D

Statistics: Posted by Clearscreen — 30 Mar 2010, 07:00


]]>
2010-03-30T05:44:23+02:00 2010-03-30T05:44:23+02:00 https://www.brainmodular.com/forums/viewtopic.php?t=2087&p=13040#p13040 <![CDATA[[script] max array]]>
for my liveosc trigger grid, I got a 8x8 grid. live returns me a 64array (8clips of first track then 8 of 2nd track, ect) with their status.
(0 noclip 1, has clip 2 clip is playing). I had made a patch version that extract each sub array (from 0to7, 8to 15 ect and check
max array position so i got a result pertrack of "clip playing nb" position in the column. so, well it's working, i could stick with that...

i try to recreate viascript so i could later easy change grid size as i plan to use matrix, and i may gain cpu probably, and feel
it's a good challenge to understand script logic..

but seems far more complicate, im failing from a few hours.. I don't manage to make a correct loop scaning from 1to8 vertically, (to get max pos of "track" subarray), then continue process for 1-8horizontally, to finnally get a 8array with each track clip playing position...

what i try do deal is making a "for j = 0 to 7" then do "for i = 0 to 7", but all my tries fail., any enlightment or tip to use?
mmm is it related to "bi-dimentional" arrays i also try to test with benjamin pdf, but without success yet, or no just correctly set
the 64 arry with good indexes..arf im lost

i got it working for one subarray using previous script, so i probably could copy/adapt 8x the process, but i feel this could be done in cleaner way using one process only maybe? script masterz? (hehe now benjamin is no more there i think only you bsork remain as a script master, with senso, amiga909,martignasse, woodlsanding? why do they all stay in darkness hehe.
I hope as soon as i got main logic keys i ll stop hammering questions, but at start, it can avoid hours of debugging..

Statistics: Posted by 23fx23 — 30 Mar 2010, 05:44


]]>
2010-03-30T02:47:01+02:00 2010-03-30T02:47:01+02:00 https://www.brainmodular.com/forums/viewtopic.php?t=2087&p=13037#p13037 <![CDATA[[script] max array]]>
Max array pos/value script:
//////////////////////////
//
/////////////////////////
// parameters declaration
var arrayin: Tparameter; // here we declare "visible" in-outs/
var maxVal: Tparameter;
var maxPos: Tparameter;

// initialisation : create parameters
procedure init;
begin // start parameters creation.
Arrayin := CreateParam('arrayin',ptArray); // here we choose
SetIsOutput(ArrayIn,false); // if they are in or outs, ie here set output false let only input visible.
SetMax(ArrayIn,MAXINT); // and overide default max value wich is 100 for arrays to maxpossible integer (16777216)

MaxVal := CreateParam('maxval',ptDataField);
SetIsinput(MaxVal,false);


MaxPos := CreateParam('maxPos',ptDataField);
SetIsinput(MaxPos,false);

end; // end paraeters creation.

// Callback procedure
Procedure Callback(n:integer); // here we declare other needed variables and types
var i, maxposTmp : integer; // i and maxpos are integers, as a position is an entire nb ie.
var currVal, maxvalTmp : single; // currval and max val are some float values, so they are "singles"
begin // we start main process
if n = 0 // will process only if 1st input changes (here arrayIn) , to not process constantly.
then begin
maxvalTmp := -1; // assuming the lowest value in the array is above - 1. starting point.
maxPosTmp := -1;
for i := 0 to GetLength(arrayin)-1 do begin // scan whole array from pos 0 to length-1
currVal := GetDataArrayValue(arrayin, i);
if currVal > maxvalTmp then begin //if find a value >-1,
maxvalTmp := currval; // the found value become new max for test
maxPosTmp := i; // and the i value is then maxpos
end;
end;
end;
SetValue (maxVal,maxValTmp); // we set paameters values with the one we found.
SetValue (maxPos,maxPosTmp);
end; // always have good nb of begins and ends.

Statistics: Posted by 23fx23 — 30 Mar 2010, 02:47


]]>
2010-03-30T02:38:19+02:00 2010-03-30T02:38:19+02:00 https://www.brainmodular.com/forums/viewtopic.php?t=2087&p=13036#p13036 <![CDATA[[script] max array]]> trying to get my head around scripts but struggling badly at the moment...

Statistics: Posted by Clearscreen — 30 Mar 2010, 02:38


]]>
2010-03-29T16:00:00+02:00 2010-03-29T16:00:00+02:00 https://www.brainmodular.com/forums/viewtopic.php?t=2087&p=13026#p13026 <![CDATA[[script] max array]]> will try to time space my questions hehe.

the habit i need to get rid off is im always trying to directly set the tparameter variables, wich naturally returns me a type incompatibility error. "tparameter vs single ect."
in fact we need to always have a double "stamp" buffer variable to define it's type that's it if i well understood?

so back to my script explorations, managed to make a color array rgb to bgr i was after, (with help of senso examples) very happy.
damned im starting to love script, my social life is definitively ruined hehe..

Statistics: Posted by 23fx23 — 29 Mar 2010, 16:00


]]>
2010-03-29T12:34:06+02:00 2010-03-29T12:34:06+02:00 https://www.brainmodular.com/forums/viewtopic.php?t=2087&p=13021#p13021 <![CDATA[[script] max array]]>

Statistics: Posted by 23fx23 — 29 Mar 2010, 12:34


]]>
2010-03-29T11:16:35+02:00 2010-03-29T11:16:35+02:00 https://www.brainmodular.com/forums/viewtopic.php?t=2087&p=13016#p13016 <![CDATA[[script] max array]]>
[c]var i, maxPos : integer;
var currVal, maxVal : single;
begin
maxVal := -1; // assuming the lowest value in the array is above -1
maxPos := -1;
for i := 0 to GetLength(arr)-1 do begin
currVal := GetDataArrayValue(arr, i);
if currVal > maxVal then begin
maxVal := currVal;
maxPos := i;
end;
end;[/c]

Statistics: Posted by bsork — 29 Mar 2010, 11:16


]]>
2010-03-29T09:29:09+02:00 2010-03-29T09:29:09+02:00 https://www.brainmodular.com/forums/viewtopic.php?t=2087&p=13013#p13013 <![CDATA[[script] max array]]> im just facing a little wall:
is it posible/how to get maxarray position/value by script? is there a build in fonction or a math trick?

i wonder how t deal with position in array.
for example to make it simpler than a max array i scan an array where only one value is 1,all other are 0.
with "for i =0 to L-1" do begin,
how can i know, let's say im making a check if value=1 , the position of the value=1 in the array, if test ok, send i to another variable? edit: mm yes seems working cool,

still, any ideas on max array?

Statistics: Posted by 23fx23 — 29 Mar 2010, 09:29


]]>
BrainModular BrainModular Users Forum 2010-03-31T11:11:50+02:00 https://www.brainmodular.com/forums/app.php/feed/topic/2087 2010-03-31T11:11:50+02:00 2010-03-31T11:11:50+02:00 https://www.brainmodular.com/forums/viewtopic.php?t=2087&p=13089#p13089 <![CDATA[[script] max array]]> really happy i could get your examples in concrete really helping situations. thanks once more.
im quite sure not everything is avaible in scripts, but as well not everything is listed in script reference, as i found some shr or other fonctions not listed, so..exploring!

Statistics: Posted by 23fx23 — 31 Mar 2010, 11:11


]]>
2010-03-31T11:03:03+02:00 2010-03-31T11:03:03+02:00 https://www.brainmodular.com/forums/viewtopic.php?t=2087&p=13088#p13088 <![CDATA[[script] max array]]>
Any tricks on concating array, do we need to manually fill the bigger with "for i to" or there is a function, or is it +?
"+" only works on strings AFAIK (remember, strings are essentially arrays of characters). I've taken a look at some Delphi documentation and found the Copy command, but I dont' know if that one will work in Usine - it's not listed in the scripting language Wiki.

There are a lot of Delphi resources on the Net, probably of varying quality, but the one I've been using most is Delphi Basics, which I find well written with good tutorials. Not everything in Delphi is available in scripts of course, but it doesn't hurt to try, does it? :)


[Edit] Sorry, I was too quick when looking at the Copy command: As you cannot specify any target index, the copied elements will always be put into the first elements of the target array. There is a Concat command though, but that one's for strings.

Statistics: Posted by bsork — 31 Mar 2010, 11:03


]]>
2010-03-31T09:41:59+02:00 2010-03-31T09:41:59+02:00 https://www.brainmodular.com/forums/viewtopic.php?t=2087&p=13086#p13086 <![CDATA[[script] max array]]>
Any tricks on concating array, do we need to manually fill the bigger with "for i to" or there is a function, or is it +?

Statistics: Posted by 23fx23 — 31 Mar 2010, 09:41


]]>
2010-03-30T14:53:52+02:00 2010-03-30T14:53:52+02:00 https://www.brainmodular.com/forums/viewtopic.php?t=2087&p=13060#p13060 <![CDATA[[script] max array]]>
I just tried the matrix [i,j] and manage to make a 8x extract subarray using it, start to understand, will try to go further checking valuesin subarrays, your help is like god light for me hehe, reaaaallly appreciate it, thanks once more, that rocks..

Statistics: Posted by 23fx23 — 30 Mar 2010, 14:53


]]>
2010-03-30T14:31:17+02:00 2010-03-30T14:31:17+02:00 https://www.brainmodular.com/forums/viewtopic.php?t=2087&p=13059#p13059 <![CDATA[[script] max array]]> first occurence of a value, since it's another loop construct and can be easier on the CPU as it jumps out of the loop when the value is found:

[c]
var i, firstPos : integer;
begin
firstPos := -1;
i := 0;
while ((firstPos = -1) and (i < GetLength(arr))) do
if (GetDataArrayValue(arr, i) = 1.0) then // checking for first occurence with value = 1
firstPos := i
else
i := i + 1;
[/c]

When done this way, you'd probably have a IF-test elsewhere in the program checking whether firstPos >= 0 before doing anything.


Another variety if you're only interested to find whether a value is present in an array without bothering with where it's located, also showing how you can assign values to a boolean without using IF-statements:

[c]
var valFound : boolean;
var i : integer;
begin
i := 0;
while ((not valFound) and (i < GetLength(arr))) do begin
valFound := (GetDataArrayValue(arr, i) = 1.0);
i := i + 1;
end;
[/c]

Statistics: Posted by bsork — 30 Mar 2010, 14:31


]]>
2010-03-30T13:58:44+02:00 2010-03-30T13:58:44+02:00 https://www.brainmodular.com/forums/viewtopic.php?t=2087&p=13056#p13056 <![CDATA[[script] max array]]> Statistics: Posted by 23fx23 — 30 Mar 2010, 13:58


]]>
2010-03-30T13:49:05+02:00 2010-03-30T13:49:05+02:00 https://www.brainmodular.com/forums/viewtopic.php?t=2087&p=13055#p13055 <![CDATA[[script] max array]]>
what i try do deal is making a "for j = 0 to 7" then do "for i = 0 to 7", but all my tries fail., any enlightment or tip to use?
mmm is it related to "bi-dimentional" arrays i also try to test with benjamin pdf, but without success yet, or no just correctly set
the 64 arry with good indexes..arf im lost
...

CODE:

VAR i, j OF Integer;FOR i &#58;= 0 TO 7 DO BEGIN   FOR j &#58;= 0 TO 7 DO BEGIN      matrix&#91;i, j&#93; &#58;= round&#40;GetDataArrayValue&#40;inArr, i*8+j&#41;&#41;;      ...   END;END;...
maybe this thread can help you to understand array manipulation by script ;)
http://www.sensomusic.com/forums/viewtopic.php?pid=11983#p11983

Statistics: Posted by martignasse — 30 Mar 2010, 13:49


]]>
2010-03-30T08:49:48+02:00 2010-03-30T08:49:48+02:00 https://www.brainmodular.com/forums/viewtopic.php?t=2087&p=13042#p13042 <![CDATA[[script] max array]]>
For example, in scripts with a number of input parameters where nothing much is happening when those parameters change, I practically always have at least two variables; the input parameter and an internal one. Take for instance a bypass switch in a MIDI script. In most cases I would do something like this:
[c]
VAR pBypass : tParameter;
VAR pMidiIn, pMidiOut : tParameter;
...
VAR cntIn : Integer; // number of midi messages received
VAR bypass : Boolean;
...
PROCEDURE Init;
BEGIN
pBypass := CreateParam('bypass', ptSwitch); SetIsOutput(pBypass, FALSE);
pMidiIn := CreateParam('midi in', 'ptMidi); SetIsOutput(pMidiIn, FALSE);
pMidiOut := CreateParam('midi out', 'ptMidi); SetIsInput(pMidiOut, FALSE);
bypass := FALSE;
...

PROCEDURE Callback(n : Integer);
BEGIN
CASE n OF
pBypass : bypass := (GetValue(n) > 0);
pMidiIn : cntIn := GetLength(n);
...
END;
...
[/c]

About the 8*8 matrix, here's an example assuming an input array of size 64 with only whole numbers:

[c]
VAR matrix ARRAY[0..7, 0..7] OF Integer;
...
VAR i, j OF Integer;
FOR i := 0 TO 7 DO BEGIN
FOR j := 0 TO 7 DO BEGIN
matrix[i, j] := round(GetDataArrayValue(inArr, i*8+j));
...
END;
END;
...
[/c]
(In case the only thing you're doing within the loops are getting/setting the value (or any other single statement), you can drop BEGIN..END.)

Statistics: Posted by bsork — 30 Mar 2010, 08:49


]]>
2010-03-30T07:00:27+02:00 2010-03-30T07:00:27+02:00 https://www.brainmodular.com/forums/viewtopic.php?t=2087&p=13041#p13041 <![CDATA[[script] max array]]>
so here is whole script, with ew comments hope can help, if copy and paste should work directly ...like to see if that's the good way do do it, i usually set some "tmp" variable that only at the end set "tparameters", is that the good way of doing master bsork?
Thansk 23fx23!! It works a treat - the notes are very helpful too - I'll be scouring through this later... :D

Statistics: Posted by Clearscreen — 30 Mar 2010, 07:00


]]>
2010-03-30T05:44:23+02:00 2010-03-30T05:44:23+02:00 https://www.brainmodular.com/forums/viewtopic.php?t=2087&p=13040#p13040 <![CDATA[[script] max array]]>
for my liveosc trigger grid, I got a 8x8 grid. live returns me a 64array (8clips of first track then 8 of 2nd track, ect) with their status.
(0 noclip 1, has clip 2 clip is playing). I had made a patch version that extract each sub array (from 0to7, 8to 15 ect and check
max array position so i got a result pertrack of "clip playing nb" position in the column. so, well it's working, i could stick with that...

i try to recreate viascript so i could later easy change grid size as i plan to use matrix, and i may gain cpu probably, and feel
it's a good challenge to understand script logic..

but seems far more complicate, im failing from a few hours.. I don't manage to make a correct loop scaning from 1to8 vertically, (to get max pos of "track" subarray), then continue process for 1-8horizontally, to finnally get a 8array with each track clip playing position...

what i try do deal is making a "for j = 0 to 7" then do "for i = 0 to 7", but all my tries fail., any enlightment or tip to use?
mmm is it related to "bi-dimentional" arrays i also try to test with benjamin pdf, but without success yet, or no just correctly set
the 64 arry with good indexes..arf im lost

i got it working for one subarray using previous script, so i probably could copy/adapt 8x the process, but i feel this could be done in cleaner way using one process only maybe? script masterz? (hehe now benjamin is no more there i think only you bsork remain as a script master, with senso, amiga909,martignasse, woodlsanding? why do they all stay in darkness hehe.
I hope as soon as i got main logic keys i ll stop hammering questions, but at start, it can avoid hours of debugging..

Statistics: Posted by 23fx23 — 30 Mar 2010, 05:44


]]>
2010-03-30T02:47:01+02:00 2010-03-30T02:47:01+02:00 https://www.brainmodular.com/forums/viewtopic.php?t=2087&p=13037#p13037 <![CDATA[[script] max array]]>
Max array pos/value script:
//////////////////////////
//
/////////////////////////
// parameters declaration
var arrayin: Tparameter; // here we declare "visible" in-outs/
var maxVal: Tparameter;
var maxPos: Tparameter;

// initialisation : create parameters
procedure init;
begin // start parameters creation.
Arrayin := CreateParam('arrayin',ptArray); // here we choose
SetIsOutput(ArrayIn,false); // if they are in or outs, ie here set output false let only input visible.
SetMax(ArrayIn,MAXINT); // and overide default max value wich is 100 for arrays to maxpossible integer (16777216)

MaxVal := CreateParam('maxval',ptDataField);
SetIsinput(MaxVal,false);


MaxPos := CreateParam('maxPos',ptDataField);
SetIsinput(MaxPos,false);

end; // end paraeters creation.

// Callback procedure
Procedure Callback(n:integer); // here we declare other needed variables and types
var i, maxposTmp : integer; // i and maxpos are integers, as a position is an entire nb ie.
var currVal, maxvalTmp : single; // currval and max val are some float values, so they are "singles"
begin // we start main process
if n = 0 // will process only if 1st input changes (here arrayIn) , to not process constantly.
then begin
maxvalTmp := -1; // assuming the lowest value in the array is above - 1. starting point.
maxPosTmp := -1;
for i := 0 to GetLength(arrayin)-1 do begin // scan whole array from pos 0 to length-1
currVal := GetDataArrayValue(arrayin, i);
if currVal > maxvalTmp then begin //if find a value >-1,
maxvalTmp := currval; // the found value become new max for test
maxPosTmp := i; // and the i value is then maxpos
end;
end;
end;
SetValue (maxVal,maxValTmp); // we set paameters values with the one we found.
SetValue (maxPos,maxPosTmp);
end; // always have good nb of begins and ends.

Statistics: Posted by 23fx23 — 30 Mar 2010, 02:47


]]>
2010-03-30T02:38:19+02:00 2010-03-30T02:38:19+02:00 https://www.brainmodular.com/forums/viewtopic.php?t=2087&p=13036#p13036 <![CDATA[[script] max array]]> trying to get my head around scripts but struggling badly at the moment...

Statistics: Posted by Clearscreen — 30 Mar 2010, 02:38


]]>
2010-03-29T16:00:00+02:00 2010-03-29T16:00:00+02:00 https://www.brainmodular.com/forums/viewtopic.php?t=2087&p=13026#p13026 <![CDATA[[script] max array]]> will try to time space my questions hehe.

the habit i need to get rid off is im always trying to directly set the tparameter variables, wich naturally returns me a type incompatibility error. "tparameter vs single ect."
in fact we need to always have a double "stamp" buffer variable to define it's type that's it if i well understood?

so back to my script explorations, managed to make a color array rgb to bgr i was after, (with help of senso examples) very happy.
damned im starting to love script, my social life is definitively ruined hehe..

Statistics: Posted by 23fx23 — 29 Mar 2010, 16:00


]]>
2010-03-29T12:34:06+02:00 2010-03-29T12:34:06+02:00 https://www.brainmodular.com/forums/viewtopic.php?t=2087&p=13021#p13021 <![CDATA[[script] max array]]>

Statistics: Posted by 23fx23 — 29 Mar 2010, 12:34


]]>
2010-03-29T11:16:35+02:00 2010-03-29T11:16:35+02:00 https://www.brainmodular.com/forums/viewtopic.php?t=2087&p=13016#p13016 <![CDATA[[script] max array]]>
[c]var i, maxPos : integer;
var currVal, maxVal : single;
begin
maxVal := -1; // assuming the lowest value in the array is above -1
maxPos := -1;
for i := 0 to GetLength(arr)-1 do begin
currVal := GetDataArrayValue(arr, i);
if currVal > maxVal then begin
maxVal := currVal;
maxPos := i;
end;
end;[/c]

Statistics: Posted by bsork — 29 Mar 2010, 11:16


]]>
2010-03-29T09:29:09+02:00 2010-03-29T09:29:09+02:00 https://www.brainmodular.com/forums/viewtopic.php?t=2087&p=13013#p13013 <![CDATA[[script] max array]]> im just facing a little wall:
is it posible/how to get maxarray position/value by script? is there a build in fonction or a math trick?

i wonder how t deal with position in array.
for example to make it simpler than a max array i scan an array where only one value is 1,all other are 0.
with "for i =0 to L-1" do begin,
how can i know, let's say im making a check if value=1 , the position of the value=1 in the array, if test ok, send i to another variable? edit: mm yes seems working cool,

still, any ideas on max array?

Statistics: Posted by 23fx23 — 29 Mar 2010, 09:29


]]>