FUNCTION "TEST_DB_TO_ATTR_DB" : Void
{ S7_Optimized_Access := 'TRUE' }
VERSION : 0.1
   VAR_INPUT 
      DB_Number : Word;
   END_VAR

   VAR_OUTPUT 
      RetVal : Int;
      DB_Length : Word;
      Write_Prot : Bool;
   END_VAR

   VAR_TEMP 
      tDB_Number : DB_ANY;
      tDB_Lenght : UDInt;
      REQ : Bool;
      ATTRIB : Byte;
   END_VAR


BEGIN
	#tDB_Number := UINT_TO_DB_ANY(WORD_TO_UINT(#DB_Number));
	
	#RetVal := ATTR_DB(REQ := TRUE,
	        DB_NUMBER := #tDB_Number,
	        DB_LENGTH => #tDB_Lenght,
	        ATTRIB => #ATTRIB);
	
	#DB_Length := UDINT_TO_WORD(#tDB_Lenght);
	
	IF #ATTRIB.%X1 THEN
	    #Write_Prot := TRUE;
	END_IF;
	
	
	    
	
	
END_FUNCTION

