11/25/2014 9:42 AM | |
Posts: 8 Rating:
|
Do anyone know if there is a function for the size of an array in TIA Portal V12? |
Last edited by: Min_Moderator at: 11/25/2014 9:45 AMSplitted |
|
11/25/2014 10:50 AM | |
Joined: 1/28/2009 Last visit: 4/20/2025 Posts: 6867 Rating:
|
Hello gdijke, As far as I know, there is no function or instruction to measure the length of an array without knowing the index and data type(at least for S7-300/400).If it is really critical to get such information, save an array inside a DB and check the instructions that measure the length of a DB like DBLG/DILG for S7-300/400.
I hope this helps, Hamid Hosseini |
11/25/2014 11:42 AM | |
Joined: 12/16/2012 Last visit: 4/9/2025 Posts: 655 Rating:
|
In the case of S7-1200 one solution to check the DB size could be: put a PEEK inside a FOR loop and use GET_ERR_ID() (solution from huggy_d1): FOR #byte_counter := 0 TO 10000 DO #peek_retval := PEEK(area:=16#84, // peek into bytes in DB dbNumber:=#DB_nr, byteOffset:=#byte_counter); #errorID := GET_ERR_ID(); // if boundary of DB is reached #errorID will become non-zero IF #errorID = 0 THEN // if not at the end of DB, increment byte counter #byte_counter := #byte_counter + 1; ELSE #DB_size := (#byte_counter); EXIT; END_IF; END_FOR; One should acctualy check the errorID not just use ELSE! The ID should be 2522 hex when DB boundary is detected. |
This contribution was helpful to
1 thankful Users |
11/25/2014 11:59 AM | |
Joined: 1/28/2009 Last visit: 4/20/2025 Posts: 6867 Rating:
|
Hello again, Arrays can not be created with a dynamic length in run-time .This is the limitation comes from the S7-Controllers.This is discussed in details in the forum:
how to creat array Good Luck from hdhosseini |
Follow us on