0

I am trying to convert some lines of code from siemens scl to twincat 3, I find myself in difficulty on some things that I explain below:

This the code that I was to understand:

VAR_INPUT
  in_00 : BOOL ;
  in_00_b AT in_00 : ARRAY[0..0] OF BOOL;   
  in_01 : BOOL ;   
  in_02 : BOOL ;   
  in_03 : BOOL ;   
  in_04 : BOOL ;   
  in_05 : BOOL ;   
  in_06 : BOOL ;   
  in_07 : BOOL ;   
  in_08 : BOOL ;   
  in_09 : BOOL ;   
  in_10 : BOOL ;   
END_VAR

VAR_OUTPUT
  out_00 : BOOL ; 
  out_00_b AT out_00 : ARRAY[0..0] OF BOOL;   
  out_01 : BOOL ;   
  out_02 : BOOL ;   
  out_03 : BOOL ;   
  out_04 : BOOL ;   
  out_05 : BOOL ;   
  out_06 : BOOL ;   
  out_07 : BOOL ;   
  out_08 : BOOL ;   
  out_09 : BOOL ;   
  out_10 : BOOL ;   
END_VAR

VAR_TEMP
  i : INT; 
END_VAR

    FOR i:=0 TO 10 BY 1 DO       
        out_00_b[i]:=in_00_b[i];         
    END_FOR;

How i can declare this array at the same address like example?

Thanks in advance.

SHKODRAN
  • 15
  • 1
  • 8
  • Hardcoding a memory address is rare in TwinCAT programming. The `AT` keyword is usually only used for mapping variables to IO. Can you provide some more detail about why you want the array at the same address? – Seth Jul 09 '19 at 08:04

1 Answers1

0

I think you could do the following. Because i think that you're not correctly declaring you arrays, so the code should look like this:

And actually you could copy all the array at once, not just element by element.

VAR_INPUT
  in_00 : BOOL ;
  in_00_b AT %I* : ARRAY[0..10] OF BOOL;   
  in_01 : BOOL ;   
  in_02 : BOOL ;   
  in_03 : BOOL ;   
  in_04 : BOOL ;   
  in_05 : BOOL ;   
  in_06 : BOOL ;   
  in_07 : BOOL ;   
  in_08 : BOOL ;   
  in_09 : BOOL ;   
  in_10 : BOOL ;   
END_VAR

VAR_OUTPUT
  out_00 : BOOL ; 
  out_00_b AT %Q* : ARRAY[0..10] OF BOOL;   
  out_01 : BOOL ;   
  out_02 : BOOL ;   
  out_03 : BOOL ;   
  out_04 : BOOL ;   
  out_05 : BOOL ;   
  out_06 : BOOL ;   
  out_07 : BOOL ;   
  out_08 : BOOL ;   
  out_09 : BOOL ;   
  out_10 : BOOL ;   
END_VAR

VAR_TEMP
  i : INT; 
END_VAR

    FOR i:=0 TO 10 BY 1 DO       
        out_00_b[i]:=in_00_b[i];         
    END_FOR;
out_00_b = in_00_b; I think this is more efficient.