Sign in to follow this  
Followers 0
saruans

array set zero

7 posts in this topic

Posted (edited)

Hello,
Maybe somebody know how make all array make zero. My array is DATAS: ARRAY[1..15, 1..6] OF INT;

 

I tried it

 

sustojimas.jpg.dee720eecd27e259d92f11b09

 

But it don't help me.

 

Edited by saruans

Share this post


Link to post
Share on other sites

Hi,

Maybe you could make a FB with a loop. Here is an example to reset an array of bool. You just need and index and a bool as the conditon of the reset.

5ad9b8339f3e6_BoucleRAZarrayofbool.png.6

JC

Share this post


Link to post
Share on other sites

I tried to use your advice and wrote FB with this code picture

arrays.jpg.fe1ec5a0f9cd0dd77484547fcfb87

I got error

arraysMistake.jpg.033fdaa5cb7bbd460180da

Could somebody  say to me how solve this problem?

Share this post


Link to post
Share on other sites

I am not familiar with this platform but ...

loop ranges do match array dimensions.

is this perhaps case sensitive? I see that array declaration starts with upper case...  and why is the purpose of IF statement? But more importantly, passing parameters seem to be wrong - you are declaring is as VAR_INPUT (ByValue) but for this to be useful, it must be declared as VAR_IN_OUT (ByReference).

example posted by acpi is using proper form...

clear_array.jpg

Share this post


Link to post
Share on other sites

Posted (edited)

I find my mistake. It was masyvas[y,i]=0; need to do masyvas[y,i]:=0; Now I want simplify the main code. My Fb block show now that:

arrays.jpg.7229ad27d79c909e86dc32eed2dfc

If I write that:

arraysMistake.jpg.52645f35403c3f53879ae9

code working well. when have Input is true, when reset array, but I want to do that:

arraysMistake.jpg.cd96afe8f4a28b7941e7ff

Now problem with top picture, that I have input kuku false, but I wrote something to array DATAS,  so immediately reset DATAS. Somebody have advice how solve this problem and update my FB code?

fb block text format:

IF Leidimas THEN
    Masyvas1:=Masyvas;
    FOR i:=1 TO 6 BY 1 DO
        FOR y:=1 TO 15 BY 1 DO
            IF(masyvas1[y,i]<>0) THEN        
                masyvas1[y,i]:=0;
            END_IF
        END_FOR
    END_FOR
reset:=Masyvas1;    
done:=TRUE;
    IF done THEN
    reset:=Masyvas1;    
    END_IF    
ELSE
    i:=1;
    y:=1;
    done:= FALSE;
END_IF

 

   

 

Edited by saruans

Share this post


Link to post
Share on other sites

that is because you did not use IN_OUT transfer as suggested

 

Must_use_ByRef.png

Share this post


Link to post
Share on other sites

Thanks to you. It is that, what to need for me.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0