FUNCTION "FC_TeleAddDataField" : Bool
{ S7_Optimized_Access := 'TRUE' }
VERSION : 0.1
   VAR_INPUT 
      sData : String;   // The data field string to be added to the telegram structure.
   END_VAR

   VAR_IN_OUT 
      stInOutTelegram : "UDT_TelegramData_Send";   // The telegram structure the data field has to be added to.
   END_VAR


BEGIN
	IF (#stInOutTelegram.nDataCount < "TELEGRAM_DATA_MAX") THEN
	    IF (#stInOutTelegram.nDataCount < 0) THEN
	        #stInOutTelegram.nDataCount := 0;
	    END_IF;
	    
	    #stInOutTelegram.nDataCount := #stInOutTelegram.nDataCount + 1;
	    #stInOutTelegram.arDataString[#stInOutTelegram.nDataCount] := #sData;
	    
	    #FC_TeleAddDataField := TRUE;
	ELSE
	    #FC_TeleAddDataField := FALSE;
	END_IF;
END_FUNCTION

