[Immo\Convertor\MasterKey to Kmrw 2]
!Конвертор транспондера MasterKey, 
!в буфер калькулятора вводим данные MasterKey 
!и получаем данные в формате Kmrw, размером 8 байт
!или получаем данные в формате Kmrw, размером 16 
!байт
!
!Оптимизированная версия
!
!Autor: telik@ukrwest.net  2008 
!
!

Size(300,370); // ширина и высота

Form
{
    	Group("Данные MasterKey",5,5,290,75) 
    		{
		HexDigit(A1," ",55,20,25,2);
		HexDigit(A2," ",75,20,25,2);
		HexDigit(A3," ",95,20,25,2);
		HexDigit(A4," ",115,20,25,2);
		HexDigit(A5," ",135,20,25,2);
		HexDigit(A6," ",155,20,25,2);
		HexDigit(A7," ",175,20,25,2);
		HexDigit(A8," ",195,20,25,2);
		HexDigit(B1," ",55,45,25,2);
		HexDigit(B2," ",75,45,25,2);
		HexDigit(B3," ",95,45,25,2);
		HexDigit(B4," ",115,45,25,2);
		HexDigit(B5," ",135,45,25,2);
		HexDigit(B6," ",155,45,25,2);
		HexDigit(B7," ",175,45,25,2);
		HexDigit(B8," ",195,45,25,2);
        	}
    	Group("Описание",5,80,290,120) 
    		{
        	Label(lb4,"Конвертор транспондера MasterKey ",0,17);
        	Label(lb5,"конвертирует данные MasterKey для Kmrw",0,32);
        	Label(lb6,"размером 8 байт или",0,47);
        	Label(lb7,"размером 16 байт",0,62);
		Label(msg," ",0,80);
		Label(msg1," ",0,95);
    		}
	Group("Информация",5,200,290,45)
    		{
        Label(message," ",0,20);
    		}
	Group("Kmrw - 16 байт ",5,250,290,75)
    		{
		HexDigit(C1," ",55,20,25,2);
		HexDigit(C2," ",75,20,25,2);
		HexDigit(C3," ",95,20,25,2);
		HexDigit(C4," ",115,20,25,2);
		HexDigit(C5," ",135,20,25,2);
		HexDigit(C6," ",155,20,25,2);
		HexDigit(C7," ",175,20,25,2);
		HexDigit(C8," ",195,20,25,2);
		HexDigit(D1," ",55,45,25,2);
		HexDigit(D2," ",75,45,25,2);
		HexDigit(D3," ",95,45,25,2);
		HexDigit(D4," ",115,45,25,2);
		HexDigit(D5," ",135,45,25,2);
		HexDigit(D6," ",155,45,25,2);
		HexDigit(D7," ",175,45,25,2);
		HexDigit(D8," ",195,45,25,2);
    		}
}

var ByteIn,ByteOut,Counter,Mask;

SwapBits
{
	mask = 0x80;
	ByteOut = 0;
	Counter = 0;
	while(Counter != 8)
	{
		if((ByteIn & 0x01) != 0)
		{
			ByteOut = ByteOut | Mask;
		}
		ByteIn = ByteIn >> 1;
		Mask = Mask >> 1;
		Counter = counter + 1;
	}
}

OnShow 
{
	msg.Color = 0xFF0000;				
        msg.Bold = 1;					
	msg = "Введите данные MasterKey";		
	msg1.Color = 0xFF0000;				
        msg1.Bold = 1;					
	msg1 = "и нажмите кнопку <Применить>";		

	a1=0; a2=0; a3=0; a4=0; a5=0; a6=0; a7=0; a8=0;	
	b1=0; b2=0; b3=0; b4=0; b5=0; b6=0; b7=0; b8=0;
	c1=0; c2=0; c3=0; c4=0; c5=0; c6=0; c7=0; c8=0;	
	d1=0; d2=0; d3=0; d4=0; d5=0; d6=0; d7=0; d8=0;	
}

OnApply
{	
	ByteIn = a1; SwapBits; c1 = ByteOut;
	ByteIn = a2; SwapBits; c2 = ByteOut;
	ByteIn = a3; SwapBits; c3 = ByteOut;
	ByteIn = a4; SwapBits; c4 = ByteOut;
	ByteIn = a5; SwapBits; c5 = ByteOut;
	ByteIn = a6; SwapBits; c6 = ByteOut;
	ByteIn = a7; SwapBits; c7 = ByteOut;
	ByteIn = a8; SwapBits; c8 = ByteOut;
	ByteIn = b1; SwapBits; d1 = ByteOut;
	ByteIn = b2; SwapBits; d2 = ByteOut;
	ByteIn = b3; SwapBits; d3 = ByteOut;
	ByteIn = b4; SwapBits; d4 = ByteOut;
	ByteIn = b5; SwapBits; d5 = ByteOut;
	ByteIn = b6; SwapBits; d6 = ByteOut;
	ByteIn = b7; SwapBits; d7 = ByteOut;
	ByteIn = b8; SwapBits; d8 = ByteOut;


	message.Color=0x0000FF; message.Bold=1; 
	//var20=0; while(var20!=101){message="Конвертирование: "+#i.Var20+"%"; var21=0; while(var21!=500){var21=var21+1;} var20=var20+1;}
	message.Color=0xFF0000; message.Bold=1; message = "Переконвертировано в формат Kmrw.";	

}

