FUNCTION "FC_TeleSetData" : Bool
{ S7_Optimized_Access := 'TRUE' }
VERSION : 0.1
   VAR_INPUT 
      nDataField : UDInt;   // The number of the data field to be modified, starts with "1".
      sData : String;   // The string that overwrites the existing data field value.
   END_VAR

   VAR_IN_OUT 
      stInOutTelegram : "UDT_TelegramData_Send";   // The telegram structure that contains the data field to be modified.
   END_VAR


BEGIN
	IF (#nDataField >= 1 AND UDINT_TO_DINT(#nDataField) <= "TELEGRAM_DATA_MAX") THEN
	    #stInOutTelegram.arDataString[#nDataField] := #sData; 
	    
	    IF (#stInOutTelegram.nDataCount < UDINT_TO_DINT(#nDataField)) THEN
	        #stInOutTelegram.nDataCount := UDINT_TO_DINT(#nDataField);
	    END_IF;
	    
	    #FC_TeleSetData := TRUE;
	ELSE
	    #FC_TeleSetData := FALSE;
	END_IF;
END_FUNCTION

