FUNCTION "FC_Uint2TroString" : String
{ S7_Optimized_Access := 'TRUE' }
VERSION : 0.1
   VAR_INPUT 
      nInNumber : UInt;
   END_VAR

   VAR_TEMP 
      sTmp : String[5];
   END_VAR


BEGIN
	// Funktion wandelt Uint zu einem Tro-String. Aus 123 wird 12.3, aus 0 wird 0.0 aus 12345 wird 1234.5
	// Autor: Christian Forkl
	// Getestet: Ja
	// 03.08.2021
	
	#sTmp := RIGHT(IN := UINT_TO_STRING(#nInNumber), L := (LEN(UINT_TO_STRING(#nInNumber)) - 1));
	
	#FC_Uint2TroString := '';
	
	 IF #nInNumber > 9999 THEN
	    #FC_Uint2TroString[1] := #sTmp[1];
	    #FC_Uint2TroString[2] := #sTmp[2];
	    #FC_Uint2TroString[3] := #sTmp[3];
	    #FC_Uint2TroString[4] := #sTmp[4];
	    #FC_Uint2TroString[5] := '.';
	    #FC_Uint2TroString[6] := #sTmp[5];
	ELSIF #nInNumber > 999 THEN
	    #FC_Uint2TroString[1] := #sTmp[1];
	    #FC_Uint2TroString[2] := #sTmp[2];
	    #FC_Uint2TroString[3] := #sTmp[3];
	    #FC_Uint2TroString[4] := '.';
	    #FC_Uint2TroString[5] := #sTmp[4];
	ELSIF #nInNumber > 99 THEN
	    #FC_Uint2TroString[1] := #sTmp[1];
	    #FC_Uint2TroString[2] := #sTmp[2];
	    #FC_Uint2TroString[3] := '.';
	    #FC_Uint2TroString[4] := #sTmp[3];
	ELSIF #nInNumber > 9 THEN
	    #FC_Uint2TroString[1] := #sTmp[1];
	    #FC_Uint2TroString[2] := '.';
	    #FC_Uint2TroString[3] := #sTmp[2];
	ELSIF #nInNumber > 0 THEN
	    #FC_Uint2TroString[1] := '0';
	    #FC_Uint2TroString[2] := '.';
	    #FC_Uint2TroString[3] := #sTmp[1];
	ELSE
	    #FC_Uint2TroString := '0.0';
	END_IF;
END_FUNCTION

