[Dashboard\Dodge\Caliber\Caliber 9S12DG256 Km]

Size(280,320); 

Form
{
    Group("Пробег",15,10,140,50)
    {
        Digit(Distance," ",5,18,90);
        Label(lb1,"Km",110,20);
    }
    Picture(Picture1,"Dodge.bmp",180,5,0,0);
    Group("Идентифткация",5,80,270,45)
    {
        Label(vin," ",0,18);
    }
    Group("Информация",5,130,270,45)
    {
        Label(message," ",0,18);
    }
    Group("Описание",5,180,270,85) 
    {
        Label(lb4,"Калькулятор пробега для Dodge Caliber.",0,20);
        Label(lb5,"9S12DG256 internal EEPROM",0,35);
        Label(lb2,"Введите нужное значение в окне ПРОБЕГ",0,50);
        Label(lb3,"и нажмите кнопку <Применить>.",0,65);
    }
}

OnShow 
{
    Message.Bold = 1;  
    Var0 = 0; 	
    if(@0x51c = 0xFF) 	{ Var0 = Var0 + 1;}	
    if(Var0 != 0)
    {
        message.Color = 0x0000FF; 	
        Message = "Неверный дамп!";     
        Distance = 0;                   
    }
    else
    {
      Var1 = 0xf70; Var2 = 0; Var3 = 0; Var4 = 0; Var5 = 0;
      while(Var1 != 0xff0)
       {
        Var2 = @Var1; Var1 = Var1 + 1;
        Var3 = @Var1; Var4 = (Var2 << 8)|Var3;
        if(Var4 > Var5) {Var5 = Var4;}
        Var1 = Var1 + 3;
       }
        message.Color = 0xFF0000;                    
        message = "Дамп ОК. Введите новый пробег.";  
        Distance =  Var5 * 42;                            
    }
  vin.Bold =1;
  vin="VIN: "+#c.@0x51c+#c.@0x51d+#c.@0x51e+#c.@0x51f+#c.@0x520+#c.@0x521+#c.@0x522+#c.@0x523+#c.@0x524+
      #c.@0x525+#c.@0x526+#c.@0x527+#c.@0x528+#c.@0x529+#c.@0x52a+#c.@0x52b+#c.@0x52c; 
}


OnApply
{
    Var1 = Distance;     	


    Var0 = 0;  	

    if(Var1 > 999900)   { Var0 = Var0 + 1; }

    if(Var0 != 0)
    {
	

        message.Color = 0x0000FF;  	

        Message = "Пробег должен быть до 999900 км."; 
    }
    else
    {
        Var0 = Distance / 42;
	Var1 = 0xfed;
        while(Var1 != 0xf6d)
        {
        @Var1 = Var0 & 0xFF; Var1 = Var1 - 1;
        @Var1 = (Var0 >> 8) & 0xFF; Var1 = Var1 - 3;
         if(Var0 != 0) {Var0 = Var0 - 1;}
         else {Var0 = 0;}
        }
        
        message.Color = 0xFF0000;    
        message = "Новый пробег записан. Дамп ОК.";
    }
}
