8/3/2015 1:44 PM | |
Posts: 26 Rating: (2) |
Hello, I wrote the following code for reading an element in array (whose size is 15) specifing position of the element in array: FUNCTION Array_Read_Val_By_Index : VOID TITLE = 'Read in array a value specified by index' VAR_INPUT Array_In : ARRAY[1..15] OF INT; //Input Array Index : INT; //Index of the element that is to be readed END_VAR VAR_OUTPUT V_Out : INT; //Value of readed element Error : BOOL; //Error if index exceedes the lenght of array END_VAR //Begin V_Out := 0; Error := False; IF (Index > 0 ) AND (Index <= 15) THEN V_Out := Array_In[Index]; ELSE Error := True; END_IF;
END_FUNCTION I would like to make this function general so that it can accept as input parameter a variable size array. Input array can also be stored in a temp variable, not only in DB, so I think I can't use ANY data type because it needs DB number in STRUCT. To perform this solution, I was searching for the using of POINTER data type, but I couldn't find good examples. Can you help me, please? Thanks in advance. Best regards. ----------------------------------------------------------------------------------------------------
Split from Pass an array without size to a FB. (SCL). |
Last edited by: Min_Moderator at: 8/3/2015 2:38:51 PMNew subject after splitting |
|
8/3/2015 2:39 PM | |
Joined: 9/3/2014 Last visit: 3/13/2019 Posts: 4774 Rating: (123) |
|
Follow us on