ArrayArrayArrayArrayArrayArrayArrayArrayArray
Statistics: Posted by 23fx23 — 10 Jun 2010, 23:18 CODE: Statistics: Posted by bsork — 03 Jun 2010, 15:17 Statistics: Posted by 23fx23 — 03 Jun 2010, 14:38 CODE: Statistics: Posted by bsork — 03 Jun 2010, 09:06 Statistics: Posted by 23fx23 — 03 Jun 2010, 04:19 Statistics: Posted by 23fx23 — 02 Jun 2010, 23:25
]]>
PS You got me a bit confused there - I thought the lower case L was and upper case I. How could that work?!?VAR i, msVal : Integer;msVal := 0;FOR i := 0 TO (L - 1) DO BEGIN IF (GetDataArrayValue, ArrayIN, i) = 1) THEN BEGIN msVal := 1; BREAK; END;END;SetValue(msdwn, msVal);
]]>
I took the bad habit to make only global variable as i had often need of them in different process, but if it take only few kb
I wil try to better think "local" process when no interconnect.
it took me a while to undesrand what happened within blocs. I think started to catch when dealing with some mouse down arrays of some usine items, just to be sure ive well understood:
I first did:
if well remember, A was leading to pbs, cause within a bloc it would set msdwn to 1, but then to 0 if next element is 0, so
for i:= 0 to l-1 do begin
if getDataArrayValue(ArrayIN,i)=1 then begin
setValue(msdwn,1);
end else begin
setvalue(msdwn,0);
end;
end;
B)///////////////////////////////////////////////////////////////////
tot:= 0;
for i:= 0 to l-1 do begin
tot:= tot + getDataArrayValue(ArrayIN,i);
if getDataArrayValue(ArrayIN,i)=1 then begin
setValue(msdwn,1);
end
else if tot:= 0 then begin
setValue(msdwn,0);
end;
end;
///////////////////////////////////////////////////////////////////////////////
the parameter result bloc anyway would be 0, is that an exemple of the situation it if i well understood?
so is the B) tot method the best for such msdwn array?
]]>
One tip is to use local variables for procedures and functions when possible; it's considered good programming practice and you don't have to think about resetting (unless you're reusing within the same method, of course). Reusing global variables has the benefit of using less memory, but in a typical script some extra variables here and there may use a kB or two, so it doesn't really matter. The program often gets more readable and more often than not easier to maintain and expand on.
As you've probably have found out yourself, this isn't the case. Everything started within a block gets executed within that block. The only way to spread the execution of something over several blocks is to have some logic that takes care of when to do what, and it should be called from Process unless you have something outside of the script that triggers the executions through callbacks It can be timers (including counting blocks), some kind of incremental execution (if x=1 then doThis else if x=2 then doThat etc...), splitting a loop construct into smaller parts, etc.A typical example of the last one could be to do calculations on a 2-dimensional array, where you take all the elements of one of the dimensions within one block:VAR dim1 : Integer;VAR arr ARRAY[0..15, 0..15] OF Single;...PROCEDURE Callback(N : Integer);BEGIN // Some callback sets dim1 = 0;END;PROCEDURE Process; VAR dim2 : Integer;BEGIN IF (dim1 < 16) THEN BEGIN FOR dim2 := 0 TO 15 DO arr[dim1, dim2] := _something_; dim1 := dim1 + 1; END;END;
]]>
i had several procedures using same S:=S+ for the string, but i was'nt reseting S, so i guess it picked up previous huge list oops
cool, nothing linked to sub bloc or bloc or iml i guess, a beginner error hehe.
]]>
anyway the new system will be much easier, i suppose arg are considered as double quoted even if not...
for my multiple wires pb, i atlast got it fixed now like this:
mmm that mean i must have lot of scripts that must process several times instead on one...i usually don't wait end and update
Procedure WIRE_MSDWNARR;
BEGIN
for i:= 0 to nb_items -1 do begin
name:= 'cell'+IntToStr(i);
S:= S+'"'+'CREATE_LINK '+name+' '+''''+'mouse dwn'+''''+' MSDWNARR '+'INPUT'+intToStr(i)+'"'+',';
end;
if i= nb_items-1 then begin // moded
setStringValue(msg,S);
end;
END;
///////////////////////////////////////////////
just like first., subbloc/blocs/time events operations are still a bit obscure for me.
I thought that when using "for i to" it was making subbloc ops, then setting the tparameter would only be possible on next bloc,
isn't it? or on first exemple, the output could be set/updated within a bloc? if i check the message in module, it seems not, I only see lines once. I tried to copy the text and if sending via button wire correcly once..
arf im happy it work but would soo like to understand....
do ya make kind of same end i check wait to send results, ?
]]>
Statistics: Posted by 23fx23 — 02 Jun 2010, 22:55
///////////////////////////////////////////////
Procedure WIRE_MSDWNARR;
BEGIN
for i:= 0 to nb_items -1 do begin
name:= 'cell'+IntToStr(i);
S:= S+'"'+'CREATE_LINK '+name+' '+''''+'mouse dwn'+''''+' MSDWNARR '+'INPUT'+intToStr(i)+'"'+',';
setStringValue(msg,S);
end;
END;
///////////////////////////////////////////////Process proc
if vcount = 1 then begin
count:= count+1;
if count = 1 then Crea_Mod;
if count = WaitBlocs*4 then WIRE_MSDWNARR;
if count > WaitBlocs*8 then begin
count:=-1;
vcount:=0;
end;
end;
///////////////////////////////////////////////////
Statistics: Posted by 23fx23 — 02 Jun 2010, 22:46
Statistics: Posted by 23fx23 — 10 Jun 2010, 23:18
CODE:
VAR i, msVal : Integer;msVal := 0;FOR i := 0 TO (L - 1) DO BEGIN IF (GetDataArrayValue, ArrayIN, i) = 1) THEN BEGIN msVal := 1; BREAK; END;END;SetValue(msdwn, msVal);PS You got me a bit confused there - I thought the lower case L was and upper case I. How could that work?!?Statistics: Posted by bsork — 03 Jun 2010, 15:17
if well remember, A was leading to pbs, cause within a bloc it would set msdwn to 1, but then to 0 if next element is 0, soA)////////////////////////////////////////////////
for i:= 0 to l-1 do begin
if getDataArrayValue(ArrayIN,i)=1 then begin
setValue(msdwn,1);
end else begin
setvalue(msdwn,0);
end;
end;
B)///////////////////////////////////////////////////////////////////
tot:= 0;
for i:= 0 to l-1 do begin
tot:= tot + getDataArrayValue(ArrayIN,i);
if getDataArrayValue(ArrayIN,i)=1 then begin
setValue(msdwn,1);
end
else if tot:= 0 then begin
setValue(msdwn,0);
end;
end;
///////////////////////////////////////////////////////////////////////////////
Statistics: Posted by 23fx23 — 03 Jun 2010, 14:38
As you've probably have found out yourself, this isn't the case. Everything started within a block gets executed within that block. The only way to spread the execution of something over several blocks is to have some logic that takes care of when to do what, and it should be called from Process unless you have something outside of the script that triggers the executions through callbacks It can be timers (including counting blocks), some kind of incremental execution (if x=1 then doThis else if x=2 then doThat etc...), splitting a loop construct into smaller parts, etc.A typical example of the last one could be to do calculations on a 2-dimensional array, where you take all the elements of one of the dimensions within one block:I thought that when using "for i to" it was making subbloc ops...
CODE:
VAR dim1 : Integer;VAR arr ARRAY[0..15, 0..15] OF Single;...PROCEDURE Callback(N : Integer);BEGIN // Some callback sets dim1 = 0;END;PROCEDURE Process; VAR dim2 : Integer;BEGIN IF (dim1 < 16) THEN BEGIN FOR dim2 := 0 TO 15 DO arr[dim1, dim2] := _something_; dim1 := dim1 + 1; END;END;Statistics: Posted by bsork — 03 Jun 2010, 09:06
Statistics: Posted by 23fx23 — 03 Jun 2010, 04:19
mmm that mean i must have lot of scripts that must process several times instead on one...i usually don't wait end and update///////////////////////////////////////////////
Procedure WIRE_MSDWNARR;
BEGIN
for i:= 0 to nb_items -1 do begin
name:= 'cell'+IntToStr(i);
S:= S+'"'+'CREATE_LINK '+name+' '+''''+'mouse dwn'+''''+' MSDWNARR '+'INPUT'+intToStr(i)+'"'+',';
end;
if i= nb_items-1 then begin // moded
setStringValue(msg,S);
end;
END;
///////////////////////////////////////////////
Statistics: Posted by 23fx23 — 02 Jun 2010, 23:25
Statistics: Posted by 23fx23 — 02 Jun 2010, 22:55
///////////////////////////////////////////////
Procedure WIRE_MSDWNARR;
BEGIN
for i:= 0 to nb_items -1 do begin
name:= 'cell'+IntToStr(i);
S:= S+'"'+'CREATE_LINK '+name+' '+''''+'mouse dwn'+''''+' MSDWNARR '+'INPUT'+intToStr(i)+'"'+',';
setStringValue(msg,S);
end;
END;
///////////////////////////////////////////////Process proc
if vcount = 1 then begin
count:= count+1;
if count = 1 then Crea_Mod;
if count = WaitBlocs*4 then WIRE_MSDWNARR;
if count > WaitBlocs*8 then begin
count:=-1;
vcount:=0;
end;
end;
///////////////////////////////////////////////////
Statistics: Posted by 23fx23 — 02 Jun 2010, 22:46