import "XStdlib.dll"
// РАСЧЕТ ПО АВАНСОВЫМ ПЛАТЕЖАМ ПО СТРАХОВЫМ ВЗНОСАМ НА 
// ОБЯЗАТЕЛЬНОЕ ПЕНСИОННОЕ СТРАХОВАНИЕ

int FTrans_DL=1; // формат передачи файла на магнитный носитеть
                   // 0 - местный (Свердловская обл.)
                   // 1 - федеральный (определенный законодательством)

var CFile_DL;      // объект класса для работы с текущим файлом печати
int SizePage_DL;   // число строк на листе
int KindPaper_DL;  // тип бумаги (0-рулон; 1-лист)
int NL_DL=0;
int PT_DL;         


double S0104 = 0.0, S0124 = 0.0, S0134 = 0.0, S0144 = 0.0,
       S0105 = 0.0, S0125 = 0.0, S0135 = 0.0, S0145 = 0.0;

int EXCEL    =  0,
    IMNS     =  1, 
    PT       =  1,
    TYPORG   =  0,
    NL       =  0,
    FLIST    =  1,
    ORG      =  0,
    ADR      =  0,
    FlgTrans = -1,
    NomFile  =  1;

string DOP = "11111111",
       DRASCH = "",
       PathStr = "a:\\                                                     ",
       VarFOtch = "001";


AvansPF_DL(DOP, PT, TYPORG, NL, FLIST, DRASCH,
           S0104, S0124, S0134, S0144,
           S0105, S0125, S0135, S0145, ORG, ADR, EXCEL,
           IMNS, PathStr, FlgTrans, NomFile, VarFOtch);
{
  int np = 22;
  var param[np];

  param[0]  = static_cast_to_string(DOP);
  param[1]  = atoi(PT);
  param[2]  = atoi(TYPORG);
  param[3]  = atoi(NL);
  param[4]  = atoi(FLIST);
  param[5]  = static_cast_to_string(DRASCH);
  param[6]  = atof(S0104);
  param[7]  = atof(S0124);
  param[8]  = atof(S0134);
  param[9]  = atof(S0144);
  param[10] = atof(S0105);
  param[11] = atof(S0125);
  param[12] = atof(S0135);
  param[13] = atof(S0145);
  param[14] = atoi(ORG);
  param[15] = atoi(ADR);
  param[16] = atoi(EXCEL);
  param[17] = atoi(IMNS);
  param[18] = static_cast_to_string(PathStr);
  param[19] = atoi(FlgTrans);
  param[20] = atoi(NomFile);
  param[21] = static_cast_to_string(VarFOtch);

  return AvansPF_par(param,np);
}


ReadParam(&param,np)
{
  if ( np >  0 ) DOP      = static_cast_to_string(param[0]);
  if ( np >  1 ) PT       = atoi(param[1]);
  if ( np >  2 ) TYPORG   = atoi(param[2]);
  if ( np >  3 ) NL       = atoi(param[3]);
  if ( np >  4 ) FLIST    = atoi(param[4]);
  if ( np >  5 ) DRASCH   = static_cast_to_string(param[5]);
  if ( np >  6 ) S0104    = atof(param[6]);   
  if ( np >  7 ) S0124    = atof(param[7]);   
  if ( np >  8 ) S0134    = atof(param[8]);   
  if ( np >  9 ) S0144    = atof(param[9]);   
  if ( np > 10 ) S0105    = atof(param[10]);   
  if ( np > 11 ) S0125    = atof(param[11]);   
  if ( np > 12 ) S0135    = atof(param[12]);   
  if ( np > 13 ) S0145    = atof(param[13]);   
  if ( np > 14 ) ORG      = atoi(param[14]);
  if ( np > 15 ) ADR      = atoi(param[15]);
  if ( np > 16 ) EXCEL    = atoi(param[16]);   
  if ( np > 17 ) IMNS     = atoi(param[17]);    
  if ( np > 18 ) PathStr  = static_cast_to_string(param[18]);
  if ( np > 19 ) FlgTrans = atoi(param[19]);
  if ( np > 20 ) NomFile  = atoi(param[20]);
  if ( np > 21 ) VarFOtch = static_cast_to_string(param[21]);

  KorParam();

  return 0;
}


KorParam()
{
  if ( PT       < 0 ) PT       = 0; if ( PT       > 1 ) PT       = 1;
  if ( TYPORG   < 0 ) TYPORG   = 0; if ( TYPORG   > 1 ) TYPORG   = 1;
  if ( NL       < 0 ) NL       = 0; if ( NL       > 1 ) NL       = 1;
  if ( FLIST    < 0 ) FLIST    = 0; if ( FLIST    > 1 ) FLIST    = 1;
  if ( ORG      < 0 ) ORG      = 0; if ( ORG      > 3 ) ORG      = 3;
  if ( ADR      < 0 ) ADR      = 0; if ( ADR      > 1 ) ADR      = 1;
  if ( IMNS     < 0 ) IMNS     = 0; if ( IMNS     > 1 ) IMNS     = 1;

  return 0;
}


AvansPF_par(&param,np)
{
  ReadParam(param,np);

  NL_DL=NL;

  CFile_DL=CreateObject("CurPrnFile");

  if (EXCEL==1 || EXCEL==2) { CFile_DL.SetFlagBrowse(0); CFile_DL.SetFlag_Print(0); }

  PT_DL=PT;
  if (PT_DL==1 && EXCEL==0)
  {
    CFile_DL.SetKindPrint(1);   // сжатая
    CFile_DL.SetWidthPage(180); // число символов на строку
  }

  if (EXCEL==0) 
  {
    SizePage_DL =CFile_DL.GetSizePage();  // количество строк на странице 
    KindPaper_DL=CFile_DL.GetKindPaper(); // тип бумаги (0-рулон; 1-лист)
  }

  table();

  return 0;
}


table()
{
  int PRSUM=1;
  int MOVEMP=1;
  int SP600NULL=1;

  int TypOrg = TYPORG;
  int Flist  = FLIST;

  char str[500];
  char Arg[256];
  char Rez[256];

  // инициализация переменных
  double t0100_3=0.; double t0100_5=0.; double t0100_7=0.; double t0100_9=0.;
  double t0110_3=0.; double t0110_5=0.; double t0110_7=0.; double t0110_9=0.;
  double t0120_3=0.; double t0120_5=0.; double t0120_7=0.; double t0120_9=0.;
  double t0130_3=0.; double t0130_5=0.; double t0130_7=0.; double t0130_9=0.;
  double t0140_3=0.; double t0140_5=0.; double t0140_7=0.; double t0140_9=0.;
  double t0200_3=0.; double t0200_5=0.; double t0200_7=0.; double t0200_9=0.;
  double t0210_3=0.; double t0210_5=0.; double t0210_7=0.; double t0210_9=0.;
  double t0220_3=0.; double t0220_5=0.; double t0220_7=0.; double t0220_9=0.;
  double t0230_3=0.; double t0230_5=0.; double t0230_7=0.; double t0230_9=0.;
  double t0240_3=0.; double t0240_5=0.; double t0240_7=0.; double t0240_9=0.;
  double t0300_3=0.; double t0300_5=0.; double t0300_7=0.; double t0300_9=0.;
  double t0310_3=0.; double t0310_5=0.; double t0310_7=0.; double t0310_9=0.;
  double t0320_3=0.; double t0320_5=0.; double t0320_7=0.; double t0320_9=0.;
  double t0330_3=0.; double t0330_5=0.; double t0330_7=0.; double t0330_9=0.;
  double t0340_3=0.; double t0340_5=0.; double t0340_7=0.; double t0340_9=0.;
                     double t0400_5=0.; double t0400_7=0.; double t0400_9=0.;
                     double t0410_5=0.; double t0410_7=0.; double t0410_9=0.;
                     double t0420_5=0.; double t0420_7=0.; double t0420_9=0.;
                     double t0430_5=0.; double t0430_7=0.; double t0430_9=0.;
                     double t0440_5=0.; double t0440_7=0.; double t0440_9=0.;

  double R12=0.; double R1T5=0.; int S12=0;
  double R22=0.; double R2T5=0.; int S22=0;
  double R32=0.; double R3T5=0.;             
  double R42=0.; double R4T5=0.;           
  double R52=0.; double R5T5=0.; int S52=0;
  double R62=0.; double R6T5=0.;           
  double R72=0.; double R7T5=0.;           
  double R82=0.; double R8T5=0.; int S82=0;
  double R92=0.; double R9T5=0.;           
  double R02=0.; double R0T5=0.;           
  double RI2=0.; double RIT5=0.; int SI2=0;

  double R14=0.; double R1T71=0.; double R1T72=0.; int S14=0;
  double R24=0.; double R2T71=0.; double R2T72=0.; int S24=0;
  double R34=0.; double R3T71=0.; double R3T72=0.;             
  double R44=0.; double R4T71=0.; double R4T72=0.;           
  double R54=0.; double R5T71=0.; double R5T72=0.; int S54=0;
  double R64=0.; double R6T71=0.; double R6T72=0.;           
  double R74=0.; double R7T71=0.; double R7T72=0.;           
  double R84=0.; double R8T71=0.; double R8T72=0.; int S84=0;
  double R94=0.; double R9T71=0.; double R9T72=0.;           
  double R04=0.; double R0T71=0.; double R0T72=0.;           
  double RI4=0.; double RIT71=0.; double RIT72=0.; int SI4=0;

  double R16=0.; double R1T91=0.; double R1T92=0.; int S16=0;
  double R26=0.; double R2T91=0.; double R2T92=0.; int S26=0;
  double R36=0.; double R3T91=0.; double R3T92=0.;             
  double R46=0.; double R4T91=0.; double R4T92=0.;           
  double R56=0.; double R5T91=0.; double R5T92=0.; int S56=0;
  double R66=0.; double R6T91=0.; double R6T92=0.;           
  double R76=0.; double R7T91=0.; double R7T92=0.;           
  double R86=0.; double R8T91=0.; double R8T92=0.; int S86=0;
  double R96=0.; double R9T91=0.; double R9T92=0.;           
  double R06=0.; double R0T91=0.; double R0T92=0.;           
  double RI6=0.; double RIT91=0.; double RIT92=0.; int SI6=0;


  var CTabl=CreateObject("CurPrnTbl");

  int nper1=atoi(CTabl.TextS("BDAT",0));
  int kper1=atoi(CTabl.TextS("M1",0))+1;
  int dper1=kper1-nper1+1;

  int PrMes2=0;
  int PrMes1=0;
  int PrMes0=0;
  int EndInKv  =atoi(CTabl.TextS("ENDINKV",0));
  int EndOtnTek=atoi(CTabl.TextS("ENDOTNTEK",0));
  if ((kper1-2) <= EndOtnTek) PrMes2=1; // 1-й месяц квартала
  if ((kper1-1) <= EndOtnTek) PrMes1=1; // 2-й месяц квартала
  if ( kper1    <= EndOtnTek) PrMes0=1; // 3-й месяц квартала

//  sprintf(Arg,"7,%d", kper1); // абсолютный месяц конца периода
//  int kper1_abs=atoi(R_DATA_EX(Arg,Rez,10,0));
  int kper1_abs=atoi(CTabl.TextS("AEDAT",0));


  int RFLAG1=FindRegrFlag(kper1_abs-2);
  int RFLAG2=FindRegrFlag(kper1_abs-1);
  int RFLAG3=FindRegrFlag(kper1_abs);

  var MKper=CreateObject("KMonth");
  int kmes=atoi(R_Date("2",Rez,10,0));
  int kgod=atoi(R_Date("6",Rez,10,0));
  MKper.SetMonthYear(kmes,kgod);

  char ZaPeriod[20];
  sprintf(ZaPeriod,"%4d", kgod);

  char edat[20]; sprintf(edat,"%s",CTabl.TextS("EDAT",0));
  FreeSpaceString(edat,3,"");

  string MesPer1="";
  if (EXCEL==0) 
  {
    if (dper1==3) MesPer1="I квартал";
    if (dper1==6) MesPer1="полугодие";
    if (dper1==9) MesPer1="9 месяцев";
  }
  else
  {
    if (dper1==3) MesPer1="I ътрЁЄры";
    if (dper1==6) MesPer1="яюыєуюфшх";
    if (dper1==9) MesPer1="9 ьхё Ўхт";
  }

  int ERROR_CODE_RET=0;
  // int CalMesBegPer=atoi(R_Date("1",Rez,10,0));


//  sprintf(Arg,"0,%d", nper1);
  sprintf(Arg,"0,%d", atoi(CTabl.TextS("ABDAT",0)));
  int CalMesBegPer=atoi(R_DATA_EX(Arg,Rez,10,0));

  if (CalMesBegPer!=1)
  {
    if (EXCEL==0) {
      sprintf(str,"Месяцем начала периода должен быть январь"); prntPF_DL(str,1,0);
    }
    ERROR_CODE_RET=52;
    return ERROR_CODE_RET;
  }

//  int PERIOD_ERROR=1;
//  if (dper1==3 || dper1==6 || dper1==9 || dper1==12) PERIOD_ERROR=0;

//  if (PERIOD_ERROR==1)
//  {
//    if (EXCEL==0) {
//      sprintf(str,"Неправильно задан период. Период должен быть 3, 6, 9 или 12 месяцев"); prntPF_DL(str,1,0);
//    }
//    ERROR_CODE_RET=53;
//    return ERROR_CODE_RET;
//  }

  int TmpI;

  double Temp;
  double Temp1;
  double Temp2;
  double Temp3;

  int RFLAG=RFLAG3;
  double TEMP3=0;

  int CR=CTabl.Count_Rcr();  // число рабочих зaписей в таблице   

  // цикл по записям таблицы
  for (int zap=0; (CR-zap)>0; zap++)
  {
    Temp =0.;
    Temp1=0.;
    Temp2=0.;
    Temp3=0.;

    int KAT_ESN_PF=atoi(CTabl.TextS("KATESNPF",zap));

    if (KAT_ESN_PF==1)
    {

      Temp =atof(CTabl.TextS("0100",zap)); t0100_3+=Temp;
                                           t0100_9+=Temp;
      if (PrMes2==1)
      Temp1=atof(CTabl.TextS("0120",zap)); t0120_3+=Temp1;
                                           t0120_9+=Temp1;
      if (PrMes1==1)
      Temp2=atof(CTabl.TextS("0130",zap)); t0130_3+=Temp2;
                                           t0130_9+=Temp2;
      if (PrMes0==1)
      Temp3=atof(CTabl.TextS("0140",zap)); t0140_3+=Temp3;
                                           t0140_9+=Temp3;
                                           t0110_3+=(Temp1+Temp2+Temp3);
                                           t0110_9+=(Temp1+Temp2+Temp3);


      Temp =atof(CTabl.TextS("0300",zap)); t0300_3+=Temp;
                                           t0300_9+=Temp;
                                           t0200_3+=Temp;
                                           t0200_9+=Temp;
      if (PrMes2==1)
      Temp1=atof(CTabl.TextS("0320",zap)); t0320_3+=Temp1;
                                           t0320_9+=Temp1;
                                           t0220_3+=Temp1;
                                           t0220_9+=Temp1;
      if (PrMes1==1)
      Temp2=atof(CTabl.TextS("0330",zap)); t0330_3+=Temp2;
                                           t0330_9+=Temp2;
                                           t0230_3+=Temp2;
                                           t0230_9+=Temp2;
      if (PrMes0==1)
      Temp3=atof(CTabl.TextS("0340",zap)); t0340_3+=Temp3;
                                           t0340_9+=Temp3;
                                           t0240_3+=Temp3;
                                           t0240_9+=Temp3;
                                           t0310_3+=(Temp1+Temp2+Temp3);
                                           t0310_9+=(Temp1+Temp2+Temp3);
                                           t0210_3+=(Temp1+Temp2+Temp3);
                                           t0210_9+=(Temp1+Temp2+Temp3);
    } // END if KAT_ESN_PF==1

    if (KAT_ESN_PF==2)
    {

      Temp =atof(CTabl.TextS("0100",zap)); t0100_5+=Temp;
                                           t0100_9+=Temp;
      if (PrMes2==1)
      Temp1=atof(CTabl.TextS("0120",zap)); t0120_5+=Temp1;
                                           t0120_9+=Temp1;
      if (PrMes1==1)
      Temp2=atof(CTabl.TextS("0130",zap)); t0130_5+=Temp2;
                                           t0130_9+=Temp2;
      if (PrMes0==1)
      Temp3=atof(CTabl.TextS("0140",zap)); t0140_5+=Temp3;
                                           t0140_9+=Temp3;
                                           t0110_5+=(Temp1+Temp2+Temp3);
                                           t0110_9+=(Temp1+Temp2+Temp3);


      Temp =atof(CTabl.TextS("0300",zap)); t0300_5+=Temp;
                                           t0300_9+=Temp;
                                           t0200_5+=Temp;
                                           t0200_9+=Temp;
      if (PrMes2==1)
      Temp1=atof(CTabl.TextS("0320",zap)); t0320_5+=Temp1;
                                           t0320_9+=Temp1;
                                           t0220_5+=Temp1;
                                           t0220_9+=Temp1;
      if (PrMes1==1)
      Temp2=atof(CTabl.TextS("0330",zap)); t0330_5+=Temp2;
                                           t0330_9+=Temp2;
                                           t0230_5+=Temp2;
                                           t0230_9+=Temp2;
      if (PrMes0==1)
      Temp3=atof(CTabl.TextS("0340",zap)); t0340_5+=Temp3;
                                           t0340_9+=Temp3;
                                           t0240_5+=Temp3;
                                           t0240_9+=Temp3;
                                           t0310_5+=(Temp1+Temp2+Temp3);
                                           t0310_9+=(Temp1+Temp2+Temp3);
                                           t0210_5+=(Temp1+Temp2+Temp3);
                                           t0210_9+=(Temp1+Temp2+Temp3);


      Temp =atof(CTabl.TextS("0400",zap)); t0400_5+=Temp;
                                           t0400_9+=Temp;
                                           t0200_5+=Temp;
                                           t0200_9+=Temp;
      if (PrMes2==1)
      Temp1=atof(CTabl.TextS("0420",zap)); t0420_5+=Temp1;
                                           t0220_5+=Temp1;
                                           t0220_9+=Temp1;
                                           t0420_9+=Temp1;
      if (PrMes1==1)
      Temp2=atof(CTabl.TextS("0430",zap)); t0430_5+=Temp2;
                                           t0230_5+=Temp2;
                                           t0230_9+=Temp2;
                                           t0430_9+=Temp2;
      if (PrMes0==1)
      Temp3=atof(CTabl.TextS("0440",zap)); t0440_5+=Temp3;
                                           t0240_5+=Temp3;
                                           t0240_9+=Temp3;
                                           t0440_9+=Temp3;
                                           t0410_5+=(Temp1+Temp2+Temp3);
                                           t0410_9+=(Temp1+Temp2+Temp3);
                                           t0210_5+=(Temp1+Temp2+Temp3);
                                           t0210_9+=(Temp1+Temp2+Temp3);
    } // END if KAT_ESN_PF==2


    if (KAT_ESN_PF==3)
    {

      Temp =atof(CTabl.TextS("0100",zap)); t0100_7+=Temp;
                                           t0100_9+=Temp;
      if (PrMes2==1)
      Temp1=atof(CTabl.TextS("0120",zap)); t0120_7+=Temp1;
                                           t0120_9+=Temp1;
      if (PrMes1==1)
      Temp2=atof(CTabl.TextS("0130",zap)); t0130_7+=Temp2;
                                           t0130_9+=Temp2;
      if (PrMes0==1)
      Temp3=atof(CTabl.TextS("0140",zap)); t0140_7+=Temp3;
                                           t0140_9+=Temp3;
                                           t0110_7+=(Temp1+Temp2+Temp3);
                                           t0110_9+=(Temp1+Temp2+Temp3);


      Temp =atof(CTabl.TextS("0300",zap)); t0300_7+=Temp;
                                           t0300_9+=Temp;
                                           t0200_7+=Temp;
                                           t0200_9+=Temp;
      if (PrMes2==1)
      Temp1=atof(CTabl.TextS("0320",zap)); t0320_7+=Temp1;
                                           t0320_9+=Temp1;
                                           t0220_7+=Temp1;
                                           t0220_9+=Temp1;
      if (PrMes1==1)
      Temp2=atof(CTabl.TextS("0330",zap)); t0330_7+=Temp2;
                                           t0330_9+=Temp2;
                                           t0230_7+=Temp2;
                                           t0230_9+=Temp2;
      if (PrMes0==1)
      Temp3=atof(CTabl.TextS("0340",zap)); t0340_7+=Temp3;
                                           t0340_9+=Temp3;
                                           t0240_7+=Temp3;
                                           t0240_9+=Temp3;
                                           t0310_7+=(Temp1+Temp2+Temp3);
                                           t0310_9+=(Temp1+Temp2+Temp3);
                                           t0210_7+=(Temp1+Temp2+Temp3);
                                           t0210_9+=(Temp1+Temp2+Temp3);


      Temp =atof(CTabl.TextS("0400",zap)); t0400_7+=Temp;
                                           t0400_9+=Temp;
                                           t0200_7+=Temp;
                                           t0200_9+=Temp;
      if (PrMes2==1)
      Temp1=atof(CTabl.TextS("0420",zap)); t0420_7+=Temp1;
                                           t0220_7+=Temp1;
                                           t0220_9+=Temp1;
                                           t0420_9+=Temp1;
      if (PrMes1==1)
      Temp2=atof(CTabl.TextS("0430",zap)); t0430_7+=Temp2;
                                           t0230_7+=Temp2;
                                           t0230_9+=Temp2;
                                           t0430_9+=Temp2;
      if (PrMes0==1)
      Temp3=atof(CTabl.TextS("0440",zap)); t0440_7+=Temp3;
                                           t0240_7+=Temp3;
                                           t0240_9+=Temp3;
                                           t0440_9+=Temp3;
                                           t0410_7+=(Temp1+Temp2+Temp3);
                                           t0410_9+=(Temp1+Temp2+Temp3);
                                           t0210_7+=(Temp1+Temp2+Temp3);
                                           t0210_9+=(Temp1+Temp2+Temp3);
    } // END if KAT_ESN_PF==3

    TEMP3=0.;
    TEMP3=atof(CTabl.TextS("0100",zap));

    if(KAT_ESN_PF==1)
    {
      if((TEMP3)>0)
      {
        if( ((TEMP3-100000)<0) || ((RFLAG-2)==0) )
        {
          R12=R12+TEMP3;
          if (TypOrg==0) R1T5=R1T5+TEMP3*.14;  round(R1T5);
          if (TypOrg==1) R1T5=R1T5+TEMP3*.103; round(R1T5);
          S12=S12+1;
        }
        else
        {
          if( (TEMP3-300000)<0 )
          {
            R22=R22+TEMP3;
            S22=S22+1;
            R32=R32+100000;
            if (TypOrg==0) R3T5=R3T5+14000;
            if (TypOrg==1) R3T5=R3T5+10300;
            R42=R42+TEMP3-100000;
            R4T5=R4T5+(TEMP3-100000)*.079; round(R4T5);
          }
          else
          {
            if( (TEMP3-600000)<=0 )
            {
              R52=R52+TEMP3;
              S52=S52+1;
              R62=R62+300000;
              if (TypOrg==0) R6T5=R6T5+29800;
              if (TypOrg==1) R6T5=R6T5+26100;
              R72=R72+TEMP3-300000;
              R7T5=R7T5+(TEMP3-300000)*.0395; round(R7T5);
            }
            if( (TEMP3-600000)>0 )
            {
//              R82=R82+TEMP3;
              S82=S82+1;
//              R92=R92+600000;
              if (TypOrg==0) R9T5=R9T5+41650;
              if (TypOrg==1) R9T5=R9T5+37950;
//              R02=R02+TEMP3-600000;
              R02=R02+TEMP3;
              R0T5=R0T5+(TEMP3-600000)*0; round(R0T5);  
            }
          }
        }
      }
    }


    if(KAT_ESN_PF==2)
    {
      if((TEMP3)>0)
      {
        if( ((TEMP3-100000)<0) || ((RFLAG-2)==0) )
        {
          R14=R14+TEMP3;
          if (TypOrg==0) R1T71=R1T71+TEMP3*.12;  round(R1T71);
          if (TypOrg==0) R1T72=R1T72+TEMP3*.02;  round(R1T72);
          if (TypOrg==1) R1T71=R1T71+TEMP3*.083; round(R1T71);
          if (TypOrg==1) R1T72=R1T72+TEMP3*.02;  round(R1T72);
          S14=S14+1;
        }
        else
        {
          if( (TEMP3-300000)<0 )
          {
            R24=R24+TEMP3;
            S24=S24+1;
            R34=R34+100000;
            if (TypOrg==0) R3T71=R3T71+12000;
            if (TypOrg==0) R3T72=R3T72+ 2000;
            if (TypOrg==1) R3T71=R3T71+ 8300;
            if (TypOrg==1) R3T72=R3T72+ 2000;
            R44=R44+TEMP3-100000;
            R4T71=R4T71+(TEMP3-100000)*.068; round(R4T71);
            R4T72=R4T72+(TEMP3-100000)*.011; round(R4T72);
          }
          else
          {
            if( (TEMP3-600000)<=0 )
            {
              R54=R54+TEMP3;
              S54=S54+1;
              R64=R64+300000;
              if (TypOrg==0) R6T71=R6T71+25600;
              if (TypOrg==0) R6T72=R6T72+ 4200;
              if (TypOrg==1) R6T71=R6T71+21900;
              if (TypOrg==1) R6T72=R6T72+ 4200;
              R74=R74+TEMP3-300000;
              R7T71=R7T71+(TEMP3-300000)*.0339; round(R7T71);
              R7T72=R7T72+(TEMP3-300000)*.0056; round(R7T72);
            }
            else
            {
//              R84=R84+TEMP3;
              S84=S84+1;
//              R94=R94+600000;
              if (TypOrg==0) R9T71=R9T71+35770;
              if (TypOrg==0) R9T72=R9T72+ 5880;
              if (TypOrg==1) R9T71=R9T71+32070;
              if (TypOrg==1) R9T72=R9T72+ 5880;
//              R04=R04+TEMP3-600000;
              R04=R04+TEMP3;
              R0T71=R0T71+(TEMP3-600000)*0; round(R0T71);  
              R0T72=R0T72+(TEMP3-600000)*0; round(R0T72);  
            }
          }
        }
      }
    }


    if(KAT_ESN_PF==3)
    {
      if((TEMP3)>0)
      {
        if( ((TEMP3-100000)<0) || ((RFLAG-2)==0) )
        {
          R16=R16+TEMP3;
          if (TypOrg==0) R1T91=R1T91+TEMP3*.11;  round(R1T91);
          if (TypOrg==0) R1T92=R1T92+TEMP3*.03;  round(R1T92);
          if (TypOrg==1) R1T91=R1T91+TEMP3*.073; round(R1T91);
          if (TypOrg==1) R1T92=R1T92+TEMP3*.03;  round(R1T92);
          S16=S16+1;
        }
        else
        {
          if( (TEMP3-300000)<0 )
          {
            R26=R26+TEMP3;
            S26=S26+1;
            R36=R36+100000;
            if (TypOrg==0) R3T91=R3T91+11000;
            if (TypOrg==0) R3T92=R3T92+ 3000;
            if (TypOrg==1) R3T91=R3T91+ 7300;
            if (TypOrg==1) R3T92=R3T92+ 3000;
            R46=R46+TEMP3-100000;
            R4T91=R4T91+(TEMP3-100000)*.0621; round(R4T91);
            R4T92=R4T92+(TEMP3-100000)*.0169; round(R4T92);
          }
          else
          {
            if( (TEMP3-600000)<=0 )
            {
              R56=R56+TEMP3;
              S56=S56+1;
              R66=R66+300000;
              if (TypOrg==0) R6T91=R6T91+23420;
              if (TypOrg==0) R6T92=R6T92+ 6380;
              if (TypOrg==1) R6T91=R6T91+19720;
              if (TypOrg==1) R6T92=R6T92+ 6380;
              R76=R76+TEMP3-300000;
              R7T91=R7T91+(TEMP3-300000)*.031;  round(R7T91);
              R7T92=R7T92+(TEMP3-300000)*.0085; round(R7T92);
            }
            else
            {
//              R86=R86+TEMP3;
              S86=S86+1;
//              R96=R96+600000;
              if (TypOrg==0) R9T91=R9T91+32720;
              if (TypOrg==0) R9T92=R9T92+ 8930;
              if (TypOrg==1) R9T91=R9T91+29020;
              if (TypOrg==1) R9T92=R9T92+ 8930;
//              R06=R06+TEMP3-600000;
              R06=R06+TEMP3;
              R0T91=R0T91+(TEMP3-600000)*0; round(R0T91);  
              R0T92=R0T92+(TEMP3-600000)*0; round(R0T92);  
            }
          }
        }
      }
    }
  } // конец цикла по записям таблицы
  
    
  double eps=0.001;    
  char tmpstr[20];   sprintf(tmpstr,  "       -      ");
  char tmpstr5[20];  sprintf(tmpstr5, "  -  "         );
  char tmpstr13[20]; sprintf(tmpstr13,"      -      " );
  char tmpstr12[20]; sprintf(tmpstr12,"     -      "  );
  char tmpstr11[20]; sprintf(tmpstr11,"     -     "  );
  char tmpstr10[20]; sprintf(tmpstr10,"    -     "  );

  char YesStr[20]; sprintf(YesStr,"-----           ");
  char NoStr[20];  sprintf(NoStr, "      ----------");

  RI2=R12+R32+R42+R62+R72+R92+R02;
  RI4=R14+R34+R44+R64+R74+R94+R04;
  RI6=R16+R36+R46+R66+R76+R96+R06;

  R0T5=R0T5+R9T5;
  RIT5=R1T5+R3T5+R4T5+R6T5+R7T5+R0T5;

  R0T71=R0T71+R9T71;
  RIT71=R1T71+R3T71+R4T71+R6T71+R7T71+R0T71;
  R0T72=R0T72+R9T72;
  RIT72=R1T72+R3T72+R4T72+R6T72+R7T72+R0T72;

  R0T91=R0T91+R9T91;
  RIT91=R1T91+R3T91+R4T91+R6T91+R7T91+R0T91;
  R0T92=R0T92+R9T92;
  RIT92=R1T92+R3T92+R4T92+R6T92+R7T92+R0T92;

  SI2=S12+S22+S52+S82;
  SI4=S14+S24+S54+S84;
  SI6=S16+S26+S56+S86;

  if( (PRSUM)!=0 )
  {
    R2T5=R3T5+R4T5;
    R5T5=R6T5+R7T5;
    R8T5=R9T5+R0T5;

    R2T71=R3T71+R4T71;
    R5T71=R6T71+R7T71;
    R8T71=R9T71+R0T71;

    R2T72=R3T72+R4T72;
    R5T72=R6T72+R7T72;
    R8T72=R9T72+R0T72;

    R2T91=R3T91+R4T91;
    R5T91=R6T91+R7T91;
    R8T91=R9T91+R0T91;

    R2T92=R3T92+R4T92;
    R5T92=R6T92+R7T92;
    R8T92=R9T92+R0T92;
  }

  char P1T5[10];  if(TypOrg==0) sprintf(P1T5, " 14%% "); if(TypOrg==1) sprintf(P1T5, "10.3%%");
  char P3T5[10];  if(TypOrg==0) sprintf(P3T5, "14000");  if(TypOrg==1) sprintf(P3T5, "10300"); 
  char P4T5[10];  if(TypOrg==0) sprintf(P4T5, " 7.9%%"); if(TypOrg==1) sprintf(P4T5, " 7.9%%");
  char P6T5[10];  if(TypOrg==0) sprintf(P6T5, "29800");  if(TypOrg==1) sprintf(P6T5, "26100"); 
  char P7T5[10];  if(TypOrg==0) sprintf(P7T5, "3.95%%"); if(TypOrg==1) sprintf(P7T5, "3.95%%");
  char P0T5[10];  if(TypOrg==0) sprintf(P0T5, "41650");  if(TypOrg==1) sprintf(P0T5, "37950"); 

  char P1T71[10]; if(TypOrg==0) sprintf(P1T71," 12%% "); if(TypOrg==1) sprintf(P1T71," 8.3%%");
  char P3T71[10]; if(TypOrg==0) sprintf(P3T71,"12000");  if(TypOrg==1) sprintf(P3T71," 8300"); 
  char P4T71[10]; if(TypOrg==0) sprintf(P4T71," 6.8%%"); if(TypOrg==1) sprintf(P4T71," 6.8%%");
  char P6T71[10]; if(TypOrg==0) sprintf(P6T71,"25600");  if(TypOrg==1) sprintf(P6T71,"21900"); 
  char P7T71[10]; if(TypOrg==0) sprintf(P7T71,"3.39%%"); if(TypOrg==1) sprintf(P7T71,"3.39%%");
  char P0T71[10]; if(TypOrg==0) sprintf(P0T71,"35770");  if(TypOrg==1) sprintf(P0T71,"32070"); 

  char P1T72[10];               sprintf(P1T72,"  2%% "); 
  char P3T72[10];               sprintf(P3T72," 2000");  
  char P4T72[10];               sprintf(P4T72," 1.1%%"); 
  char P6T72[10];               sprintf(P6T72," 4200");  
  char P7T72[10];               sprintf(P7T72,"0.56%%"); 
  char P0T72[10];               sprintf(P0T72," 5880");  

  char P1T91[10]; if(TypOrg==0) sprintf(P1T91," 11%% "); if(TypOrg==1) sprintf(P1T91," 7.3%%");
  char P3T91[10]; if(TypOrg==0) sprintf(P3T91,"11000");  if(TypOrg==1) sprintf(P3T91," 7300"); 
  char P4T91[10]; if(TypOrg==0) sprintf(P4T91,"6.21%%"); if(TypOrg==1) sprintf(P4T91,"6.21%%");
  char P6T91[10]; if(TypOrg==0) sprintf(P6T91,"23420");  if(TypOrg==1) sprintf(P6T91,"19720"); 
  char P7T91[10]; if(TypOrg==0) sprintf(P7T91," 3.1%%"); if(TypOrg==1) sprintf(P7T91," 3.1%%");
  char P0T91[10]; if(TypOrg==0) sprintf(P0T91,"32720");  if(TypOrg==1) sprintf(P0T91,"29020"); 

  char P1T92[10];               sprintf(P1T92,"  3%% "); 
  char P3T92[10];               sprintf(P3T92," 3000");  
  char P4T92[10];               sprintf(P4T92,"1.69%%"); 
  char P6T92[10];               sprintf(P6T92," 6380");  
  char P7T92[10];               sprintf(P7T92,"0.85%%"); 
  char P0T92[10];               sprintf(P0T92," 8930");  


  // последний лист  ( II. РАСЧЕТ ДЛЯ ЗАПОЛНЕНИЯ СТРОК 0300 и 0400 )

  // последний лист графа 3 ( база для начисления страховых взносов по 1 категории )
  char s100_3[20]; Temp=R12; if (nabs(Temp)>eps) sprintf(s100_3,"%12.2f",Temp);  else  sprintf(s100_3,"%s",tmpstr12);
  char s200_3[20]; Temp=R22; if (nabs(Temp)>eps) sprintf(s200_3,"%12.2f",Temp);  else  sprintf(s200_3,"%s",tmpstr12);
  char s210_3[20]; Temp=R32; if (nabs(Temp)>eps) sprintf(s210_3,"%12.2f",Temp);  else  sprintf(s210_3,"%s",tmpstr12);
  char s220_3[20]; Temp=R42; if (nabs(Temp)>eps) sprintf(s220_3,"%12.2f",Temp);  else  sprintf(s220_3,"%s",tmpstr12);
  char s300_3[20]; Temp=R52; if (nabs(Temp)>eps) sprintf(s300_3,"%12.2f",Temp);  else  sprintf(s300_3,"%s",tmpstr12);
  char s310_3[20]; Temp=R62; if (nabs(Temp)>eps) sprintf(s310_3,"%12.2f",Temp);  else  sprintf(s310_3,"%s",tmpstr12);
  char s320_3[20]; Temp=R72; if (nabs(Temp)>eps) sprintf(s320_3,"%12.2f",Temp);  else  sprintf(s320_3,"%s",tmpstr12);
  char s400_3[20]; Temp=R02; if (nabs(Temp)>eps) sprintf(s400_3,"%12.2f",Temp);  else  sprintf(s400_3,"%s",tmpstr12);
  char s500_3[20]; Temp=RI2; if (nabs(Temp)>eps) sprintf(s500_3,"%12.2f",Temp);  else  sprintf(s500_3,"%s",tmpstr12);

  // последний лист графа 7 ( база для начисления страховых взносов по 2 категории )
  char s100_7[20]; Temp=R14; if (nabs(Temp)>eps) sprintf(s100_7,"%12.2f",Temp);  else  sprintf(s100_7,"%s",tmpstr12);
  char s200_7[20]; Temp=R24; if (nabs(Temp)>eps) sprintf(s200_7,"%12.2f",Temp);  else  sprintf(s200_7,"%s",tmpstr12);
  char s210_7[20]; Temp=R34; if (nabs(Temp)>eps) sprintf(s210_7,"%12.2f",Temp);  else  sprintf(s210_7,"%s",tmpstr12);
  char s220_7[20]; Temp=R44; if (nabs(Temp)>eps) sprintf(s220_7,"%12.2f",Temp);  else  sprintf(s220_7,"%s",tmpstr12);
  char s300_7[20]; Temp=R54; if (nabs(Temp)>eps) sprintf(s300_7,"%12.2f",Temp);  else  sprintf(s300_7,"%s",tmpstr12);
  char s310_7[20]; Temp=R64; if (nabs(Temp)>eps) sprintf(s310_7,"%12.2f",Temp);  else  sprintf(s310_7,"%s",tmpstr12);
  char s320_7[20]; Temp=R74; if (nabs(Temp)>eps) sprintf(s320_7,"%12.2f",Temp);  else  sprintf(s320_7,"%s",tmpstr12);
  char s400_7[20]; Temp=R04; if (nabs(Temp)>eps) sprintf(s400_7,"%12.2f",Temp);  else  sprintf(s400_7,"%s",tmpstr12);
  char s500_7[20]; Temp=RI4; if (nabs(Temp)>eps) sprintf(s500_7,"%12.2f",Temp);  else  sprintf(s500_7,"%s",tmpstr12);

  // последний лист графа 13 ( база для начисления страховых взносов по 3 категории )
  char s100_13[20]; Temp=R16; if (nabs(Temp)>eps) sprintf(s100_13,"%12.2f",Temp); else  sprintf(s100_13,"%s",tmpstr12);
  char s200_13[20]; Temp=R26; if (nabs(Temp)>eps) sprintf(s200_13,"%12.2f",Temp); else  sprintf(s200_13,"%s",tmpstr12);
  char s210_13[20]; Temp=R36; if (nabs(Temp)>eps) sprintf(s210_13,"%12.2f",Temp); else  sprintf(s210_13,"%s",tmpstr12);
  char s220_13[20]; Temp=R46; if (nabs(Temp)>eps) sprintf(s220_13,"%12.2f",Temp); else  sprintf(s220_13,"%s",tmpstr12);
  char s300_13[20]; Temp=R56; if (nabs(Temp)>eps) sprintf(s300_13,"%12.2f",Temp); else  sprintf(s300_13,"%s",tmpstr12);
  char s310_13[20]; Temp=R66; if (nabs(Temp)>eps) sprintf(s310_13,"%12.2f",Temp); else  sprintf(s310_13,"%s",tmpstr12);
  char s320_13[20]; Temp=R76; if (nabs(Temp)>eps) sprintf(s320_13,"%12.2f",Temp); else  sprintf(s320_13,"%s",tmpstr12);
  char s400_13[20]; Temp=R06; if (nabs(Temp)>eps) sprintf(s400_13,"%12.2f",Temp); else  sprintf(s400_13,"%s",tmpstr12);
  char s500_13[20]; Temp=RI6; if (nabs(Temp)>eps) sprintf(s500_13,"%12.2f",Temp); else  sprintf(s500_13,"%s",tmpstr12);
                    
  // последний лист графа 5 ( начислено взносов на страх. часть по 1 категории )
  char s100_5[20]; Temp=R1T5; if (nabs(Temp)>eps) sprintf(s100_5,"%11.2f",Temp); else  sprintf(s100_5,"%s",tmpstr11);
  char s200_5[20]; Temp=R2T5; if (nabs(Temp)>eps) sprintf(s200_5,"%11.2f",Temp); else  sprintf(s200_5,"%s",tmpstr11);
  char s210_5[20]; Temp=R3T5; if (nabs(Temp)>eps) sprintf(s210_5,"%11.2f",Temp); else  sprintf(s210_5,"%s",tmpstr11);
  char s220_5[20]; Temp=R4T5; if (nabs(Temp)>eps) sprintf(s220_5,"%11.2f",Temp); else  sprintf(s220_5,"%s",tmpstr11);
  char s300_5[20]; Temp=R5T5; if (nabs(Temp)>eps) sprintf(s300_5,"%11.2f",Temp); else  sprintf(s300_5,"%s",tmpstr11);
  char s310_5[20]; Temp=R6T5; if (nabs(Temp)>eps) sprintf(s310_5,"%11.2f",Temp); else  sprintf(s310_5,"%s",tmpstr11);
  char s320_5[20]; Temp=R7T5; if (nabs(Temp)>eps) sprintf(s320_5,"%11.2f",Temp); else  sprintf(s320_5,"%s",tmpstr11);
  char s400_5[20]; Temp=R0T5; if (nabs(Temp)>eps) sprintf(s400_5,"%11.2f",Temp); else  sprintf(s400_5,"%s",tmpstr11);
  char s500_5[20]; Temp=RIT5; if (nabs(Temp)>eps) sprintf(s500_5,"%11.2f",Temp); else  sprintf(s500_5,"%s",tmpstr11);

  // последний лист графа 9 ( начислено взносов на страх. часть по 2 категории )
  char s100_9[20]; Temp=R1T71; if (nabs(Temp)>eps) sprintf(s100_9,"%11.2f",Temp); else  sprintf(s100_9,"%s",tmpstr11);
  char s200_9[20]; Temp=R2T71; if (nabs(Temp)>eps) sprintf(s200_9,"%11.2f",Temp); else  sprintf(s200_9,"%s",tmpstr11);
  char s210_9[20]; Temp=R3T71; if (nabs(Temp)>eps) sprintf(s210_9,"%11.2f",Temp); else  sprintf(s210_9,"%s",tmpstr11);
  char s220_9[20]; Temp=R4T71; if (nabs(Temp)>eps) sprintf(s220_9,"%11.2f",Temp); else  sprintf(s220_9,"%s",tmpstr11);
  char s300_9[20]; Temp=R5T71; if (nabs(Temp)>eps) sprintf(s300_9,"%11.2f",Temp); else  sprintf(s300_9,"%s",tmpstr11);
  char s310_9[20]; Temp=R6T71; if (nabs(Temp)>eps) sprintf(s310_9,"%11.2f",Temp); else  sprintf(s310_9,"%s",tmpstr11);
  char s320_9[20]; Temp=R7T71; if (nabs(Temp)>eps) sprintf(s320_9,"%11.2f",Temp); else  sprintf(s320_9,"%s",tmpstr11);
  char s400_9[20]; Temp=R0T71; if (nabs(Temp)>eps) sprintf(s400_9,"%11.2f",Temp); else  sprintf(s400_9,"%s",tmpstr11);
  char s500_9[20]; Temp=RIT71; if (nabs(Temp)>eps) sprintf(s500_9,"%11.2f",Temp); else  sprintf(s500_9,"%s",tmpstr11);

  // последний лист графа 11 ( начислено взносов на накоп. часть по 2 категории )
  char s100_11[20]; Temp=R1T72; if (nabs(Temp)>eps) sprintf(s100_11,"%10.2f",Temp); else  sprintf(s100_11,"%s",tmpstr10);
  char s200_11[20]; Temp=R2T72; if (nabs(Temp)>eps) sprintf(s200_11,"%10.2f",Temp); else  sprintf(s200_11,"%s",tmpstr10);
  char s210_11[20]; Temp=R3T72; if (nabs(Temp)>eps) sprintf(s210_11,"%10.2f",Temp); else  sprintf(s210_11,"%s",tmpstr10);
  char s220_11[20]; Temp=R4T72; if (nabs(Temp)>eps) sprintf(s220_11,"%10.2f",Temp); else  sprintf(s220_11,"%s",tmpstr10);
  char s300_11[20]; Temp=R5T72; if (nabs(Temp)>eps) sprintf(s300_11,"%10.2f",Temp); else  sprintf(s300_11,"%s",tmpstr10);
  char s310_11[20]; Temp=R6T72; if (nabs(Temp)>eps) sprintf(s310_11,"%10.2f",Temp); else  sprintf(s310_11,"%s",tmpstr10);
  char s320_11[20]; Temp=R7T72; if (nabs(Temp)>eps) sprintf(s320_11,"%10.2f",Temp); else  sprintf(s320_11,"%s",tmpstr10);  
  char s400_11[20]; Temp=R0T72; if (nabs(Temp)>eps) sprintf(s400_11,"%10.2f",Temp); else  sprintf(s400_11,"%s",tmpstr10);
  char s500_11[20]; Temp=RIT72; if (nabs(Temp)>eps) sprintf(s500_11,"%10.2f",Temp); else  sprintf(s500_11,"%s",tmpstr10);

  // последний лист графа 15 ( начислено взносов на страх. часть по 3 категории )
  char s100_15[20]; Temp=R1T91; if (nabs(Temp)>eps) sprintf(s100_15,"%11.2f",Temp); else  sprintf(s100_15,"%s",tmpstr11);
  char s200_15[20]; Temp=R2T91; if (nabs(Temp)>eps) sprintf(s200_15,"%11.2f",Temp); else  sprintf(s200_15,"%s",tmpstr11);
  char s210_15[20]; Temp=R3T91; if (nabs(Temp)>eps) sprintf(s210_15,"%11.2f",Temp); else  sprintf(s210_15,"%s",tmpstr11);
  char s220_15[20]; Temp=R4T91; if (nabs(Temp)>eps) sprintf(s220_15,"%11.2f",Temp); else  sprintf(s220_15,"%s",tmpstr11);
  char s300_15[20]; Temp=R5T91; if (nabs(Temp)>eps) sprintf(s300_15,"%11.2f",Temp); else  sprintf(s300_15,"%s",tmpstr11);
  char s310_15[20]; Temp=R6T91; if (nabs(Temp)>eps) sprintf(s310_15,"%11.2f",Temp); else  sprintf(s310_15,"%s",tmpstr11);
  char s320_15[20]; Temp=R7T91; if (nabs(Temp)>eps) sprintf(s320_15,"%11.2f",Temp); else  sprintf(s320_15,"%s",tmpstr11);  
  char s400_15[20]; Temp=R0T91; if (nabs(Temp)>eps) sprintf(s400_15,"%11.2f",Temp); else  sprintf(s400_15,"%s",tmpstr11);
  char s500_15[20]; Temp=RIT91; if (nabs(Temp)>eps) sprintf(s500_15,"%11.2f",Temp); else  sprintf(s500_15,"%s",tmpstr11);

  // последний лист графа 17 ( начислено взносов на накоп. часть по 3 категории )
  char s100_17[20]; Temp=R1T92; if (nabs(Temp)>eps) sprintf(s100_17,"%10.2f",Temp); else  sprintf(s100_17,"%s",tmpstr10);
  char s200_17[20]; Temp=R2T92; if (nabs(Temp)>eps) sprintf(s200_17,"%10.2f",Temp); else  sprintf(s200_17,"%s",tmpstr10);
  char s210_17[20]; Temp=R3T92; if (nabs(Temp)>eps) sprintf(s210_17,"%10.2f",Temp); else  sprintf(s210_17,"%s",tmpstr10);
  char s220_17[20]; Temp=R4T92; if (nabs(Temp)>eps) sprintf(s220_17,"%10.2f",Temp); else  sprintf(s220_17,"%s",tmpstr10);
  char s300_17[20]; Temp=R5T92; if (nabs(Temp)>eps) sprintf(s300_17,"%10.2f",Temp); else  sprintf(s300_17,"%s",tmpstr10);
  char s310_17[20]; Temp=R6T92; if (nabs(Temp)>eps) sprintf(s310_17,"%10.2f",Temp); else  sprintf(s310_17,"%s",tmpstr10);
  char s320_17[20]; Temp=R7T92; if (nabs(Temp)>eps) sprintf(s320_17,"%10.2f",Temp); else  sprintf(s320_17,"%s",tmpstr10);  
  char s400_17[20]; Temp=R0T92; if (nabs(Temp)>eps) sprintf(s400_17,"%10.2f",Temp); else  sprintf(s400_17,"%s",tmpstr10);
  char s500_17[20]; Temp=RIT92; if (nabs(Temp)>eps) sprintf(s500_17,"%10.2f",Temp); else  sprintf(s500_17,"%s",tmpstr10);

  // последний лист графа 6 ( численность по 1 категории )
  char s100_6[20]; TmpI=S12; if (nabs(TmpI)>eps) sprintf(s100_6,"%5d",TmpI); else  sprintf(s100_6,"%s",tmpstr5);
  char s200_6[20]; TmpI=S22; if (nabs(TmpI)>eps) sprintf(s200_6,"%5d",TmpI); else  sprintf(s200_6,"%s",tmpstr5);
  char s300_6[20]; TmpI=S52; if (nabs(TmpI)>eps) sprintf(s300_6,"%5d",TmpI); else  sprintf(s300_6,"%s",tmpstr5);
  char s400_6[20]; TmpI=S82; if (nabs(TmpI)>eps) sprintf(s400_6,"%5d",TmpI); else  sprintf(s400_6,"%s",tmpstr5);
  char s500_6[20]; TmpI=SI2; if (nabs(TmpI)>eps) sprintf(s500_6,"%5d",TmpI); else  sprintf(s500_6,"%s",tmpstr5);

  // последний лист графа 6 ( численность по 1 категории )
  char s100_12[20]; TmpI=S14; if (nabs(TmpI)>eps) sprintf(s100_12,"%5d",TmpI); else  sprintf(s100_12,"%s",tmpstr5);
  char s200_12[20]; TmpI=S24; if (nabs(TmpI)>eps) sprintf(s200_12,"%5d",TmpI); else  sprintf(s200_12,"%s",tmpstr5);
  char s300_12[20]; TmpI=S54; if (nabs(TmpI)>eps) sprintf(s300_12,"%5d",TmpI); else  sprintf(s300_12,"%s",tmpstr5);
  char s400_12[20]; TmpI=S84; if (nabs(TmpI)>eps) sprintf(s400_12,"%5d",TmpI); else  sprintf(s400_12,"%s",tmpstr5);
  char s500_12[20]; TmpI=SI4; if (nabs(TmpI)>eps) sprintf(s500_12,"%5d",TmpI); else  sprintf(s500_12,"%s",tmpstr5);

  // последний лист графа 6 ( численность по 1 категории )
  char s100_18[20]; TmpI=S16; if (nabs(TmpI)>eps) sprintf(s100_18,"%5d",TmpI); else  sprintf(s100_18,"%s",tmpstr5);
  char s200_18[20]; TmpI=S26; if (nabs(TmpI)>eps) sprintf(s200_18,"%5d",TmpI); else  sprintf(s200_18,"%s",tmpstr5);
  char s300_18[20]; TmpI=S56; if (nabs(TmpI)>eps) sprintf(s300_18,"%5d",TmpI); else  sprintf(s300_18,"%s",tmpstr5);
  char s400_18[20]; TmpI=S86; if (nabs(TmpI)>eps) sprintf(s400_18,"%5d",TmpI); else  sprintf(s400_18,"%s",tmpstr5);
  char s500_18[20]; TmpI=SI6; if (nabs(TmpI)>eps) sprintf(s500_18,"%5d",TmpI); else  sprintf(s500_18,"%s",tmpstr5);


  // Лист 5 строка 0100 ( база для начисления страховых взносов, всего )
  char s0100_3[20]; Temp=t0100_3; if (nabs(Temp)>eps) sprintf(s0100_3,"%14.2f",Temp); else  sprintf(s0100_3,"%s",tmpstr);
  char s0100_5[20]; Temp=t0100_5; if (nabs(Temp)>eps) sprintf(s0100_5,"%14.2f",Temp); else  sprintf(s0100_5,"%s",tmpstr);
  char s0100_7[20]; Temp=t0100_7; if (nabs(Temp)>eps) sprintf(s0100_7,"%14.2f",Temp); else  sprintf(s0100_7,"%s",tmpstr);
  char s0100_9[20]; Temp=t0100_9; if (nabs(Temp)>eps) sprintf(s0100_9,"%14.2f",Temp); else  sprintf(s0100_9,"%s",tmpstr);

  // Лист 5 строка 0110 ( база для начисления страховых взносов, за квартал )
  char s0110_3[20]; Temp=t0110_3; if (nabs(Temp)>eps) sprintf(s0110_3,"%14.2f",Temp); else  sprintf(s0110_3,"%s",tmpstr);
  char s0110_5[20]; Temp=t0110_5; if (nabs(Temp)>eps) sprintf(s0110_5,"%14.2f",Temp); else  sprintf(s0110_5,"%s",tmpstr);
  char s0110_7[20]; Temp=t0110_7; if (nabs(Temp)>eps) sprintf(s0110_7,"%14.2f",Temp); else  sprintf(s0110_7,"%s",tmpstr);
  char s0110_9[20]; Temp=t0110_9; if (nabs(Temp)>eps) sprintf(s0110_9,"%14.2f",Temp); else  sprintf(s0110_9,"%s",tmpstr);

  // Лист 5 строка 0120 ( база для начисления страховых взносов, 1-й месяц )
  char s0120_3[20]; Temp=t0120_3; if (nabs(Temp)>eps) sprintf(s0120_3,"%14.2f",Temp); else  sprintf(s0120_3,"%s",tmpstr);
  char s0120_5[20]; Temp=t0120_5; if (nabs(Temp)>eps) sprintf(s0120_5,"%14.2f",Temp); else  sprintf(s0120_5,"%s",tmpstr);
  char s0120_7[20]; Temp=t0120_7; if (nabs(Temp)>eps) sprintf(s0120_7,"%14.2f",Temp); else  sprintf(s0120_7,"%s",tmpstr);
  char s0120_9[20]; Temp=t0120_9; if (nabs(Temp)>eps) sprintf(s0120_9,"%14.2f",Temp); else  sprintf(s0120_9,"%s",tmpstr);

  // Лист 5 строка 0130 ( база для начисления страховых взносов, 2-й месяц )       
  char s0130_3[20]; Temp=t0130_3; if (nabs(Temp)>eps) sprintf(s0130_3,"%14.2f",Temp); else  sprintf(s0130_3,"%s",tmpstr);
  char s0130_5[20]; Temp=t0130_5; if (nabs(Temp)>eps) sprintf(s0130_5,"%14.2f",Temp); else  sprintf(s0130_5,"%s",tmpstr);
  char s0130_7[20]; Temp=t0130_7; if (nabs(Temp)>eps) sprintf(s0130_7,"%14.2f",Temp); else  sprintf(s0130_7,"%s",tmpstr);
  char s0130_9[20]; Temp=t0130_9; if (nabs(Temp)>eps) sprintf(s0130_9,"%14.2f",Temp); else  sprintf(s0130_9,"%s",tmpstr);

  // Лист 5 строка 0140 ( база для начисления страховых взносов, 3-й месяц )
  char s0140_3[20]; Temp=t0140_3; if (nabs(Temp)>eps) sprintf(s0140_3,"%14.2f",Temp); else  sprintf(s0140_3,"%s",tmpstr);
  char s0140_5[20]; Temp=t0140_5; if (nabs(Temp)>eps) sprintf(s0140_5,"%14.2f",Temp); else  sprintf(s0140_5,"%s",tmpstr);
  char s0140_7[20]; Temp=t0140_7; if (nabs(Temp)>eps) sprintf(s0140_7,"%14.2f",Temp); else  sprintf(s0140_7,"%s",tmpstr);
  char s0140_9[20]; Temp=t0140_9; if (nabs(Temp)>eps) sprintf(s0140_9,"%14.2f",Temp); else  sprintf(s0140_9,"%s",tmpstr);

  // Лист 5 строка 0200 ( сумма начисленных страховых взносов, всего )
  char s0200_3[20]; Temp=t0200_3; if (nabs(Temp)>eps) sprintf(s0200_3,"%14.2f",Temp); else  sprintf(s0200_3,"%s",tmpstr);
  char s0200_5[20]; Temp=t0200_5; if (nabs(Temp)>eps) sprintf(s0200_5,"%14.2f",Temp); else  sprintf(s0200_5,"%s",tmpstr);
  char s0200_7[20]; Temp=t0200_7; if (nabs(Temp)>eps) sprintf(s0200_7,"%14.2f",Temp); else  sprintf(s0200_7,"%s",tmpstr);
  char s0200_9[20]; Temp=t0200_9; if (nabs(Temp)>eps) sprintf(s0200_9,"%14.2f",Temp); else  sprintf(s0200_9,"%s",tmpstr);

  // Лист 5 строка 0210 ( сумма начисленных страховых взносов, за квартал )
  char s0210_3[20]; Temp=t0210_3; if (nabs(Temp)>eps) sprintf(s0210_3,"%14.2f",Temp); else  sprintf(s0210_3,"%s",tmpstr);
  char s0210_5[20]; Temp=t0210_5; if (nabs(Temp)>eps) sprintf(s0210_5,"%14.2f",Temp); else  sprintf(s0210_5,"%s",tmpstr);
  char s0210_7[20]; Temp=t0210_7; if (nabs(Temp)>eps) sprintf(s0210_7,"%14.2f",Temp); else  sprintf(s0210_7,"%s",tmpstr);
  char s0210_9[20]; Temp=t0210_9; if (nabs(Temp)>eps) sprintf(s0210_9,"%14.2f",Temp); else  sprintf(s0210_9,"%s",tmpstr);

  // Лист 5 строка 0220 ( сумма начисленных страховых взносов, 1-й месяц )
  char s0220_3[20]; Temp=t0220_3; if (nabs(Temp)>eps) sprintf(s0220_3,"%14.2f",Temp); else  sprintf(s0220_3,"%s",tmpstr);
  char s0220_5[20]; Temp=t0220_5; if (nabs(Temp)>eps) sprintf(s0220_5,"%14.2f",Temp); else  sprintf(s0220_5,"%s",tmpstr);
  char s0220_7[20]; Temp=t0220_7; if (nabs(Temp)>eps) sprintf(s0220_7,"%14.2f",Temp); else  sprintf(s0220_7,"%s",tmpstr);
  char s0220_9[20]; Temp=t0220_9; if (nabs(Temp)>eps) sprintf(s0220_9,"%14.2f",Temp); else  sprintf(s0220_9,"%s",tmpstr);

  // Лист 5 строка 0230 ( сумма начисленных страховых взносов, 2-й месяц )
  char s0230_3[20]; Temp=t0230_3; if (nabs(Temp)>eps) sprintf(s0230_3,"%14.2f",Temp); else  sprintf(s0230_3,"%s",tmpstr);
  char s0230_5[20]; Temp=t0230_5; if (nabs(Temp)>eps) sprintf(s0230_5,"%14.2f",Temp); else  sprintf(s0230_5,"%s",tmpstr);
  char s0230_7[20]; Temp=t0230_7; if (nabs(Temp)>eps) sprintf(s0230_7,"%14.2f",Temp); else  sprintf(s0230_7,"%s",tmpstr);
  char s0230_9[20]; Temp=t0230_9; if (nabs(Temp)>eps) sprintf(s0230_9,"%14.2f",Temp); else  sprintf(s0230_9,"%s",tmpstr);

  // Лист 5 строка 0240 ( сумма начисленных страховых взносов, 3-й месяц )
  char s0240_3[20]; Temp=t0240_3; if (nabs(Temp)>eps) sprintf(s0240_3,"%14.2f",Temp); else  sprintf(s0240_3,"%s",tmpstr);
  char s0240_5[20]; Temp=t0240_5; if (nabs(Temp)>eps) sprintf(s0240_5,"%14.2f",Temp); else  sprintf(s0240_5,"%s",tmpstr);
  char s0240_7[20]; Temp=t0240_7; if (nabs(Temp)>eps) sprintf(s0240_7,"%14.2f",Temp); else  sprintf(s0240_7,"%s",tmpstr);
  char s0240_9[20]; Temp=t0240_9; if (nabs(Temp)>eps) sprintf(s0240_9,"%14.2f",Temp); else  sprintf(s0240_9,"%s",tmpstr);

  // Лист 5 строка 0300 ( сумма страховой части, всего ) 
  char s0300_3[20]; Temp=t0300_3; if (nabs(Temp)>eps) sprintf(s0300_3,"%14.2f",Temp); else  sprintf(s0300_3,"%s",tmpstr);
  char s0300_5[20]; Temp=t0300_5; if (nabs(Temp)>eps) sprintf(s0300_5,"%14.2f",Temp); else  sprintf(s0300_5,"%s",tmpstr);
  char s0300_7[20]; Temp=t0300_7; if (nabs(Temp)>eps) sprintf(s0300_7,"%14.2f",Temp); else  sprintf(s0300_7,"%s",tmpstr);
  char s0300_9[20]; Temp=t0300_9; if (nabs(Temp)>eps) sprintf(s0300_9,"%14.2f",Temp); else  sprintf(s0300_9,"%s",tmpstr);

  // Лист 5 строка 0310 ( сумма страховой части, за квартал ) 
  char s0310_3[20]; Temp=t0310_3; if (nabs(Temp)>eps) sprintf(s0310_3,"%14.2f",Temp); else  sprintf(s0310_3,"%s",tmpstr);
  char s0310_5[20]; Temp=t0310_5; if (nabs(Temp)>eps) sprintf(s0310_5,"%14.2f",Temp); else  sprintf(s0310_5,"%s",tmpstr);
  char s0310_7[20]; Temp=t0310_7; if (nabs(Temp)>eps) sprintf(s0310_7,"%14.2f",Temp); else  sprintf(s0310_7,"%s",tmpstr);
  char s0310_9[20]; Temp=t0310_9; if (nabs(Temp)>eps) sprintf(s0310_9,"%14.2f",Temp); else  sprintf(s0310_9,"%s",tmpstr);

  // Лист 5 строка 0320 ( сумма страховой части, 1-й месяц ) 
  char s0320_3[20]; Temp=t0320_3; if (nabs(Temp)>eps) sprintf(s0320_3,"%14.2f",Temp); else  sprintf(s0320_3,"%s",tmpstr);
  char s0320_5[20]; Temp=t0320_5; if (nabs(Temp)>eps) sprintf(s0320_5,"%14.2f",Temp); else  sprintf(s0320_5,"%s",tmpstr);
  char s0320_7[20]; Temp=t0320_7; if (nabs(Temp)>eps) sprintf(s0320_7,"%14.2f",Temp); else  sprintf(s0320_7,"%s",tmpstr);
  char s0320_9[20]; Temp=t0320_9; if (nabs(Temp)>eps) sprintf(s0320_9,"%14.2f",Temp); else  sprintf(s0320_9,"%s",tmpstr);

  // Лист 5 строка 0330 ( сумма страховой части, 2-й месяц ) 
  char s0330_3[20]; Temp=t0330_3; if (nabs(Temp)>eps) sprintf(s0330_3,"%14.2f",Temp); else  sprintf(s0330_3,"%s",tmpstr);
  char s0330_5[20]; Temp=t0330_5; if (nabs(Temp)>eps) sprintf(s0330_5,"%14.2f",Temp); else  sprintf(s0330_5,"%s",tmpstr);
  char s0330_7[20]; Temp=t0330_7; if (nabs(Temp)>eps) sprintf(s0330_7,"%14.2f",Temp); else  sprintf(s0330_7,"%s",tmpstr);
  char s0330_9[20]; Temp=t0330_9; if (nabs(Temp)>eps) sprintf(s0330_9,"%14.2f",Temp); else  sprintf(s0330_9,"%s",tmpstr);
  
  // Лист 5 строка 0340 ( сумма страховой части, 3-й месяц ) 
  char s0340_3[20]; Temp=t0340_3; if (nabs(Temp)>eps) sprintf(s0340_3,"%14.2f",Temp); else  sprintf(s0340_3,"%s",tmpstr);
  char s0340_5[20]; Temp=t0340_5; if (nabs(Temp)>eps) sprintf(s0340_5,"%14.2f",Temp); else  sprintf(s0340_5,"%s",tmpstr);
  char s0340_7[20]; Temp=t0340_7; if (nabs(Temp)>eps) sprintf(s0340_7,"%14.2f",Temp); else  sprintf(s0340_7,"%s",tmpstr);
  char s0340_9[20]; Temp=t0340_9; if (nabs(Temp)>eps) sprintf(s0340_9,"%14.2f",Temp); else  sprintf(s0340_9,"%s",tmpstr);

  // Лист 5 строка 0400 ( сумма накопительной части, всего )
  char s0400_5[20]; Temp=t0400_5; if (nabs(Temp)>eps) sprintf(s0400_5,"%14.2f",Temp); else  sprintf(s0400_5,"%s",tmpstr);
  char s0400_7[20]; Temp=t0400_7; if (nabs(Temp)>eps) sprintf(s0400_7,"%14.2f",Temp); else  sprintf(s0400_7,"%s",tmpstr);
  char s0400_9[20]; Temp=t0400_9; if (nabs(Temp)>eps) sprintf(s0400_9,"%14.2f",Temp); else  sprintf(s0400_9,"%s",tmpstr);
                                                                                   
  // Лист 5 строка 0410 ( сумма накопительной части, за квартал )
  char s0410_5[20]; Temp=t0410_5; if (nabs(Temp)>eps) sprintf(s0410_5,"%14.2f",Temp); else  sprintf(s0410_5,"%s",tmpstr);
  char s0410_7[20]; Temp=t0410_7; if (nabs(Temp)>eps) sprintf(s0410_7,"%14.2f",Temp); else  sprintf(s0410_7,"%s",tmpstr);
  char s0410_9[20]; Temp=t0410_9; if (nabs(Temp)>eps) sprintf(s0410_9,"%14.2f",Temp); else  sprintf(s0410_9,"%s",tmpstr);

  // Лист 5 строка 0420 ( сумма накопительной части, 1-й месяц )
  char s0420_5[20]; Temp=t0420_5; if (nabs(Temp)>eps) sprintf(s0420_5,"%14.2f",Temp); else  sprintf(s0420_5,"%s",tmpstr);
  char s0420_7[20]; Temp=t0420_7; if (nabs(Temp)>eps) sprintf(s0420_7,"%14.2f",Temp); else  sprintf(s0420_7,"%s",tmpstr);
  char s0420_9[20]; Temp=t0420_9; if (nabs(Temp)>eps) sprintf(s0420_9,"%14.2f",Temp); else  sprintf(s0420_9,"%s",tmpstr);

  // Лист 5 строка 0430 ( сумма накопительной части, 2-й месяц )
  char s0430_5[20]; Temp=t0430_5; if (nabs(Temp)>eps) sprintf(s0430_5,"%14.2f",Temp); else  sprintf(s0430_5,"%s",tmpstr);
  char s0430_7[20]; Temp=t0430_7; if (nabs(Temp)>eps) sprintf(s0430_7,"%14.2f",Temp); else  sprintf(s0430_7,"%s",tmpstr);
  char s0430_9[20]; Temp=t0430_9; if (nabs(Temp)>eps) sprintf(s0430_9,"%14.2f",Temp); else  sprintf(s0430_9,"%s",tmpstr);

  // Лист 5 строка 0440 ( сумма накопительной части, 3-й месяц )
  char s0440_5[20]; Temp=t0440_5; if (nabs(Temp)>eps) sprintf(s0440_5,"%14.2f",Temp); else  sprintf(s0440_5,"%s",tmpstr);
  char s0440_7[20]; Temp=t0440_7; if (nabs(Temp)>eps) sprintf(s0440_7,"%14.2f",Temp); else  sprintf(s0440_7,"%s",tmpstr);
  char s0440_9[20]; Temp=t0440_9; if (nabs(Temp)>eps) sprintf(s0440_9,"%14.2f",Temp); else  sprintf(s0440_9,"%s",tmpstr);


  // Лист 6
  double r010_4=S0104; double r010_5=S0105;
  double r012_4=S0124; double r012_5=S0125;
  double r013_4=S0134; double r013_5=S0135;
  double r014_4=S0144; double r014_5=S0145;

  double r011_4=r012_4+r013_4+r014_4;
  double r011_5=r012_5+r013_5+r014_5;

  double r010_3=r010_4+r010_5;
  double r011_3=r011_4+r011_5;
  double r012_3=r012_4+r012_5;
  double r013_3=r013_4+r013_5;
  double r014_3=r014_4+r014_5;

  double r015_4=r010_4-atof(s0300_9);
  double r015_5=r010_5-atof(s0400_9);
  double r015_3=r015_4+r015_5;

  // Лист 6 строка 010 ( Уплачено авансовых платежей, всего )
  char s010_3[20]; Temp=r010_3; if(nabs(Temp)>eps) sprintf(s010_3,"%14.2f",Temp); else sprintf(s010_3,"%s",tmpstr);
  char s010_4[20]; Temp=r010_4; if(nabs(Temp)>eps) sprintf(s010_4,"%14.2f",Temp); else sprintf(s010_4,"%s",tmpstr);
  char s010_5[20]; Temp=r010_5; if(nabs(Temp)>eps) sprintf(s010_5,"%14.2f",Temp); else sprintf(s010_5,"%s",tmpstr);

  // Лист 6 строка 011 ( Уплачено авансовых платежей, за квартал )
  char s011_3[20]; Temp=r011_3; if(nabs(Temp)>eps) sprintf(s011_3,"%14.2f",Temp); else sprintf(s011_3,"%s",tmpstr);
  char s011_4[20]; Temp=r011_4; if(nabs(Temp)>eps) sprintf(s011_4,"%14.2f",Temp); else sprintf(s011_4,"%s",tmpstr);
  char s011_5[20]; Temp=r011_5; if(nabs(Temp)>eps) sprintf(s011_5,"%14.2f",Temp); else sprintf(s011_5,"%s",tmpstr);

  // Лист 6 строка 012 ( Уплачено авансовых платежей, 1-й месяц )
  char s012_3[20]; Temp=r012_3; if(nabs(Temp)>eps) sprintf(s012_3,"%14.2f",Temp); else sprintf(s012_3,"%s",tmpstr);
  char s012_4[20]; Temp=r012_4; if(nabs(Temp)>eps) sprintf(s012_4,"%14.2f",Temp); else sprintf(s012_4,"%s",tmpstr);
  char s012_5[20]; Temp=r012_5; if(nabs(Temp)>eps) sprintf(s012_5,"%14.2f",Temp); else sprintf(s012_5,"%s",tmpstr);

  // Лист 6 строка 012 ( Уплачено авансовых платежей, 2-й месяц )
  char s013_3[20]; Temp=r013_3; if(nabs(Temp)>eps) sprintf(s013_3,"%14.2f",Temp); else sprintf(s013_3,"%s",tmpstr);
  char s013_4[20]; Temp=r013_4; if(nabs(Temp)>eps) sprintf(s013_4,"%14.2f",Temp); else sprintf(s013_4,"%s",tmpstr);
  char s013_5[20]; Temp=r013_5; if(nabs(Temp)>eps) sprintf(s013_5,"%14.2f",Temp); else sprintf(s013_5,"%s",tmpstr);

  // Лист 6 строка 013 ( Уплачено авансовых платежей, 3-й месяц )
  char s014_3[20]; Temp=r014_3; if(nabs(Temp)>eps) sprintf(s014_3,"%14.2f",Temp); else sprintf(s014_3,"%s",tmpstr);
  char s014_4[20]; Temp=r014_4; if(nabs(Temp)>eps) sprintf(s014_4,"%14.2f",Temp); else sprintf(s014_4,"%s",tmpstr);
  char s014_5[20]; Temp=r014_5; if(nabs(Temp)>eps) sprintf(s014_5,"%14.2f",Temp); else sprintf(s014_5,"%s",tmpstr);

  // Лист 6 строка 015 ( разница между уплаченным и начисленным )
  char s015_3[20]; Temp=r015_3; if(nabs(Temp)>eps) sprintf(s015_3,"%14.2f",Temp); else sprintf(s015_3,"%s",tmpstr);
  char s015_4[20]; Temp=r015_4; if(nabs(Temp)>eps) sprintf(s015_4,"%14.2f",Temp); else sprintf(s015_4,"%s",tmpstr);
  char s015_5[20]; Temp=r015_5; if(nabs(Temp)>eps) sprintf(s015_5,"%14.2f",Temp); else sprintf(s015_5,"%s",tmpstr);


  char Nni[128];
  char Cni[128];
  char Org[201];
  char Nio[201];
  char Adr[201];
  char Adf[201];
  char Ado[201];
  char Adi[201];
  char Inn[128];
  char Tel[128];
  char Kpp[128];
  char Kop[128];
  char Kim[128];
  char Kio[128];
  char Ruk[128];
  char Glb[128];
  char Dgl[128]; // должность главного бухгалтера
  char Iru[128];
  char Igl[128];
  char Pen[128];
  char Upr[128]; // Уполномоченный представитель
  char Iup[128]; // ИНН уполномоченного представителя
  char Tup[128]; // Телефон уполномоченного представителя
  char Tnr[20];  // Табельный номер руководителя
  char Tng[20];  // Табельный номер главного бухгалтера
  char Tnp[20];  // Табельный номер представителя
  char Kst[20];  // Код страны

  GetEnterpriseVar("ИМЯНИ",    Nni,127); // Наименование налоговой инспекции
  GetEnterpriseVar("КОДНИ",    Cni,127); // Код налоговой инспекции
  GetEnterpriseVar("ИМЯП",     Org,127); // Наименование предприятия или отделения иностранной организации
  GetEnterpriseVar("ИМЯИО",    Nio,127); // Наименование иностранной организации
  GetEnterpriseVar("АДРП",     Adr,127); // Адрес предприятия
  GetEnterpriseVar("АДРПФ",    Adf,200); // Адрес предприятия фактический
  GetEnterpriseVar("АДРПО",    Ado,200); // Адрес обособленного подразделения
  GetEnterpriseVar("АДРИО",    Adi,200); // Адрес иностранной организации в стране регистрации
  GetEnterpriseVar("ИНН",      Inn,127); // ИНН
  GetEnterpriseVar("ТЕЛП",     Tel,127); // Телефон
  GetEnterpriseVar("КОДПОСУЧ", Kpp,127); // Код причины постановки на учет
  GetEnterpriseVar("КППОП",    Kop,127); // КПП обособленного предприятия
  GetEnterpriseVar("КППИНОМ",  Kim,127); // КПП по месту нахождения имущества иностранной организации
  GetEnterpriseVar("КОДИОСР",  Kio,127); // Код налогоплательщика в стране регистрации или его аналог
  GetEnterpriseVar("РУКПП",    Ruk,127); // Руководитель
  GetEnterpriseVar("ГЛБУХП",   Glb,127); // Главбух
  GetEnterpriseVar("ДОЛЖБУХ",  Dgl,127); // Должность главного бухгалтера
  GetEnterpriseVar("ИННРУКП",  Iru,127); // ИНН руководителя
  GetEnterpriseVar("ИННГЛБ",   Igl,127); // ИНН главного бухгалтера
  GetEnterpriseVar("ПЕНСНОМ",  Pen,127); // регистрационный номер ПФР
  GetEnterpriseVar("КОДСТРИО", Kst,19);  // Код страны регистрации (инкорпорации)
  GetEnterpriseVar("ТНРУКП",   Tnr,19);  // Табельный номер руководителя
  GetEnterpriseVar("ТНГЛБУХ",  Tng,19);  // Табельный номер главного бухгалтера
  GetEnterpriseVar("ТНУПОЛН",  Tnp,19);  // Табельный номер уполномоченного представителя

  FreeSpaceString(Org,3,"");
  FreeSpaceString(Nio,3,"");
  FreeSpaceString(Inn,3,"");
  FreeSpaceString(Kpp,3,"");
  FreeSpaceString(Kop,3,"");
  FreeSpaceString(Kim,3,"");
  FreeSpaceString(Kio,3,"");
  FreeSpaceString(Nni,3,"");
  FreeSpaceString(Cni,3,"");
  FreeSpaceString(Adr,3,"");
  FreeSpaceString(Adf,3,"");
  FreeSpaceString(Ado,3,"");
  FreeSpaceString(Adi,3,"");
  FreeSpaceString(Tel,3,"");
  FreeSpaceString(Iru,3,"");
  FreeSpaceString(Igl,3,"");
  FreeSpaceString(Pen,3,"");
  FreeSpaceString(Dgl,3,"");
  FreeSpaceString(Upr,3,"");
  FreeSpaceString(Iup,3,"");
  FreeSpaceString(Tup,3,"");
  FreeSpaceString(Tnr,3,"");
  FreeSpaceString(Tng,3,"");
  FreeSpaceString(Tnp,3,"");
  FreeSpaceString(Kst,3,"");

  UpperString(Org);
  UpperString(Nio);
  UpperString(Ruk);
  UpperString(Glb);
  UpperString(Dgl);
  UpperString(Upr);
  UpperString(Adr);
  UpperString(Adf);
  UpperString(Adi);

  // TRANSFER {
  int hf;
  int hTmpFile; // хэндл временного файла
  unsigned long dwBytes;
  char NameStr[256];
  char TmpFileName[200];
  char Buffer[256];
  char InnFile[20];
  char YearFile[10];
  char ls[256]; // буфер для имени ЛС	
  char fsTmp[256];
  long PointKolPok=0;

  char CountryName[140]; char ALFA2[10];
  GetValueClassif("T_GUIDE\\country.tab",Kst,CountryName,120,"NAME","KOD");
  GetValueClassif("T_GUIDE\\country.tab",Kst,ALFA2,2,"ALFA2","KOD");
  FreeSpaceString(CountryName,3,""); FreeSpaceString(ALFA2,3,"");

  sprintf(YearFile,"%c%c",edat[5],edat[6]);

  if (ORG==3)
    sprintf(InnFile,"%c%c%c%c%c",Inn[5],Inn[6],Inn[7],Inn[8],Inn[9]);
  else
    sprintf(InnFile,"%c%c%c%c%c",Inn[4],Inn[5],Inn[6],Inn[7],Inn[8]);

  if (IMNS==1)
    sprintf(NameStr,"%sO%s%s.%03d", PathStr, InnFile, YearFile, NomFile);
  else
    sprintf(NameStr,"%sO%c%c%c%c%03d.txt", PathStr, Cni[0], Cni[1], Cni[2], Cni[3], NomFile);

  int KatNP=1;
  int DocPredst=4;

  if (FlgTrans==0)
  {
    // создадим временный файл в текущей директории
    sprintf(TmpFileName,"RaschEsn.tmp");
    DeleteFile(TmpFileName);

//  if ((stream = CreateFile(name       ,GENERIC_WRITE,FILE_SHARE_READ,NULL,CREATE_NEW,FILE_ATTRIBUTE_NORMAL,NULL)) == INVALID_HANDLE_VALUE)
    if ((hf  =    CreateFile(TmpFileName,1073741824   ,1              ,0   ,1         ,128                  ,0   )) == -1)
    {
      MessageBox(0,"эхтючьюцэю ёючфрЄ№ Їрщы","ю°шсър",0);
      FlgTrans=-1;
//      return -1;
    }
  }

  if (FlgTrans==0)
  {

    // собираем "Идентификатор файла"
    char IDFile[100]; // Идентификатор файла
    char IDOtpr[50];  // Идентификатор отправителя   

    if (IMNS==1)
    {
      if ( ORG!=3 && strlen(Kpp)>0 )
        sprintf(IDOtpr,"%c%c%c%c%c%c%c%c%c%c**%c%c%c%c%c%c%c%c%c",Inn[0],Inn[1],Inn[2],Inn[3],Inn[4],Inn[5],Inn[6],Inn[7],Inn[8],Inn[9],Kpp[0],Kpp[1],Kpp[2],Kpp[3],Kpp[4],Kpp[5],Kpp[6],Kpp[7],Kpp[8]);
      if ( ORG!=3 && strlen(Kpp)==0 )
        sprintf(IDOtpr,"%c%c%c%c%c%c%c%c%c%c***********",Inn[0],Inn[1],Inn[2],Inn[3],Inn[4],Inn[5],Inn[6],Inn[7],Inn[8],Inn[9]);
      if ( ORG==3 )
        sprintf(IDOtpr,"%c%c%c%c%c%c%c%c%c%c%c%c*********",Inn[0],Inn[1],Inn[2],Inn[3],Inn[4],Inn[5],Inn[6],Inn[7],Inn[8],Inn[9],Inn[10],Inn[11]);
    }
    else
      sprintf(IDOtpr,"%c%c%c%c*****************",Cni[0],Cni[1],Cni[2],Cni[3]);

    char IDDate[20];
    sprintf(IDDate,"%c%c%c%c%c%c%c%c",datatek[6],datatek[7],datatek[8],datatek[9],datatek[3],datatek[4],datatek[0],datatek[1]);

    char IDTime[20];
    struct SYSTEMTIME st;
    GetLocalTime(st);
    sprintf(IDTime,"%02d%02d%02d", st.wHour, st.wMinute, st.wSecond);

    // <файл отчетности> begin
    // <служебная часть> begin
    // <общие сведения служебной части> begin
    sprintf(IDFile,"%s%s%s", IDOtpr, IDDate, IDTime);
    sprintf(Buffer,"ИдФайл:%s\r\n", IDFile); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0);
    sprintf(Buffer,"ТипИнф:ОТЧЕТНОСТЬНП\r\n"); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0);
    sprintf(Buffer,"ВерсФорм:2.00\r\n"); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0);
    sprintf(Buffer,"ИдПол:%c%c%c%c\r\n",Cni[0],Cni[1],Cni[2],Cni[3]); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0);
    sprintf(Buffer,"ВерсПрог:УЧЕТ ЗАРАБОТНОЙ ПЛАТЫ - АМБА 3.7\r\n"); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0);
    sprintf(Buffer,"КолДок:1\r\n"); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0);
    // <общие сведения служебной части> end
    // <сведения об отправителе> begin
    if (ORG!=3)
    { // отправитель - юридическое лицо
      sprintf(Buffer,"НаимОтпрЮл:%s\r\n",Org); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0);
      sprintf(Buffer,"ТелОтпр:%s\r\n",Tel); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0);
      sprintf(Buffer,"ДолжнОтпр:%s\r\n",Dgl); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0);
      char fam[40], name[40], otch[40];
      elem_of_array(Glb,1,' ',fam,25);  FreeSpaceString(fam,3,"");
      elem_of_array(Glb,2,' ',name,25); FreeSpaceString(name,3,"");
      elem_of_array(Glb,3,' ',otch,25); FreeSpaceString(otch,3,"");
      sprintf(Buffer,"ФИООтпр:%s,%s,%s\r\n",fam,name,otch); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0);
    }
    else
    { // отправитель - физическое лицо
      char fam[40], name[40], otch[40];
      elem_of_array(Org,1,' ',fam,25);  FreeSpaceString(fam,3,"");
      elem_of_array(Org,2,' ',name,25); FreeSpaceString(name,3,"");
      elem_of_array(Org,3,' ',otch,25); FreeSpaceString(otch,3,"");
      sprintf(Buffer,"ФИООтпрФл:%s,%s,%s\r\n",fam,name,otch); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0);
      sprintf(Buffer,"ТелОтпр:%s\r\n",Tel); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0);
    }
    sprintf(Buffer,"@@@\r\n"); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0);
    // <сведения об отправителе> end
    // <служебная часть> end

    // <информационная часть> begin
    // <общие сведения иформационной части> begin
    char IDDoc[40];
    sprintf(IDDoc,"%s%c%c%c%c%08d",IDOtpr,edat[3],edat[4],edat[5],edat[6],NomFile);
    sprintf(Buffer,"ИдДок:%s\r\n",IDDoc); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0);
    sprintf(Buffer,"ДатаДок:%s\r\n",DRASCH); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0);
    if (ORG==0) DocPredst=1; // Российская организация
    if (ORG==1) DocPredst=2; // Обособленное подразделение
    if (ORG==3) DocPredst=3; // Физическое лицо
    if (ORG==2) DocPredst=5; // Иностранная организация
    sprintf(Buffer,"ДокПредст:%1d\r\n",DocPredst); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0);

    char SvidSer[30];   GetSerSvidetN("",SvidSer,25); FreeSpaceString(SvidSer,3,"");
    char SvidNum[30];   GetNumSvidetN("",SvidNum,25); FreeSpaceString(SvidNum,3,"");
    char SvidKod[30]; GetKodNISvidetN("",SvidKod,4);  FreeSpaceString(SvidKod,3,"");
    char SvidDatT[15]; sprintf(SvidDatT,"%9.2f",GetDateVSvidetN(""));
    char SvidDat[15];  sprintf(SvidDat,"%c%c.%c%c.%c%c%c%c",SvidDatT[7],SvidDatT[8],SvidDatT[4],SvidDatT[5],SvidDatT[0],SvidDatT[1],SvidDatT[2],SvidDatT[3]);

    sprintf(Buffer,"Свидетельство:%s %s,%s,%s\r\n",SvidSer,SvidNum,SvidDat,SvidKod); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0);
    if (TYPORG==1 || TYPORG==3) KatNP=2;
    if (ORG==3) KatNP=3;
    sprintf(Buffer,"КатНП:%02d\r\n",KatNP); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0);
    sprintf(Buffer,"КолФОтч:1\r\n"); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0);

    sprintf(Buffer,"###\r\n"); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0);
    // <общие сведения иформационной части> end
    // <сведения о налогоплательщике> begin
    if (ORG==0 || ORG==1)
    { // <сведения о российской организации>
      sprintf(Buffer,"НаимЮЛПол:%s\r\n",Org); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0);
      if (DocPredst==2 || DocPredst==4)
      { 
        sprintf(Buffer,"НаимОППол:%s\r\n",Org); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); 
      }
      sprintf(Buffer,"ИННЮЛ:%s\r\n",Inn); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0);
      sprintf(Buffer,"КППЮЛ:%s\r\n",Kpp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0);
      if (DocPredst==2 || DocPredst==4)
      { 
        sprintf(Buffer,"КППОП:%s\r\n",Kop); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); 
      }
      if (DocPredst==4)
      { 
        sprintf(Buffer,"КППИном:\r\n"); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); 
      }
      int PrizAdr=1; if (ADR==1) PrizAdr=2;
      sprintf(Buffer,"ПризАдр:%d\r\n",PrizAdr); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0);
      sprintf(Buffer,"АдрЮр:643,%s\r\n",Adr); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0);
      if (PrizAdr==2)
      {
        sprintf(Buffer,"АдрИсОрг:643,%s\r\n",Adf); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0);
      }
      if (DocPredst==2)
      {
        sprintf(Buffer,"АдрОП:643,%s\r\n",Ado); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0);
        sprintf(Buffer,"ТелОП:%s\r\n",Tel); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0);
      }
    }

    if (ORG==2)
    { // <сведения об иностранной организации>
      sprintf(Buffer,"НаимОИОПол:%s\r\n",Org); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0);
      sprintf(Buffer,"ИННИО:%s\r\n",Inn); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0);
//      sprintf(Buffer,"НаимОИОПол:%s\r\n",Org); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0);
      sprintf(Buffer,"КППИО:%s\r\n",Kpp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0);
      sprintf(Buffer,"КППИмИО:%s\r\n",Kim); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0);
      if (DocPredst==5)
      {
        sprintf(Buffer,"АдрОтдИОРФ:%s\r\n",Adr); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0);
      }
      sprintf(Buffer,"КодИОСтрРег:%s\r\n",Kio); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0);
      sprintf(Buffer,"НаимИОПол:%s\r\n",Nio); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0);
      sprintf(Buffer,"СтрИО:%s\r\n",CountryName); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0);
      sprintf(Buffer,"КодСтрИО:%s\r\n",ALFA2); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0);
      sprintf(Buffer,"АдрИО:%s\r\n",Adi); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0);
    }

    if (ORG==3)
    { // <сведения о налогоплательщике - физическом лице>
      char fam[40], name[40], otch[40];
      elem_of_array(Org,1,' ',fam,25);  FreeSpaceString(fam,3,"");
      elem_of_array(Org,2,' ',name,25); FreeSpaceString(name,3,"");
      elem_of_array(Org,3,' ',otch,25); FreeSpaceString(otch,3,"");
      sprintf(Buffer,"ФИО:%s,%s,%s\r\n",fam,name,otch); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0);
      sprintf(Buffer,"ИННФЛ:%s\r\n",Inn); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0);
//      sprintf(Buffer,"КолДнейРФ:\r\n"); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0);
      sprintf(Buffer,"ТелСлуж:%s\r\n",Tel); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0);
      if (Tel=="")
      {
        sprintf(Buffer,"ТелДом:\r\n"); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0);
      }
      if (Inn=="")
      {
        long tn=atol(Tnr);
        if (tn!=0)
        {
          // чтение ЛС
          lsname(Find_Full_TN(tn),ls);
          lsread(ls,1); 
          // дата рождения
          sprintf(Buffer,"ДатаРожд:%s\r\n",FreeSpaceString(R_Face("data_r",Rez,10,0),3,"")); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0);
          // место рождения
          char fsTmp1[200];
          sprintf(fsTmp1,"%s", FreeSpaceString(R_Face("strana_r",Rez,30,0),3,""));
          if (fsTmp1!="") sprintf(fsTmp,"%s",fsTmp1);
          sprintf(fsTmp1,"%s", FreeSpaceString(R_Face("oblast_r",Rez,30,0),3,""));
          if (fsTmp1!="" && fsTmp!="") sprintf(fsTmp,"%s,%s",fsTmp,fsTmp1);
          if (fsTmp1!="" && fsTmp=="") sprintf(fsTmp,"%s",fsTmp1);
          sprintf(fsTmp1,"%s", FreeSpaceString(R_Face("rajon_r",Rez,30,0),3,""));
          if (fsTmp1!="" && fsTmp!="") sprintf(fsTmp,"%s,%s",fsTmp,fsTmp1);
          if (fsTmp1!="" && fsTmp=="") sprintf(fsTmp,"%s",fsTmp1);
          sprintf(fsTmp1,"%s", FreeSpaceString(R_Face("gorod_r",Rez,30,0),3,""));
          if (fsTmp1!="" && fsTmp!="") sprintf(fsTmp,"%s,%s",fsTmp,fsTmp1);
          if (fsTmp1!="" && fsTmp=="") sprintf(fsTmp,"%s",fsTmp1);
          sprintf(Buffer,"МестоРожд:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0);
          sprintf(fsTmp,"");
          // пол
          R_Face("pol",Rez,10,0);
          FreeSpaceString(Rez,3,"");
          int pol=0;
          if (Rez=="М" || Rez=="м") pol=1;
          if (Rez=="Ж" || Rez=="ж") pol=2;
          sprintf(Buffer,"Пол:%1d\r\n",pol); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0);
          // гражданство
          sprintf(Buffer,"Гражд:%s\r\n",FreeSpaceString(R_Face("citizen",Rez,10,0),3,"")); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0);
          // удостоверение личности
          sprintf(fsTmp1,"%s",R_Face("doc_code",Rez,2,0));
          R_Face("pasport",Rez,128,0);
          FreeSpaceString(Rez,3,"");
          char fsTmp2[200];
          elem_of_array(Rez,1,',',fsTmp2,100);
          FreeSpaceString(fsTmp2,3,"");
          elem_of_array(Rez,2,',',fsTmp,100);
          FreeSpaceString(fsTmp,3,"");
          sprintf(Buffer,"УдЛичн:%s,%s %s\r\n",fsTmp1,fsTmp2,fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0);
          // дата удостоверения личности
          elem_of_array(Rez,4,',',fsTmp1,100);
          FreeSpaceString(fsTmp1,3,"");
          sprintf(Buffer,"ДатаУдЛичн:%s\r\n",fsTmp1); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0);
          sprintf(Buffer,"АдрМж:643,%s\r\n",FreeSpaceString(UpperString(R_Face("adres_f",Rez,200,0)),3,"")); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0);
          sprintf(Buffer,"АдрМжРез:643,%s\r\n",FreeSpaceString(UpperString(R_Face("adres",Rez,200,0)),3,"")); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0);
        }
      }
    }

    sprintf(Buffer,"###\r\n"); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0);

    // <сведения о руководстве организации>
    char fam1[40], name1[40], otch1[40];
    elem_of_array(Ruk,1,' ',fam1,25);  FreeSpaceString(fam1,3,"");
    elem_of_array(Ruk,2,' ',name1,25); FreeSpaceString(name1,3,"");
    elem_of_array(Ruk,3,' ',otch1,25); FreeSpaceString(otch1,3,"");
    sprintf(Buffer,"ФИОРук:%s,%s,%s\r\n",fam1,name1,otch1); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0);
    sprintf(Buffer,"ИННРук:%s\r\n",Iru); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0);
    sprintf(Buffer,"ТелРук:%s\r\n",Tel); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0);
    if (Iru=="")
    {
      long tn=atol(Tnr);
      if (tn!=0)
      {
        // чтение ЛС
        lsname(Find_Full_TN(tn),ls);
        lsread(ls,1); 
        // дата рождения
        sprintf(Buffer,"ДатаРождРук:%s\r\n",FreeSpaceString(R_Face("data_r",Rez,10,0),3,"")); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0);
        // место рождения
        char fsTmp1[200];
        sprintf(fsTmp1,"%s", FreeSpaceString(R_Face("strana_r",Rez,30,0),3,""));
        if (fsTmp1!="") sprintf(fsTmp,"%s",fsTmp1);
        sprintf(fsTmp1,"%s", FreeSpaceString(R_Face("oblast_r",Rez,30,0),3,""));
        if (fsTmp1!="" && fsTmp!="") sprintf(fsTmp,"%s,%s",fsTmp,fsTmp1);
        if (fsTmp1!="" && fsTmp=="") sprintf(fsTmp,"%s",fsTmp1);
        sprintf(fsTmp1,"%s", FreeSpaceString(R_Face("rajon_r",Rez,30,0),3,""));
        if (fsTmp1!="" && fsTmp!="") sprintf(fsTmp,"%s,%s",fsTmp,fsTmp1);
        if (fsTmp1!="" && fsTmp=="") sprintf(fsTmp,"%s",fsTmp1);
        sprintf(fsTmp1,"%s", FreeSpaceString(R_Face("gorod_r",Rez,30,0),3,""));
        if (fsTmp1!="" && fsTmp!="") sprintf(fsTmp,"%s,%s",fsTmp,fsTmp1);
        if (fsTmp1!="" && fsTmp=="") sprintf(fsTmp,"%s",fsTmp1);
        sprintf(Buffer,"МестоРождРук:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0);
        sprintf(fsTmp,"");
        // пол
        R_Face("pol",Rez,10,0);
        FreeSpaceString(Rez,3,"");
        int pol=0;
        if (Rez=="М" || Rez=="м" || Rez=="1") pol=1;
        if (Rez=="Ж" || Rez=="ж" || Rez=="2") pol=2;
        sprintf(Buffer,"ПолРук:%1d\r\n",pol); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0);
        // гражданство
        sprintf(Buffer,"ГраждРук:%s\r\n",FreeSpaceString(R_Face("citizen",Rez,10,0),3,"")); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0);
        // удостоверение личности
        sprintf(fsTmp1,"%s",R_Face("doc_code",Rez,2,0));
        R_Face("pasport",Rez,128,0);
        FreeSpaceString(Rez,3,"");
        char fsTmp2[200];
        elem_of_array(Rez,1,',',fsTmp2,100);
        FreeSpaceString(fsTmp2,3,"");
        elem_of_array(Rez,2,',',fsTmp,100);
        FreeSpaceString(fsTmp,3,"");
        sprintf(Buffer,"УдЛичнРук:%s,%s %s\r\n",fsTmp1,fsTmp2,fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0);
        // дата удостоверения личности
        elem_of_array(Rez,4,',',fsTmp1,100);
        FreeSpaceString(fsTmp1,3,"");
        sprintf(Buffer,"ДатаУдЛичнРук:%s\r\n",fsTmp1); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0);
        sprintf(Buffer,"АдрМЖРукРФ:643,%s\r\n",FreeSpaceString(UpperString(R_Face("adres_f",Rez,200,0)),3,"")); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0);
        sprintf(Buffer,"АдрМЖРукРез:643,%s\r\n",FreeSpaceString(UpperString(R_Face("adres",Rez,200,0)),3,"")); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0);
      }
    }
    elem_of_array(Glb,1,' ',fam1,25);  FreeSpaceString(fam1,3,"");
    elem_of_array(Glb,2,' ',name1,25); FreeSpaceString(name1,3,"");
    elem_of_array(Glb,3,' ',otch1,25); FreeSpaceString(otch1,3,"");
    char Glb1[100]; sprintf(Glb1,"%s,%s,%s",fam1,name1,otch1);
    sprintf(Buffer,"ФИОБух:%s\r\n",Glb1); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0);
    if (Glb1!=",,")
    {
      sprintf(Buffer,"ИННБух:%s\r\n",Igl); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0);
      sprintf(Buffer,"ТелБух:%s\r\n",Tel); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0);
    }
    if (Glb1!=",," && Igl=="")
    {
      long tn=atol(Tng);
      if (tn!=0)
      {
        // чтение ЛС
        lsname(Find_Full_TN(tn),ls);
        lsread(ls,1); 
        // дата рождения
        sprintf(Buffer,"ДатаРождБух:%s\r\n",FreeSpaceString(R_Face("data_r",Rez,10,0),3,"")); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0);
        // место рождения
        char fsTmp1[200];
        for (int i=0; i<strlen(fsTmp); i++) fsTmp[i]=' '; fsTmp[0]='\0';
        sprintf(fsTmp1,"%s", FreeSpaceString(R_Face("strana_r",Rez,30,0),3,""));
        if (fsTmp1!="") sprintf(fsTmp,"%s",fsTmp1);
        sprintf(fsTmp1,"%s", FreeSpaceString(R_Face("oblast_r",Rez,30,0),3,""));
        if (fsTmp1!="" && fsTmp!="") sprintf(fsTmp,"%s,%s",fsTmp,fsTmp1);
        if (fsTmp1!="" && fsTmp=="") sprintf(fsTmp,"%s",fsTmp1);
        sprintf(fsTmp1,"%s", FreeSpaceString(R_Face("rajon_r",Rez,30,0),3,""));
        if (fsTmp1!="" && fsTmp!="") sprintf(fsTmp,"%s,%s",fsTmp,fsTmp1);
        if (fsTmp1!="" && fsTmp=="") sprintf(fsTmp,"%s",fsTmp1);
        sprintf(fsTmp1,"%s", FreeSpaceString(R_Face("gorod_r",Rez,30,0),3,""));
        if (fsTmp1!="" && fsTmp!="") sprintf(fsTmp,"%s,%s",fsTmp,fsTmp1);
        if (fsTmp1!="" && fsTmp=="") sprintf(fsTmp,"%s",fsTmp1);
        sprintf(Buffer,"МестоРождБух:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0);
        // пол
        R_Face("pol",Rez,10,0);
        FreeSpaceString(Rez,3,"");
        int pol=0;
        if (Rez=="М" || Rez=="м") pol=1;
        if (Rez=="Ж" || Rez=="ж") pol=2;
        sprintf(Buffer,"ПолБух:%1d\r\n",pol); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0);
        // гражданство
        sprintf(Buffer,"ГраждБух:%s\r\n",FreeSpaceString(R_Face("citizen",Rez,10,0),3,"")); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0);
        // удостоверение личности
        for (int i=0; i<strlen(fsTmp); i++) fsTmp[i]=' '; fsTmp[0]='\0'; 
        for (int i=0; i<strlen(fsTmp1); i++) fsTmp1[i]=' '; fsTmp1[0]='\0';
        sprintf(fsTmp1,"%s",R_Face("doc_code",Rez,2,0));
        R_Face("pasport",Rez,128,0);
        FreeSpaceString(Rez,3,"");
        char fsTmp2[200];
        elem_of_array(Rez,1,',',fsTmp2,100);
        FreeSpaceString(fsTmp2,3,"");
        elem_of_array(Rez,2,',',fsTmp,100);
        FreeSpaceString(fsTmp,3,"");
        sprintf(Buffer,"УдЛичнБух:%s,%s %s\r\n",fsTmp1,fsTmp2,fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0);
        // дата удостоверения личности
        elem_of_array(Rez,4,',',fsTmp1,100);
        FreeSpaceString(fsTmp1,3,"");
        sprintf(Buffer,"ДатаУдЛичнБух:%s\r\n",fsTmp1); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0);
        sprintf(Buffer,"АдрМЖБухРФ:643,%s\r\n",FreeSpaceString(UpperString(R_Face("adres_f",Rez,200,0)),3,"")); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0);
        sprintf(Buffer,"АдрМЖБухРез:643,%s\r\n",FreeSpaceString(UpperString(R_Face("adres",Rez,200,0)),3,"")); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0);
      }
    }
    elem_of_array(Upr,1,' ',fam1,25);  FreeSpaceString(fam1,3,"");
    elem_of_array(Upr,2,' ',name1,25); FreeSpaceString(name1,3,"");
    elem_of_array(Upr,3,' ',otch1,25); FreeSpaceString(otch1,3,"");
    char Upr1[100]; sprintf(Upr1,"%s,%s,%s",fam1,name1,otch1);
    sprintf(Buffer,"ФИОУпПред:%s\r\n",Upr1); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0);
    if (Upr1!=",,")
    {
      sprintf(Buffer,"ИННУпПред:%s\r\n",Iup); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0);
      sprintf(Buffer,"ТелУпПред:%s\r\n",Tup); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0);
    }
    if (Upr1!=",," && Iup=="")
    {
      long tn=atol(Tnp);
      if (tn!=0)
      {
        // чтение ЛС
        lsname(Find_Full_TN(tn),ls);
        lsread(ls,1); 
        // дата рождения
        sprintf(Buffer,"ДатаРождУпПред:%s\r\n",FreeSpaceString(R_Face("data_r",Rez,10,0),3,"")); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0);
        // место рождения
        char fsTmp1[200];
        for (int i=0; i<strlen(fsTmp); i++) fsTmp[i]=' '; fsTmp[0]='\0';
        sprintf(fsTmp1,"%s", FreeSpaceString(R_Face("strana_r",Rez,30,0),3,""));
        if (fsTmp1!="") sprintf(fsTmp,"%s",fsTmp1);
        sprintf(fsTmp1,"%s", FreeSpaceString(R_Face("oblast_r",Rez,30,0),3,""));
        if (fsTmp1!="" && fsTmp!="") sprintf(fsTmp,"%s,%s",fsTmp,fsTmp1);
        if (fsTmp1!="" && fsTmp=="") sprintf(fsTmp,"%s",fsTmp1);
        sprintf(fsTmp1,"%s", FreeSpaceString(R_Face("rajon_r",Rez,30,0),3,""));
        if (fsTmp1!="" && fsTmp!="") sprintf(fsTmp,"%s,%s",fsTmp,fsTmp1);
        if (fsTmp1!="" && fsTmp=="") sprintf(fsTmp,"%s",fsTmp1);
        sprintf(fsTmp1,"%s", FreeSpaceString(R_Face("gorod_r",Rez,30,0),3,""));
        if (fsTmp1!="" && fsTmp!="") sprintf(fsTmp,"%s,%s",fsTmp,fsTmp1);
        if (fsTmp1!="" && fsTmp=="") sprintf(fsTmp,"%s",fsTmp1);
        sprintf(Buffer,"МестоРождУпПред:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0);
        // пол
        R_Face("pol",Rez,10,0);
        FreeSpaceString(Rez,3,"");
        int pol=0;
        if (Rez=="М" || Rez=="м" || Rez=="1") pol=1;
        if (Rez=="Ж" || Rez=="ж" || Rez=="2") pol=2;
        sprintf(Buffer,"ПолУпПред:%1d\r\n",pol); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0);
        // гражданство
        sprintf(Buffer,"ГраждУпПред:%s\r\n",FreeSpaceString(R_Face("citizen",Rez,10,0),3,"")); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0);
        // удостоверение личности
        for (int i=0; i<strlen(fsTmp); i++) fsTmp[i]=' '; fsTmp[0]='\0';
        for (int i=0; i<strlen(fsTmp1); i++) fsTmp1[i]=' '; fsTmp1[0]='\0';
        sprintf(fsTmp1,"%s",R_Face("doc_code",Rez,2,0));
        R_Face("pasport",Rez,128,0);
        FreeSpaceString(Rez,3,"");
        char fsTmp2[200];
        elem_of_array(Rez,1,',',fsTmp2,100);
        FreeSpaceString(fsTmp2,3,"");
        elem_of_array(Rez,2,',',fsTmp,100);
        FreeSpaceString(fsTmp,3,"");
        sprintf(Buffer,"УдЛичнУпПред:%s,%s %s\r\n",fsTmp1,fsTmp2,fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0);
        // дата удостоверения личности
        elem_of_array(Rez,4,',',fsTmp1,100);
        FreeSpaceString(fsTmp1,3,"");
        sprintf(Buffer,"ДатаУдЛичнУпПред:%s\r\n",fsTmp1); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0);
        sprintf(Buffer,"АдрМЖУпПредРФ:643,%s\r\n",FreeSpaceString(UpperString(R_Face("adres_f",Rez,200,0)),3,"")); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0);
        sprintf(Buffer,"АдрМЖУпПредРез:643,%s\r\n",FreeSpaceString(UpperString(R_Face("adres",Rez,200,0)),3,"")); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0);
      }
    }

    sprintf(Buffer,"###\r\n"); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0);
    // <сведения о налогоплательщике> end

    // КОНЕЦ ОБЩЕЙ ЧАСТИ ФАЙЛА

    // <форма отчетности> begin
    // <описание формы> begin
    // Таблица 1
    sprintf(Buffer,"ПризФОтч:1\r\n"); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0);
    sprintf(Buffer,"КНД:1151058\r\n"); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0);
//    sprintf(Buffer,"НаимФОтч:РАСЧЕТ ПО АВАНСОВЫМ ПЛАТЕЖАМ ПО СТРАХОВЫМ ВЗНОСАМ НА ОБЯЗАТЕЛЬНОЕ ПЕНСИОННОЕ СТРАХОВАНИЕ ДЛЯ ЛИЦ, ПРОИЗВОДЯЩИХ ВЫПЛАТЫ ФИЗИЧЕСКИМ ЛИЦАМ: ОРГАНИЗАЦИЙ; ИНДИВИДУАЛЬНЫХ ПРЕДПРИНИМАТЕЛЕЙ; ФИЗИЧЕСКИХ ЛИЦ, НЕ ПРИЗНАВАЕМЫХ ИНДИВИДУАЛЬНЫМИ ПРЕДПРИНИМАТЕЛЯМИ\r\n"); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0);
    sprintf(Buffer,"НаимФОтч:РАСЧЕТ ПО АВАНСОВЫМ ПЛАТЕЖАМ ПО СТРАХОВЫМ ВЗНОСАМ НА ОБЯЗАТЕЛЬНОЕ ПЕНСИОННОЕ СТРАХОВАНИЕ\r\n"); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0);
    sprintf(Buffer,"ВерФОтч:2.00000\r\n"); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0);
    sprintf(Buffer,"ПериодВерОтч:17.06.2002,\r\n"); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0);
    sprintf(Buffer,"ПризПериодОтч:2\r\n"); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0);

    char BegPOtch[20];
    char EndPOtch[20];
    int BPOtch=atoi(CTabl.TextS("ABDAT",0));
    int EPOtch=atoi(CTabl.TextS("AEDAT",0));
    sprintf(Arg,"5,%d",BPOtch);
    sprintf(BegPOtch,"01.%-7.7s",R_DATA_EX(Arg,Rez,7,0));
    sprintf(Arg,"6,%d",EPOtch);
    int KalDays=atoi(R_DATA_EX(Arg,Rez,10,0));
    sprintf(Arg,"5,%d",EPOtch);
    sprintf(EndPOtch,"%02d.%-7.7s",KalDays,R_DATA_EX(Arg,Rez,7,0));
    if (FTrans_DL==0)
    {
      if (EndPOtch=="30.09.2002")
      {
        sprintf(Buffer,"НачПериодОтч:%s\r\n","01.07.2002"); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0);
      }
      else
      {
        sprintf(Buffer,"НачПериодОтч:%s\r\n",BegPOtch); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0);
      }
    }
    if (FTrans_DL==1)
    {
      sprintf(Buffer,"НачПериодОтч:%s\r\n",BegPOtch); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0);
    }
    sprintf(Buffer,"КонПериодОтч:%s\r\n",EndPOtch); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0);

    sprintf(Buffer,"ОКЕИ:383\r\n"); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0);
    sprintf(Buffer,"ВарФОтч:%s\r\n",VarFOtch); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0);
    sprintf(Buffer,"КолПокФОтч:\r\n"); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0);
    PointKolPok=SetFilePointer(hf,0,0,1);
    // <описание формы> end
    sprintf(Buffer,"###\r\n"); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0);
    // <содержание формы> begin
    // <Раздел 0> begin
    // Таблица 2
    if (FTrans_DL==1)
    {
      sprintf(Buffer,"РегНомПФР:%s\r\n",Pen); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0);
      // <Раздел 0> end
      sprintf(Buffer,"###\r\n"); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0);
    }
  }
  // } TRANSFER 

  if (strlen(Kpp)==0) { sprintf(Kpp,"               "); }
  if (strlen(Kop)==0) { sprintf(Kop,"               "); }
  if (strlen(Inn)==0) { sprintf(Inn,"               "); }
  if (strlen(Iru)==0) { sprintf(Iru,"               "); }
  if (strlen(Igl)==0) { sprintf(Igl,"               "); }

  char adr_ind[20]; elem_of_array(Adr, 1, ',', adr_ind, 6);  // индекс
  char adr_reg[40]; elem_of_array(Adr, 2, ',', adr_reg, 40); // регион
  char adr_rai[40]; elem_of_array(Adr, 3, ',', adr_rai, 40); // район
  char adr_gor[40]; elem_of_array(Adr, 4, ',', adr_gor, 40); // город
  char adr_nas[40]; elem_of_array(Adr, 5, ',', adr_nas, 40); // населенный пункт
  char adr_str[40]; elem_of_array(Adr, 6, ',', adr_str, 40); // улица                
  char adr_dom[10]; elem_of_array(Adr, 7, ',', adr_dom, 10); // дом
  char adr_kor[10]; elem_of_array(Adr, 8, ',', adr_kor, 10); // корпус
  char adr_kva[10]; elem_of_array(Adr, 9, ',', adr_kva, 10); // квартира

  char adf_ind[20]; elem_of_array(Adf, 1, ',', adf_ind, 6);  // индекс
  char adf_reg[40]; elem_of_array(Adf, 2, ',', adf_reg, 40); // регион
  char adf_rai[40]; elem_of_array(Adf, 3, ',', adf_rai, 40); // район
  char adf_gor[40]; elem_of_array(Adf, 4, ',', adf_gor, 40); // город
  char adf_nas[40]; elem_of_array(Adf, 5, ',', adf_nas, 40); // населенный пункт
  char adf_str[40]; elem_of_array(Adf, 6, ',', adf_str, 40); // улица                
  char adf_dom[10]; elem_of_array(Adf, 7, ',', adf_dom, 10); // дом
  char adf_kor[10]; elem_of_array(Adf, 8, ',', adf_kor, 10); // корпус
  char adf_kva[10]; elem_of_array(Adf, 9, ',', adf_kva, 10); // квартира

  char ado_ind[20]; elem_of_array(Ado, 1, ',', ado_ind, 6);  // индекс
  char ado_reg[40]; elem_of_array(Ado, 2, ',', ado_reg, 40); // регион
  char ado_rai[40]; elem_of_array(Ado, 3, ',', ado_rai, 40); // район
  char ado_gor[40]; elem_of_array(Ado, 4, ',', ado_gor, 40); // город
  char ado_nas[40]; elem_of_array(Ado, 5, ',', ado_nas, 40); // населенный пункт
  char ado_str[40]; elem_of_array(Ado, 6, ',', ado_str, 40); // улица                
  char ado_dom[10]; elem_of_array(Ado, 7, ',', ado_dom, 10); // дом
  char ado_kor[10]; elem_of_array(Ado, 8, ',', ado_kor, 10); // корпус
  char ado_kva[10]; elem_of_array(Ado, 9, ',', ado_kva, 10); // квартира

  FreeSpaceString(adr_ind,3,"");
  FreeSpaceString(adr_reg,3,"");
  FreeSpaceString(adr_rai,3,"");
  FreeSpaceString(adr_gor,3,"");
  FreeSpaceString(adr_nas,3,"");
  FreeSpaceString(adr_str,3,"");
  FreeSpaceString(adr_dom,3,"");
  FreeSpaceString(adr_kor,3,"");
  FreeSpaceString(adr_kva,3,"");

  FreeSpaceString(adf_ind,3,"");
  FreeSpaceString(adf_reg,3,"");
  FreeSpaceString(adf_rai,3,"");
  FreeSpaceString(adf_gor,3,"");
  FreeSpaceString(adf_nas,3,"");
  FreeSpaceString(adf_str,3,"");
  FreeSpaceString(adf_dom,3,"");
  FreeSpaceString(adf_kor,3,"");
  FreeSpaceString(adf_kva,3,"");

  FreeSpaceString(ado_ind,3,"");
  FreeSpaceString(ado_reg,3,"");
  FreeSpaceString(ado_rai,3,"");
  FreeSpaceString(ado_gor,3,"");
  FreeSpaceString(ado_nas,3,"");
  FreeSpaceString(ado_str,3,"");
  FreeSpaceString(ado_dom,3,"");
  FreeSpaceString(ado_kor,3,"");
  FreeSpaceString(ado_kva,3,"");

  if (strlen(adr_ind)==0) sprintf(adr_ind,"                       ");
  if (strlen(adf_ind)==0) sprintf(adf_ind,"                       ");
  if (strlen(ado_ind)==0) sprintf(ado_ind,"                       ");

  char WHAT_PRINT[11]; sprintf(WHAT_PRINT,"%-10.10s", DOP);
  char DIGIT[10];
  int  LIST[11]; // признак печати листа, индекс - номер листа

  for (int i=0; i<7; i++)
  {
    sprintf(DIGIT,"%c",WHAT_PRINT[i]); LIST[i+1]=atoi(DIGIT);
  }

  char StrDate[11];
  sprintf(StrDate,"%-10.10s",DRASCH);

  char KodReg[3]; 
  sprintf(KodReg,"  ");
  if (adr_reg=="Свердловская обл.")  { sprintf(KodReg,"66"); } 
  if (adr_reg=="Челябинская обл.")   { sprintf(KodReg,"74"); } 
  if (adr_reg=="г. Москва")          { sprintf(KodReg,"77"); } 
  if (adr_reg=="г. Санкт-Петербург") { sprintf(KodReg,"78"); } 
  if (adr_reg=="Сахалинская обл.")   { sprintf(KodReg,"65"); } 
  if (adr_reg=="Пермская обл.")      { sprintf(KodReg,"59"); } 

  char fKodReg[3]; 
  sprintf(fKodReg,"  ");
  if (adf_reg=="Свердловская обл.")  { sprintf(fKodReg,"66"); } 
  if (adf_reg=="Челябинская обл.")   { sprintf(fKodReg,"74"); } 
  if (adf_reg=="г. Москва")          { sprintf(fKodReg,"77"); } 
  if (adf_reg=="г. Санкт-Петербург") { sprintf(fKodReg,"78"); } 
  if (adf_reg=="Сахалинская обл.")   { sprintf(fKodReg,"65"); } 
  if (adf_reg=="Пермская обл.")      { sprintf(fKodReg,"59"); } 

  char oKodReg[3]; 
  sprintf(oKodReg,"  ");
  if (ado_reg=="Свердловская обл.")  { sprintf(oKodReg,"66"); } 
  if (ado_reg=="Челябинская обл.")   { sprintf(oKodReg,"74"); } 
  if (ado_reg=="г. Москва")          { sprintf(oKodReg,"77"); } 
  if (ado_reg=="г. Санкт-Петербург") { sprintf(oKodReg,"78"); } 
  if (ado_reg=="Сахалинская обл.")   { sprintf(oKodReg,"65"); } 
  if (ado_reg=="Пермская обл.")      { sprintf(oKodReg,"59"); } 


  string ai0, ai1, ai2, ai3, ai4, ai5;
  string aReg, aKodReg0, aKodReg1, aRai, aGor, aNas, aStr, aDom, aKor, aKva;
  string afi0, afi1, afi2, afi3, afi4, afi5;
  string afReg, afKodReg0, afKodReg1, afRai, afGor;
  string afNas, afStr, afDom, afKor, afKva;
  string aTel, aOrg;

  string vOrg[4];
  for (int i=0; i<4; i++)
  {
    if (i==ORG) vOrg[i]="V"; else vOrg[i]=" ";
  }


  // TRANSFER {                 // передача в файл

  int KolPokFOtch=0;

  if (FlgTrans==0)
  {
    // <Раздел 1> begin
    // Таблица 3
    // Лист 5  Расчет по авансовым платежам по страховым взносам
    // строка 0100
    dTransPF_DL(s0100_3,fsTmp); sprintf(Buffer,"П000010010003:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;
    dTransPF_DL(s0100_5,fsTmp); sprintf(Buffer,"П000010010005:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;
    dTransPF_DL(s0100_7,fsTmp); sprintf(Buffer,"П000010010007:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;
    dTransPF_DL(s0100_9,fsTmp); sprintf(Buffer,"П000010010009:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;

    // строка 0110
    dTransPF_DL(s0110_3,fsTmp); sprintf(Buffer,"П000010011003:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;
    dTransPF_DL(s0110_5,fsTmp); sprintf(Buffer,"П000010011005:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;
    dTransPF_DL(s0110_7,fsTmp); sprintf(Buffer,"П000010011007:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;
    dTransPF_DL(s0110_9,fsTmp); sprintf(Buffer,"П000010011009:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;

    // строка 0120
    dTransPF_DL(s0120_3,fsTmp); sprintf(Buffer,"П000010012003:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;
    dTransPF_DL(s0120_5,fsTmp); sprintf(Buffer,"П000010012005:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;
    dTransPF_DL(s0120_7,fsTmp); sprintf(Buffer,"П000010012007:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;
    dTransPF_DL(s0120_9,fsTmp); sprintf(Buffer,"П000010012009:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;

    // строка 0130
    dTransPF_DL(s0130_3,fsTmp); sprintf(Buffer,"П000010013003:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;
    dTransPF_DL(s0130_5,fsTmp); sprintf(Buffer,"П000010013005:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;
    dTransPF_DL(s0130_7,fsTmp); sprintf(Buffer,"П000010013007:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;
    dTransPF_DL(s0130_9,fsTmp); sprintf(Buffer,"П000010013009:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;

    // строка 0140
    dTransPF_DL(s0140_3,fsTmp); sprintf(Buffer,"П000010014003:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;
    dTransPF_DL(s0140_5,fsTmp); sprintf(Buffer,"П000010014005:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;
    dTransPF_DL(s0140_7,fsTmp); sprintf(Buffer,"П000010014007:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;
    dTransPF_DL(s0140_9,fsTmp); sprintf(Buffer,"П000010014009:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;

    // строка 0200
    dTransPF_DL(s0200_3,fsTmp); sprintf(Buffer,"П000010020003:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;
    dTransPF_DL(s0200_5,fsTmp); sprintf(Buffer,"П000010020005:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;
    dTransPF_DL(s0200_7,fsTmp); sprintf(Buffer,"П000010020007:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;
    dTransPF_DL(s0200_9,fsTmp); sprintf(Buffer,"П000010020009:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;

    // строка 0210
    dTransPF_DL(s0210_3,fsTmp); sprintf(Buffer,"П000010021003:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;
    dTransPF_DL(s0210_5,fsTmp); sprintf(Buffer,"П000010021005:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;
    dTransPF_DL(s0210_7,fsTmp); sprintf(Buffer,"П000010021007:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;
    dTransPF_DL(s0210_9,fsTmp); sprintf(Buffer,"П000010021009:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;

    // строка 0220
    dTransPF_DL(s0220_3,fsTmp); sprintf(Buffer,"П000010022003:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;
    dTransPF_DL(s0220_5,fsTmp); sprintf(Buffer,"П000010022005:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;
    dTransPF_DL(s0220_7,fsTmp); sprintf(Buffer,"П000010022007:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;
    dTransPF_DL(s0220_9,fsTmp); sprintf(Buffer,"П000010022009:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;

    // строка 0230
    dTransPF_DL(s0230_3,fsTmp); sprintf(Buffer,"П000010023003:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;
    dTransPF_DL(s0230_5,fsTmp); sprintf(Buffer,"П000010023005:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;
    dTransPF_DL(s0230_7,fsTmp); sprintf(Buffer,"П000010023007:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;
    dTransPF_DL(s0230_9,fsTmp); sprintf(Buffer,"П000010023009:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;

    // строка 0240
    dTransPF_DL(s0240_3,fsTmp); sprintf(Buffer,"П000010024003:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;
    dTransPF_DL(s0240_5,fsTmp); sprintf(Buffer,"П000010024005:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;
    dTransPF_DL(s0240_7,fsTmp); sprintf(Buffer,"П000010024007:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;
    dTransPF_DL(s0240_9,fsTmp); sprintf(Buffer,"П000010024009:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;

    // строка 0300
    dTransPF_DL(s0300_3,fsTmp); sprintf(Buffer,"П000010030003:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;
    dTransPF_DL(s0300_5,fsTmp); sprintf(Buffer,"П000010030005:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;
    dTransPF_DL(s0300_7,fsTmp); sprintf(Buffer,"П000010030007:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;
    dTransPF_DL(s0300_9,fsTmp); sprintf(Buffer,"П000010030009:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;

    // строка 0310
    dTransPF_DL(s0310_3,fsTmp); sprintf(Buffer,"П000010031003:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;
    dTransPF_DL(s0310_5,fsTmp); sprintf(Buffer,"П000010031005:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;
    dTransPF_DL(s0310_7,fsTmp); sprintf(Buffer,"П000010031007:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;
    dTransPF_DL(s0310_9,fsTmp); sprintf(Buffer,"П000010031009:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;

    // строка 0320
    dTransPF_DL(s0320_3,fsTmp); sprintf(Buffer,"П000010032003:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;
    dTransPF_DL(s0320_5,fsTmp); sprintf(Buffer,"П000010032005:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;
    dTransPF_DL(s0320_7,fsTmp); sprintf(Buffer,"П000010032007:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;
    dTransPF_DL(s0320_9,fsTmp); sprintf(Buffer,"П000010032009:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;

    // строка 0330
    dTransPF_DL(s0330_3,fsTmp); sprintf(Buffer,"П000010033003:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;
    dTransPF_DL(s0330_5,fsTmp); sprintf(Buffer,"П000010033005:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;
    dTransPF_DL(s0330_7,fsTmp); sprintf(Buffer,"П000010033007:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;
    dTransPF_DL(s0330_9,fsTmp); sprintf(Buffer,"П000010033009:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;

    // строка 0340
    dTransPF_DL(s0340_3,fsTmp); sprintf(Buffer,"П000010034003:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;
    dTransPF_DL(s0340_5,fsTmp); sprintf(Buffer,"П000010034005:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;
    dTransPF_DL(s0340_7,fsTmp); sprintf(Buffer,"П000010034007:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;
    dTransPF_DL(s0340_9,fsTmp); sprintf(Buffer,"П000010034009:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;

    // строка 0400
    dTransPF_DL(s0400_5,fsTmp); sprintf(Buffer,"П000010040005:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;
    dTransPF_DL(s0400_7,fsTmp); sprintf(Buffer,"П000010040007:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;
    dTransPF_DL(s0400_9,fsTmp); sprintf(Buffer,"П000010040009:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;

    // строка 0410
    dTransPF_DL(s0410_5,fsTmp); sprintf(Buffer,"П000010041005:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;
    dTransPF_DL(s0410_7,fsTmp); sprintf(Buffer,"П000010041007:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;
    dTransPF_DL(s0410_9,fsTmp); sprintf(Buffer,"П000010041009:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;

    // строка 0420
    dTransPF_DL(s0420_5,fsTmp); sprintf(Buffer,"П000010042005:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;
    dTransPF_DL(s0420_7,fsTmp); sprintf(Buffer,"П000010042007:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;
    dTransPF_DL(s0420_9,fsTmp); sprintf(Buffer,"П000010042009:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;

    // строка 0430
    dTransPF_DL(s0430_5,fsTmp); sprintf(Buffer,"П000010043005:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;
    dTransPF_DL(s0430_7,fsTmp); sprintf(Buffer,"П000010043007:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;
    dTransPF_DL(s0430_9,fsTmp); sprintf(Buffer,"П000010043009:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;

    // строка 0440
    dTransPF_DL(s0440_5,fsTmp); sprintf(Buffer,"П000010044005:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;
    dTransPF_DL(s0440_7,fsTmp); sprintf(Buffer,"П000010044007:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;
    dTransPF_DL(s0440_9,fsTmp); sprintf(Buffer,"П000010044009:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;
    if (FTrans_DL==1)
    {
      sprintf(Buffer,"###\r\n"); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0);
    }
    // <Раздел 1> end

    // <Раздел 2> begin
    // Таблица 4
    // Лист 6   Справочно
    // Строка 010
    dTransPF_DL(s010_3,fsTmp); sprintf(Buffer,"П000020001003:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;
    dTransPF_DL(s010_4,fsTmp); sprintf(Buffer,"П000020001004:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;
    dTransPF_DL(s010_5,fsTmp); sprintf(Buffer,"П000020001005:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;

    // Строка 011
    dTransPF_DL(s011_3,fsTmp); sprintf(Buffer,"П000020001103:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;
    dTransPF_DL(s011_4,fsTmp); sprintf(Buffer,"П000020001104:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;
    dTransPF_DL(s011_5,fsTmp); sprintf(Buffer,"П000020001105:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;

    // Строка 012
    dTransPF_DL(s012_3,fsTmp); sprintf(Buffer,"П000020001203:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;
    dTransPF_DL(s012_4,fsTmp); sprintf(Buffer,"П000020001204:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;
    dTransPF_DL(s012_5,fsTmp); sprintf(Buffer,"П000020001205:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;

    // Строка 013
    dTransPF_DL(s013_3,fsTmp); sprintf(Buffer,"П000020001303:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;
    dTransPF_DL(s013_4,fsTmp); sprintf(Buffer,"П000020001304:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;
    dTransPF_DL(s013_5,fsTmp); sprintf(Buffer,"П000020001305:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;

    // Строка 014
    dTransPF_DL(s014_3,fsTmp); sprintf(Buffer,"П000020001403:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;
    dTransPF_DL(s014_4,fsTmp); sprintf(Buffer,"П000020001404:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;
    dTransPF_DL(s014_5,fsTmp); sprintf(Buffer,"П000020001405:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;

    // Строка 015
    dTransPF_DL(s015_3,fsTmp); sprintf(Buffer,"П000020001503:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;
    dTransPF_DL(s015_4,fsTmp); sprintf(Buffer,"П000020001504:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;
    dTransPF_DL(s015_5,fsTmp); sprintf(Buffer,"П000020001505:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;
    if (FTrans_DL==1)
    {
      sprintf(Buffer,"###\r\n"); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0);
    }
    // <Раздел 2> end

    // <Раздел 3> begin
    // Таблица 5
    // Лист 6  Расчет для заполнения строк 0300 и 0400
    // Строка 0100
    dTransPF_DL(s100_3,fsTmp);  sprintf(Buffer,"П000030010003:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;
    if (FTrans_DL==1)
    {
      dTransPF_DL(P1T5,fsTmp);    sprintf(Buffer,"П000030010004:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;
    }
    dTransPF_DL(s100_5,fsTmp);  sprintf(Buffer,"П000030010005:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;
    iTransPF_DL(s100_6,fsTmp);  sprintf(Buffer,"П000030010006:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;
    dTransPF_DL(s100_7,fsTmp);  sprintf(Buffer,"П000030010007:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;
    if (FTrans_DL==1)
    {
      dTransPF_DL(P1T71,fsTmp);   sprintf(Buffer,"П000030010008:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;
    }
    dTransPF_DL(s100_9,fsTmp);  sprintf(Buffer,"П000030010009:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;
    if (FTrans_DL==1)
    {
      dTransPF_DL(P1T72,fsTmp);   sprintf(Buffer,"П000030010010:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;
    }
    dTransPF_DL(s100_11,fsTmp); sprintf(Buffer,"П000030010011:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;
    iTransPF_DL(s100_12,fsTmp); sprintf(Buffer,"П000030010012:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;
    dTransPF_DL(s100_13,fsTmp); sprintf(Buffer,"П000030010013:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;
    if (FTrans_DL==1)
    {
      dTransPF_DL(P1T91,fsTmp);   sprintf(Buffer,"П000030010014:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;
    }
    dTransPF_DL(s100_15,fsTmp); sprintf(Buffer,"П000030010015:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;
    if (FTrans_DL==1)
    {
      dTransPF_DL(P1T92,fsTmp);   sprintf(Buffer,"П000030010016:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;
    }
    dTransPF_DL(s100_17,fsTmp); sprintf(Buffer,"П000030010017:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;
    iTransPF_DL(s100_18,fsTmp); sprintf(Buffer,"П000030010018:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;

    // строка 0200
    dTransPF_DL(s200_3,fsTmp);  sprintf(Buffer,"П000030020003:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;
    dTransPF_DL(s200_5,fsTmp);  sprintf(Buffer,"П000030020005:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;
    iTransPF_DL(s200_6,fsTmp);  sprintf(Buffer,"П000030020006:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;
    dTransPF_DL(s200_7,fsTmp);  sprintf(Buffer,"П000030020007:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;
    dTransPF_DL(s200_9,fsTmp);  sprintf(Buffer,"П000030020009:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;
    dTransPF_DL(s200_11,fsTmp); sprintf(Buffer,"П000030020011:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;
    iTransPF_DL(s200_12,fsTmp); sprintf(Buffer,"П000030020012:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;
    dTransPF_DL(s200_13,fsTmp); sprintf(Buffer,"П000030020013:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;
    dTransPF_DL(s200_15,fsTmp); sprintf(Buffer,"П000030020015:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;
    dTransPF_DL(s200_17,fsTmp); sprintf(Buffer,"П000030020017:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;
    iTransPF_DL(s200_18,fsTmp); sprintf(Buffer,"П000030020018:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;

    // строка 0210
    dTransPF_DL(s210_3,fsTmp);  sprintf(Buffer,"П000030021003:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;
    if (FTrans_DL==1)
    {
      dTransPF_DL(P3T5,fsTmp);    sprintf(Buffer,"П000030021004:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;
    }
    dTransPF_DL(s210_5,fsTmp);  sprintf(Buffer,"П000030021005:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;
    dTransPF_DL(s210_7,fsTmp);  sprintf(Buffer,"П000030021007:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;
    if (FTrans_DL==1)
    {
      dTransPF_DL(P3T71,fsTmp);   sprintf(Buffer,"П000030021008:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;
    }
    dTransPF_DL(s210_9,fsTmp);  sprintf(Buffer,"П000030021009:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;
    if (FTrans_DL==1)
    {
      dTransPF_DL(P3T72,fsTmp);   sprintf(Buffer,"П000030021010:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;
    }
    dTransPF_DL(s210_11,fsTmp); sprintf(Buffer,"П000030021011:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;
    dTransPF_DL(s210_13,fsTmp); sprintf(Buffer,"П000030021013:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;
    if (FTrans_DL==1)
    {
      dTransPF_DL(P3T91,fsTmp);   sprintf(Buffer,"П000030021014:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;
    }
    dTransPF_DL(s210_15,fsTmp); sprintf(Buffer,"П000030021015:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;
    if (FTrans_DL==1)
    {
      dTransPF_DL(P3T92,fsTmp);   sprintf(Buffer,"П000030021016:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;
    }
    dTransPF_DL(s210_17,fsTmp); sprintf(Buffer,"П000030021017:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;

    // строка 0220
    dTransPF_DL(s220_3,fsTmp);  sprintf(Buffer,"П000030022003:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;
    if (FTrans_DL==1)
    {
      dTransPF_DL(P4T5,fsTmp);    sprintf(Buffer,"П000030022004:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;
    }
    dTransPF_DL(s220_5,fsTmp);  sprintf(Buffer,"П000030022005:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;
    dTransPF_DL(s220_7,fsTmp);  sprintf(Buffer,"П000030022007:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;
    if (FTrans_DL==1)
    {
      dTransPF_DL(P4T71,fsTmp);   sprintf(Buffer,"П000030022008:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;
    }
    dTransPF_DL(s220_9,fsTmp);  sprintf(Buffer,"П000030022009:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;
    if (FTrans_DL==1)
    {
      dTransPF_DL(P4T72,fsTmp);   sprintf(Buffer,"П000030022010:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;
    }
    dTransPF_DL(s220_11,fsTmp); sprintf(Buffer,"П000030022011:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;
    dTransPF_DL(s220_13,fsTmp); sprintf(Buffer,"П000030022013:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;
    if (FTrans_DL==1)
    {
      dTransPF_DL(P4T91,fsTmp);   sprintf(Buffer,"П000030022014:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;
    }
    dTransPF_DL(s220_15,fsTmp); sprintf(Buffer,"П000030022015:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;
    if (FTrans_DL==1)
    {
      dTransPF_DL(P4T92,fsTmp);   sprintf(Buffer,"П000030022016:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;
    }
    dTransPF_DL(s220_17,fsTmp); sprintf(Buffer,"П000030022017:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;

    // Строка 0300
    dTransPF_DL(s300_3,fsTmp);  sprintf(Buffer,"П000030030003:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;
    dTransPF_DL(s300_5,fsTmp);  sprintf(Buffer,"П000030030005:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;
    iTransPF_DL(s300_6,fsTmp);  sprintf(Buffer,"П000030030006:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;
    dTransPF_DL(s300_7,fsTmp);  sprintf(Buffer,"П000030030007:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;
    dTransPF_DL(s300_9,fsTmp);  sprintf(Buffer,"П000030030009:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;
    dTransPF_DL(s300_11,fsTmp); sprintf(Buffer,"П000030030011:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;
    iTransPF_DL(s300_12,fsTmp); sprintf(Buffer,"П000030030012:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;
    dTransPF_DL(s300_13,fsTmp); sprintf(Buffer,"П000030030013:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;
    dTransPF_DL(s300_15,fsTmp); sprintf(Buffer,"П000030030015:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;
    dTransPF_DL(s300_17,fsTmp); sprintf(Buffer,"П000030030017:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;
    iTransPF_DL(s300_18,fsTmp); sprintf(Buffer,"П000030030018:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;

    // Строка 0310
    dTransPF_DL(s310_3,fsTmp);  sprintf(Buffer,"П000030031003:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;
    if (FTrans_DL==1)
    {
      dTransPF_DL(P6T5,fsTmp);    sprintf(Buffer,"П000030031004:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;
    }
    dTransPF_DL(s310_5,fsTmp);  sprintf(Buffer,"П000030031005:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;
    iTransPF_DL("",fsTmp);      sprintf(Buffer,"П000030031006:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;
    dTransPF_DL(s310_7,fsTmp);  sprintf(Buffer,"П000030031007:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;
    if (FTrans_DL==1)
    {
      dTransPF_DL(P6T71,fsTmp);   sprintf(Buffer,"П000030031008:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;
    }
    dTransPF_DL(s310_9,fsTmp);  sprintf(Buffer,"П000030031009:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;
    if (FTrans_DL==1)
    {
      dTransPF_DL(P6T72,fsTmp);   sprintf(Buffer,"П000030031010:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;
    }
    dTransPF_DL(s310_11,fsTmp); sprintf(Buffer,"П000030031011:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;
    iTransPF_DL("",fsTmp);      sprintf(Buffer,"П000030031012:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;
    dTransPF_DL(s310_13,fsTmp); sprintf(Buffer,"П000030031013:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;
    if (FTrans_DL==1)
    {
      dTransPF_DL(P6T91,fsTmp);   sprintf(Buffer,"П000030031014:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;
    }
    dTransPF_DL(s310_15,fsTmp); sprintf(Buffer,"П000030031015:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;
    if (FTrans_DL==1)
    {
      dTransPF_DL(P6T92,fsTmp);   sprintf(Buffer,"П000030031016:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;
    }
    dTransPF_DL(s310_17,fsTmp); sprintf(Buffer,"П000030031017:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;
    iTransPF_DL("",fsTmp);      sprintf(Buffer,"П000030031018:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;

    // Строка 0320
    dTransPF_DL(s320_3,fsTmp);  sprintf(Buffer,"П000030032003:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;
    if (FTrans_DL==1)
    {
      dTransPF_DL(P7T5,fsTmp);    sprintf(Buffer,"П000030032004:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;
    }
    dTransPF_DL(s320_5,fsTmp);  sprintf(Buffer,"П000030032005:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;
    dTransPF_DL(s320_7,fsTmp);  sprintf(Buffer,"П000030032007:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;
    if (FTrans_DL==1)
    {
      dTransPF_DL(P7T71,fsTmp);   sprintf(Buffer,"П000030032008:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;
    }
    dTransPF_DL(s320_9,fsTmp);  sprintf(Buffer,"П000030032009:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;
    if (FTrans_DL==1)
    {
      dTransPF_DL(P7T72,fsTmp);   sprintf(Buffer,"П000030032010:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;
    }
    dTransPF_DL(s320_11,fsTmp); sprintf(Buffer,"П000030032011:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;
    dTransPF_DL(s320_13,fsTmp); sprintf(Buffer,"П000030032013:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;
    if (FTrans_DL==1)
    {
      dTransPF_DL(P7T91,fsTmp);   sprintf(Buffer,"П000030032014:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;
    }
    dTransPF_DL(s320_15,fsTmp); sprintf(Buffer,"П000030032015:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;
    if (FTrans_DL==1)
    {
      dTransPF_DL(P7T92,fsTmp);   sprintf(Buffer,"П000030032016:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;
    }
    dTransPF_DL(s320_17,fsTmp); sprintf(Buffer,"П000030032017:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;

    // Строка 0400
    dTransPF_DL(s400_3,fsTmp);  sprintf(Buffer,"П000030040003:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;
    if (FTrans_DL==1)
    {
      dTransPF_DL(P0T5,fsTmp);    sprintf(Buffer,"П000030040004:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;
    }
    dTransPF_DL(s400_5,fsTmp);  sprintf(Buffer,"П000030040005:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;
    iTransPF_DL(s400_6,fsTmp);  sprintf(Buffer,"П000030040006:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;
    dTransPF_DL(s400_7,fsTmp);  sprintf(Buffer,"П000030040007:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;
    if (FTrans_DL==1)
    {
      dTransPF_DL(P0T71,fsTmp);   sprintf(Buffer,"П000030040008:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;
    }
    dTransPF_DL(s400_9,fsTmp);  sprintf(Buffer,"П000030040009:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;
    if (FTrans_DL==1)
    {
      dTransPF_DL(P0T72,fsTmp);   sprintf(Buffer,"П000030040010:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;
    }
    dTransPF_DL(s400_11,fsTmp); sprintf(Buffer,"П000030040011:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;
    iTransPF_DL(s400_12,fsTmp); sprintf(Buffer,"П000030040012:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;
    dTransPF_DL(s400_13,fsTmp); sprintf(Buffer,"П000030040013:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;
    if (FTrans_DL==1)
    {
      dTransPF_DL(P0T91,fsTmp);   sprintf(Buffer,"П000030040014:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;
    }
    dTransPF_DL(s400_15,fsTmp); sprintf(Buffer,"П000030040015:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;
    if (FTrans_DL==1)
    {
      dTransPF_DL(P0T92,fsTmp);   sprintf(Buffer,"П000030040016:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;
    }
    dTransPF_DL(s400_17,fsTmp); sprintf(Buffer,"П000030040017:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;
    iTransPF_DL(s400_18,fsTmp); sprintf(Buffer,"П000030040018:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;

    // Строка 0500
    dTransPF_DL(s500_3,fsTmp);  sprintf(Buffer,"П000030050003:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;
    dTransPF_DL(s500_5,fsTmp);  sprintf(Buffer,"П000030050005:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;
    iTransPF_DL(s500_6,fsTmp);  sprintf(Buffer,"П000030050006:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;
    dTransPF_DL(s500_7,fsTmp);  sprintf(Buffer,"П000030050007:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;
    dTransPF_DL(s500_9,fsTmp);  sprintf(Buffer,"П000030050009:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;
//    if (FTrans_DL==1)
//    {
//      dTransPF_DL("",fsTmp);      sprintf(Buffer,"П000030050010:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;
//    }
    dTransPF_DL(s500_11,fsTmp); sprintf(Buffer,"П000030050011:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;
    iTransPF_DL(s500_12,fsTmp); sprintf(Buffer,"П000030050012:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;
    dTransPF_DL(s500_13,fsTmp); sprintf(Buffer,"П000030050013:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;
    dTransPF_DL(s500_15,fsTmp); sprintf(Buffer,"П000030050015:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;
//    if (FTrans_DL==1)
//    {
//      dTransPF_DL("",fsTmp);      sprintf(Buffer,"П000030050016:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;
//    }
    dTransPF_DL(s500_17,fsTmp); sprintf(Buffer,"П000030050017:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;
    iTransPF_DL(s500_18,fsTmp); sprintf(Buffer,"П000030050018:%s\r\n",fsTmp); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0); KolPokFOtch++;

    // <Раздел 3> end
    // <содержание формы> end
    // <форма отчетности> end
  }

  // TRANSFER }

  int pl=CFile_DL.GetPortLand();

  if (EXCEL==0)   {
  if (LIST[1]==1) {

  sprintf(str,"                                                                                                        Приложение № 1             ");   prntPF_DL(str,1,0);
  sprintf(str,"                                                                                                        к приказу МНС России       ");   prntPF_DL(str,1,0);
  sprintf(str,"                                                                                                        от 28.03.02 № БГ-3-05/153  ");   prntPF_DL(str,1,0);
  sprintf(str,"                                                                                                                   ┌─┬─┬─┬─┬─┬─┬─┐ ");   prntPF_DL(str,1,0);
  sprintf(str,"                                                                                                    Форма по КНД   │1│1│5│1│0│5│8│ ");   prntPF_DL(str,1,0);
  sprintf(str,"                                                                                                                   └─┴─┴─┴─┴─┴─┴─┘ ");   prntPF_DL(str,1,0);
  sprintf(str," ┌────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐");   prntPF_DL(str,1,0);
  sprintf(str," │     РАСЧЕТ ПО АВАНСОВЫМ ПЛАТЕЖАМ ПО СТРАХОВЫМ ВЗНОСАМ НА ОБЯЗАТЕЛЬНОЕ ПЕНСИОННОЕ СТРАХОВАНИЕ ДЛЯ ЛИЦ, ПРОИЗВОДЯЩИХ ВЫПЛАТЫ     │");   prntPF_DL(str,1,0);
  sprintf(str," │                        ФИЗИЧЕСКИМ ЛИЦАМ: ОРГАНИЗАЦИЙ; ИНДИВИДУАЛЬНЫХ ПРЕДПРИНИМАТЕЛЕЙ; ФИЗИЧЕСКИХ ЛИЦ,                         │");   prntPF_DL(str,1,0);
  sprintf(str," │                                       НЕ ПРИЗНАВАЕМЫХ ИНДИВИДУАЛЬНЫМИ ПРЕДПРИНИМАТЕЛЯМИ                                        │");   prntPF_DL(str,1,0);
  sprintf(str," ├───────────────────────────────────────────────────────────────┬────────────────────────────────────────────────────────────────┤");   prntPF_DL(str,1,0);
  sprintf(str," │                за %-20.20s20%c%c г.                 │     представляется не позднее 20 числа месяца, следующего      │"          , MesPer1, edat[5], edat[6]); prntPF_DL(str,1,0);
  sprintf(str," │  (указывается период, за который  представляется расчет)      │                за отчетным периодом                            │");   prntPF_DL(str,1,0);
  sprintf(str," ├───────────────────────────────────────────────────────────────┴─────────────────────────────────────────────────┬──┬──┬──┬──┬──┤");   prntPF_DL(str,1,0);
  sprintf(str," │Представляется в %-60.60s                                    │ %c│ %c│ %c│ %c│  │"                                 , Nni, Cni[0], Cni[1], Cni[2], Cni[3]); prntPF_DL(str,1,0);
  sprintf(str," │                ________________________________________________________________________________________________ └──┴──┴──┴──┘  │");   prntPF_DL(str,1,0);
  sprintf(str," │                                     (наименование налогового органа и его код)                                                 │");   prntPF_DL(str,1,0);
  sprintf(str," │                                        ┌───┐                        ┌───┐                       ┌───┐                          │");   prntPF_DL(str,1,0);
  sprintf(str," │по месту нахождения (жительства):       │ %s │                        │ %s │                       │ %s │                          │", vOrg[0], vOrg[1], vOrg[3]);   prntPF_DL(str,1,0);
  sprintf(str," │                                        └───┘                        └───┘                       └───┘                          │");   prntPF_DL(str,1,0);
  sprintf(str," │                                      российской          обособленного подразделения         физического                       │");   prntPF_DL(str,1,0);
  sprintf(str," │                                      организации           российской организации               лица                           │");   prntPF_DL(str,1,0);
  sprintf(str," │ по месту осуществления деятельности                ┌───┐                          ┌───┐                                        │");   prntPF_DL(str,1,0);
  sprintf(str," │                                                    │ %s │                          │   │                                        │", vOrg[2]);   prntPF_DL(str,1,0);
  sprintf(str," │                                                    └───┘                          └───┘                                        │");   prntPF_DL(str,1,0);
  sprintf(str," │ иностранной организации  через:           отделение иностранной             иную организацию                                   │");   prntPF_DL(str,1,0);
  sprintf(str," │                                                организации                                                                     │");   prntPF_DL(str,1,0);
  sprintf(str," │                                                         ( нужное отметить знаком V)                                            │");   prntPF_DL(str,1,0);
  sprintf(str," ├────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤");   prntPF_DL(str,1,0);
  sprintf(str," ├────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤");   prntPF_DL(str,1,0);
  sprintf(str," │ %-126.126s │"                                                                                                                   , RTrim(Org)); prntPF_DL(str,1,0);
  sprintf(str," │─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── │");   prntPF_DL(str,1,0);
  sprintf(str," │                            Полное наименование организации /Фамилия, имя, отчество физического лица                            │");   prntPF_DL(str,1,0);
  sprintf(str," ├────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤");   prntPF_DL(str,1,0);
  sprintf(str," ├─────────────────────────────┬─┬─┬──┬─┬─┬─┬─┬─┬─┬─┬─────────────────────────────────────────────────────────────────────────────┤");   prntPF_DL(str,1,0);
  if (ORG==3) {
  sprintf(str," │       ИНН организации       │ │ │  │ │ │ │ │ │ │ │                                                                             │");   prntPF_DL(str,1,0);
  }
  else {
  sprintf(str," │       ИНН организации       │%c│%c│ %c│%c│%c│%c│%c│%c│%c│%c│                                                                             │", Inn[0], Inn[1], Inn[2], Inn[3], Inn[4], Inn[5], Inn[6], Inn[7], Inn[8], Inn[9]); prntPF_DL(str,1,0);
  }
  sprintf(str," │                             └─┴─┴──┴─┴─┴─┴─┴─┴─┴─┘                                                                             │");   prntPF_DL(str,1,0);
  sprintf(str," │                ┌─┬─┬─┬─┬─┬─┬─┬─┬─┐ ┌──┬─┬─┬─┬─┬─┬─┬─┬─┐                                                                        │");   prntPF_DL(str,1,0);
  if (ORG==3) {
  sprintf(str," │       КПП по   │ │ │ │ │ │ │ │ │ │ │  │ │ │ │ │ │ │ │ │                                                                        │");   prntPF_DL(str,1,0);
  }
  else {                                                                                                                                                                                                                                                                    
  sprintf(str," │       КПП по   │%c│%c│%c│%c│%c│%c│%c│%c│%c│ │ %c│%c│%c│%c│%c│%c│%c│%c│%c│                                                                        │", Kpp[0], Kpp[1], Kpp[2], Kpp[3], Kpp[4], Kpp[5], Kpp[6], Kpp[7], Kpp[8], Kop[0], Kop[1], Kop[2], Kop[3], Kop[4], Kop[5], Kop[6], Kop[7], Kop[8]); prntPF_DL(str,1,0);
  }
  sprintf(str," │                └─┴─┴─┴─┴─┴─┴─┴─┴─┘ └──┴─┴─┴─┴─┴─┴─┴─┴─┘                                                                        │");   prntPF_DL(str,1,0);
  sprintf(str," │месту нахождения     организации     обособленного подразделения                                                                │");   prntPF_DL(str,1,0);

  if ( pl==0 ) {
  sprintf(str," ├────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤");   prntPF_DL(str,1,0);
  sprintf(str," ├─────────────────────┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬──────────────────────────────────────────────────────────────────────────────────┤");   prntPF_DL(str,1,0);
  }

  if ( pl==1 ) {
  sprintf(str," └────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘");   prntPF_DL(str,1,0);
  CFile_DL.ListFeed();
  sprintf(str," ┌─────────────────────┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬──────────────────────────────────────────────────────────────────────────────────┐");   prntPF_DL(str,1,0);
  }

  if (ORG==3) {
  sprintf(str," │ИНН физического лица │%c│%c│%c│%c│%c│%c│%c│%c│%c│%c│%c│%c│                                                                                  │", Inn[0], Inn[1], Inn[2], Inn[3], Inn[4], Inn[5], Inn[6], Inn[7], Inn[8], Inn[9], Inn[10], Inn[11]);   prntPF_DL(str,1,0);
  }
  else {
  sprintf(str," │ИНН физического лица │ │ │ │ │ │ │ │ │ │ │ │ │                                                                                  │");   prntPF_DL(str,1,0);
  }
  sprintf(str," ├─────────────────────┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴──────────────────────────────────────────────────────────────────────────────────┤");   prntPF_DL(str,1,0);
  sprintf(str," ├────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤");   prntPF_DL(str,1,0);
  sprintf(str," │ Регистрационный номер ПФР  %-14.14s                                                                                      │", Pen);   prntPF_DL(str,1,0);

  if ( pl==0 ) {
  sprintf(str," └────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘");   prntPF_DL(str,1,0);
  CFile_DL.ListFeed();
  sprintf(str," ┌─────────────────────────────┬─┬─┬──────────────────────────────────────────────────────────────────────────────────────────────┐");   prntPF_DL(str,1,0);
  }

  if ( pl==1 ) {
  sprintf(str," ├────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤");   prntPF_DL(str,1,0);
  sprintf(str," ├─────────────────────────────┬─┬─┬──────────────────────────────────────────────────────────────────────────────────────────────┤");   prntPF_DL(str,1,0);
  }

  sprintf(str," │Данный расчет составлен на   │ │ │ страницах                                                                                    │");   prntPF_DL(str,1,0);
  sprintf(str," │                             └─┴─┘                                                                                              │");   prntPF_DL(str,1,0);
  sprintf(str," │Достоверность и полноту сведений, указанных в настоящем расчете, подтверждаю:                                                   │");   prntPF_DL(str,1,0);
  sprintf(str," │Для организации                                                                                                                 │");   prntPF_DL(str,1,0);
  sprintf(str," │Руководитель: %-59.59s                                                       │"                                                  , RTrim(Ruk)); prntPF_DL(str,1,0);
  sprintf(str," │         ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────│");   prntPF_DL(str,1,0);
  sprintf(str," │                              Фамилия, Имя, Отчество (полностью)                                                                │");   prntPF_DL(str,1,0);
  sprintf(str," │     ┌─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┐                                                                    ┌─┬─┐ ┌─┬─┐ ┌─┬─┬─┬─┐         │");   prntPF_DL(str,1,0);
  sprintf(str," │ИНН  │%c│%c│%c│%c│%c│%c│%c│%c│%c│%c│%c│%c│                 Подпись                                       Дата │%c│%c│ │%c│%c│ │%c│%c│%c│%c│         │", Iru[0], Iru[1], Iru[2], Iru[3], Iru[4], Iru[5], Iru[6], Iru[7], Iru[8], Iru[9], Iru[10], Iru[11], StrDate[0], StrDate[1], StrDate[3], StrDate[4], StrDate[6], StrDate[7], StrDate[8], StrDate[9]); prntPF_DL(str,1,0);
  sprintf(str," │     └─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┘                          ────────────                              └─┴─┘ └─┴─┘ └─┴─┴─┴─┘         │");   prntPF_DL(str,1,0);
  sprintf(str," │Главный бухгалтер:   %-59.59s                                                │"                                                  , RTrim(Glb)); prntPF_DL(str,1,0);
  sprintf(str," │                  ──────────────────────────────────────────────────────────────────────────────────────────────────────────────│");   prntPF_DL(str,1,0);
  sprintf(str," │                              Фамилия, Имя, Отчество (полностью)                                                                │");   prntPF_DL(str,1,0);
  sprintf(str," │     ┌─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┐                                                                    ┌─┬─┐ ┌─┬─┐ ┌─┬─┬─┬─┐         │");   prntPF_DL(str,1,0);
  sprintf(str," │ИНН  │%c│%c│%c│%c│%c│%c│%c│%c│%c│%c│%c│%c│                 Подпись                                       Дата │%c│%c│ │%c│%c│ │%c│%c│%c│%c│         │", Igl[0], Igl[1], Igl[2], Igl[3], Igl[4], Igl[5], Igl[6], Igl[7], Igl[8], Igl[9], Igl[10], Igl[11], StrDate[0], StrDate[1], StrDate[3], StrDate[4], StrDate[6], StrDate[7], StrDate[8], StrDate[9]); prntPF_DL(str,1,0);
  sprintf(str," │     └─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┘                          ────────────                              └─┴─┘ └─┴─┘ └─┴─┴─┴─┘         │");   prntPF_DL(str,1,0);
  sprintf(str," │Представитель:                                                                                                                  │");   prntPF_DL(str,1,0);
  sprintf(str," │              ──────────────────────────────────────────────────────────────────────────────────────────────────────────────────│");   prntPF_DL(str,1,0);
  sprintf(str," │                              Фамилия, Имя, Отчество (полностью)                                                                │");   prntPF_DL(str,1,0);
  sprintf(str," │     ┌─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┐                                                                    ┌─┬─┐ ┌─┬─┐ ┌─┬─┬─┬─┐         │");   prntPF_DL(str,1,0);
  sprintf(str," │ИНН  │ │ │ │ │ │ │ │ │ │ │ │ │                 Подпись                                       Дата │%c│%c│ │%c│%c│ │%c│%c│%c│%c│         │", StrDate[0], StrDate[1], StrDate[3], StrDate[4], StrDate[6], StrDate[7], StrDate[8], StrDate[9]); prntPF_DL(str,1,0);
  sprintf(str," │     └─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┘                          ────────────                              └─┴─┘ └─┴─┘ └─┴─┴─┴─┘         │");   prntPF_DL(str,1,0);
  sprintf(str," │                                     М П                                                                                        │");   prntPF_DL(str,1,0);
  sprintf(str," │                                                                                                  ┌─┬─┐ ┌─┬─┐ ┌─┬─┬─┬─┐         │");   prntPF_DL(str,1,0);
  sprintf(str," │Для физического лица                           Подпись                                       Дата │%c│%c│ │%c│%c│ │%c│%c│%c│%c│         │", StrDate[0], StrDate[1], StrDate[3], StrDate[4], StrDate[6], StrDate[7], StrDate[8], StrDate[9]); prntPF_DL(str,1,0);
  sprintf(str," │                                                        ____________                              └─┴─┘ └─┴─┘ └─┴─┴─┴─┘         │");   prntPF_DL(str,1,0);
  sprintf(str," │Представитель:                                                                                                                  │");   prntPF_DL(str,1,0);
  sprintf(str," │              ──────────────────────────────────────────────────────────────────────────────────────────────────────────────────│");   prntPF_DL(str,1,0);
  sprintf(str," │                              Фамилия, Имя, Отчество (полностью)                                                                │");   prntPF_DL(str,1,0);
  sprintf(str," │                                                                                                  ┌─┬─┐ ┌─┬─┐ ┌─┬─┬─┬─┐         │");   prntPF_DL(str,1,0);
  sprintf(str," │                                               Подпись                                       Дата │%c│%c│ │%c│%c│ │%c│%c│%c│%c│         │", StrDate[0], StrDate[1], StrDate[3], StrDate[4], StrDate[6], StrDate[7], StrDate[8], StrDate[9]); prntPF_DL(str,1,0);
  sprintf(str," │                                                        ────────────                              └─┴─┘ └─┴─┘ └─┴─┴─┴─┘         │");   prntPF_DL(str,1,0);
  if ( pl==0 ) {
  sprintf(str," ├────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤");   prntPF_DL(str,1,0);
  }
  if ( pl==1 ) {
  sprintf(str," └────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘");   prntPF_DL(str,1,0);
  CFile_DL.ListFeed();
  sprintf(str," ┌────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐");   prntPF_DL(str,1,0);
  }
  sprintf(str," │                                            Заполняется работником налогового органа                                            │");   prntPF_DL(str,1,0);
  sprintf(str," ├─────────────────────────────────────────────────────────────────────────┬──────────────────────────────────────────────────────┤");   prntPF_DL(str,1,0);
  sprintf(str," │           Сведения о представлении расчета                              │       Сведения о проведении камеральной проверки     │");   prntPF_DL(str,1,0);
  sprintf(str," ├─────────────────────────────────────────────────────────────────────────┼──────────────────────────────────────────────────────┤");   prntPF_DL(str,1,0);
  sprintf(str," │Данный расчет представлен  (нужное отметить знаком V)                    │ Камеральная проверка проведена                       │");   prntPF_DL(str,1,0);
  sprintf(str," │      ┌─┐           ┌─┐                            ┌─┐                   │        ┌─┬─┐ ┌──┬─┐ ┌─┬──┬─┬─┐                       │");   prntPF_DL(str,1,0);
  sprintf(str," │лично │ │  по почте │ │     представителем         │ │                   │   Дата │ │ │ │  │ │ │ │  │ │ │                       │");   prntPF_DL(str,1,0);
  sprintf(str," │      └─┘           └─┘                            └─┘                   │        └─┴─┘ └──┴─┘ └─┴──┴─┴─┘                       │");   prntPF_DL(str,1,0);
  sprintf(str," │   ┌─┬─┐                                                                 │                                                      │");   prntPF_DL(str,1,0);
  sprintf(str," │на │ │ │страницах                                                        │                                                      │");   prntPF_DL(str,1,0);
  sprintf(str," │   └─┴─┘                                                                 │                                                      │");   prntPF_DL(str,1,0);
  sprintf(str," │                   ┌─┬─┐  ┌─┬─┐  ┌─┬─┬─┬─┐                               │                                                      │");   prntPF_DL(str,1,0);
  sprintf(str," │Дата представления │ │ │  │ │ │  │ │ │ │ │                               │                                                      │");   prntPF_DL(str,1,0);
  sprintf(str," │расчета            └─┴─┘  └─┴─┘  └─┴─┴─┴─┘                               │                                                      │");   prntPF_DL(str,1,0);
  sprintf(str," │Зарегистрирован за N                                                     │                                                      │");   prntPF_DL(str,1,0);
  sprintf(str," │               ──────────────────────────────────────────────────────────┤                                                      │");   prntPF_DL(str,1,0);
  sprintf(str," │                                                                         │                                                      │");   prntPF_DL(str,1,0);
  sprintf(str," ├───────────────              ────────────────────────────────────────────┼────────────────────────────────   ───────────────────┤");   prntPF_DL(str,1,0);
  sprintf(str," │Фамилия, И.О.                 Подпись                                    │ Фамилия, И.О.                        Подпись         │");   prntPF_DL(str,1,0);
  sprintf(str," └─────────────────────────────────────────────────────────────────────────┴──────────────────────────────────────────────────────┘");   prntPF_DL(str,1,0);

  int LastList=LIST[2]+LIST[3]+LIST[4]+LIST[5]+LIST[5]+LIST[6]+LIST[7];
  if (LastList==0) { if (FLIST==1) { CFile_DL.ListFeed(); } } else { CFile_DL.ListFeed(); }

  } // end if LIST[1]

  if (LIST[2]==1) {

  char N_STR[10]; if (NL_DL==1) { nlist_DL++; sprintf(N_STR,"%2d",nlist_DL); } else { sprintf(N_STR,"%2s","  "); }

  if (ORG==0 || ORG==1) {
    char ts[40]; 
    sprintf(ts,"%c",adr_ind[0]);    ai0=ts;
    sprintf(ts,"%c",adr_ind[1]);    ai1=ts;                         
    sprintf(ts,"%c",adr_ind[2]);    ai2=ts;                         
    sprintf(ts,"%c",adr_ind[3]);    ai3=ts;                         
    sprintf(ts,"%c",adr_ind[4]);    ai4=ts;                         
    sprintf(ts,"%c",adr_ind[5]);    ai5=ts;   
    sprintf(ts,"%-22.22s",adr_reg); aReg=ts;
    sprintf(ts,"%c",KodReg[0]);     aKodReg0=ts;
    sprintf(ts,"%c",KodReg[1]);     aKodReg1=ts;
    sprintf(ts,"%-30.30s",adr_rai); aRai=ts;
    sprintf(ts,"%-30.30s",adr_gor); aGor=ts;
    sprintf(ts,"%-30.30s",adr_nas); aNas=ts;
    sprintf(ts,"%-30.30s",adr_str); aStr=ts;
    sprintf(ts,"%-30.30s",adr_dom); aDom=ts;
    sprintf(ts,"%-30.30s",adr_kor); aKor=ts;
    sprintf(ts,"%-30.30s",adr_kva); aKva=ts;
    sprintf(ts,"%-25.25s",Tel);     aTel=ts; if (ORG==1) aTel=" ";
  } 
  else {
    ai0=ai1=ai2=ai3=ai4=ai5=aReg=aKodReg0=aKodReg1=" ";
    aRai=aGor=aNas=aStr=aDom=aKor=aKva=aTel=" "; 
  }

  if (ADR==1 && (ORG==0 || ORG==1)) {
    char ts[40]; 
    sprintf(ts,"%c",adf_ind[0]);     afi0=ts;
    sprintf(ts,"%c",adf_ind[1]);     afi1=ts;                         
    sprintf(ts,"%c",adf_ind[2]);     afi2=ts;                         
    sprintf(ts,"%c",adf_ind[3]);     afi3=ts;                         
    sprintf(ts,"%c",adf_ind[4]);     afi4=ts;                         
    sprintf(ts,"%c",adf_ind[5]);     afi5=ts;   
    sprintf(ts,"%-22.22s",adf_reg);  afReg=ts;
    sprintf(ts,"%c",fKodReg[0]);     afKodReg0=ts;
    sprintf(ts,"%c",fKodReg[1]);     afKodReg1=ts;
    sprintf(ts,"%-30.30s",adf_rai);  afRai=ts;
    sprintf(ts,"%-30.30s",adf_gor);  afGor=ts;
    sprintf(ts,"%-30.30s",adf_nas);  afNas=ts;
    sprintf(ts,"%-30.30s",adf_str);  afStr=ts;
    sprintf(ts,"%-30.30s",adf_dom);  afDom=ts;
    sprintf(ts,"%-30.30s",adf_kor);  afKor=ts;
    sprintf(ts,"%-30.30s",adf_kva);  afKva=ts;
  }
  else {
    afi0=afi1=afi2=afi3=afi4=afi5=afReg=afKodReg0=afKodReg1=" ";
    afRai=afGor=afNas=afStr=afDom=afKor=afKva=" "; 
  }

  sprintf(str,"                                                                                                                          ┌──┬──┐ ");   prntPF_DL(str,1,0);
  sprintf(str,"                                                                                                                    Лист  │ 0│ 2│ ");   prntPF_DL(str,1,0);
  sprintf(str,"                                                                                                                          └──┴──┘ ");   prntPF_DL(str,1,0);
  sprintf(str,"                                                                                                                          ┌──┬──┐ ");   prntPF_DL(str,1,0);
  sprintf(str,"                                                                                                               Страница N │ %c│ %c│ ", N_STR[0], N_STR[1]);   prntPF_DL(str,1,0);
  sprintf(str,"                                                                                                                          └──┴──┘ ");   prntPF_DL(str,1,0);
  sprintf(str,"                                                                                                                  ┌─┬─┬─┬─┬─┬─┬─┐ ");   prntPF_DL(str,1,0);
  sprintf(str,"                                                                                                    Форма по КНД  │1│1│5│1│0│5│8│ ");   prntPF_DL(str,1,0);
  sprintf(str,"                                                                                                                  └─┴─┴─┴─┴─┴─┴─┘ ");   prntPF_DL(str,1,0);
  sprintf(str," Сведения о налогоплательщике:                                                                                                    ");   prntPF_DL(str,1,0);
  sprintf(str," I. Российские организации                                                                                                        ");   prntPF_DL(str,1,0);
  sprintf(str," Адрес, указанный в учредительных документах:                                                                                     ");   prntPF_DL(str,1,0);
  sprintf(str," ┌─────────────────────────────────────────┬─┬─┬─┬─┬─┬─┬─────────────────────────────────────────────────────────────────────────┐");   prntPF_DL(str,1,0);
  sprintf(str," │Почтовый индекс                          │%s│%s│%s│%s│%s│%s│                                                                         │", ai0, ai1, ai2, ai3, ai4, ai5); prntPF_DL(str,1,0);
  sprintf(str," ├─────────────────────────────────────────┼─┴─┴─┴─┴─┴─┴────────────────────────────────────────────────────────────────────┬─┬──┤");   prntPF_DL(str,1,0);
  sprintf(str," │Субъект Российской Федерации             │ %-22.22s                                                      Код│%s│ %s│"           , aReg, aKodReg0, aKodReg1); prntPF_DL(str,1,0);
  sprintf(str," ├─────────────────────────────────────────┼────────────────────────────────────────────────────────────────────────────────┴─┴──┤");   prntPF_DL(str,1,0);
  sprintf(str," │Район                                    │ %-30.30s                                                      │"                     , aRai); prntPF_DL(str,1,0);
  sprintf(str," ├─────────────────────────────────────────┼─────────────────────────────────────────────────────────────────────────────────────┤");   prntPF_DL(str,1,0);
  sprintf(str," │Город                                    │ %-30.30s                                                      │"                     , aGor); prntPF_DL(str,1,0);
  sprintf(str," ├─────────────────────────────────────────┼─────────────────────────────────────────────────────────────────────────────────────┤");   prntPF_DL(str,1,0);
  sprintf(str," │Населенный пункт (село, поселок и т.д.)  │ %-30.30s                                                      │"                     , aNas); prntPF_DL(str,1,0);
  sprintf(str," ├─────────────────────────────────────────┼─────────────────────────────────────────────────────────────────────────────────────┤");   prntPF_DL(str,1,0);
  sprintf(str," │Улица (проспект, переулок и т.д.)        │ %-30.30s                                                      │"                     , aStr); prntPF_DL(str,1,0);
  sprintf(str," ├─────────────────────────────────────────┼─────────────────────────────────────────────────────────────────────────────────────┤");   prntPF_DL(str,1,0);
  sprintf(str," │Номер дома (владения)                    │ %-30.30s                                                      │"                     , aDom); prntPF_DL(str,1,0);
  sprintf(str," ├─────────────────────────────────────────┼─────────────────────────────────────────────────────────────────────────────────────┤");   prntPF_DL(str,1,0);
  sprintf(str," │Номер корпуса (строения)                 │ %-30.30s                                                      │"                     , aKor); prntPF_DL(str,1,0);
  sprintf(str," ├─────────────────────────────────────────┼─────────────────────────────────────────────────────────────────────────────────────┤");   prntPF_DL(str,1,0);
  sprintf(str," │Номер квартиры (офиса)                   │ %-30.30s                                                      │"                     , aKva); prntPF_DL(str,1,0);
  sprintf(str," ├─────────────────────────────────────────┴─────────────────────────────────────────────────────────────────────────────────────┤");   prntPF_DL(str,1,0);
  sprintf(str," │Контактный телефон: Руководителя %-25.25s  Гл. бухгалтера                                                     │"                , aTel); prntPF_DL(str,1,0);
  sprintf(str," └───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘");   prntPF_DL(str,1,0);
  sprintf(str,"  Адрес, указанный в учредительных                 ┌─┐              ┌─┐                                                           ");   prntPF_DL(str,1,0);
  if ((ORG==0 || ORG==1) && ADR==0) {
  sprintf(str,"  документах и адрес постоянно действующего        │V│              │ │                                                           ");   prntPF_DL(str,1,0);
  }
  if ((ORG==0 || ORG==1) && ADR==1) {
  sprintf(str,"  документах и адрес постоянно действующего        │ │              │V│                                                           ");   prntPF_DL(str,1,0);
  }
  if (ORG!=0 && ORG!=1) {
  sprintf(str,"  документах и адрес постоянно действующего        │ │              │ │                                                           ");   prntPF_DL(str,1,0);
  }
  sprintf(str,"  исполнительного органа                           └─┘              └─┘                                                           ");   prntPF_DL(str,1,0);
  sprintf(str,"                                               совпадают     не совпадают                                                         ");   prntPF_DL(str,1,0);
  sprintf(str,"                                               (нужное отметить знаком V)                                                         ");   prntPF_DL(str,1,0);

  if ( pl==1 ) {
  CFile_DL.ListFeed();

  char N_STR[10]; if (NL_DL==1) { nlist_DL++; sprintf(N_STR,"%2d",nlist_DL); } else { sprintf(N_STR,"%2s","  "); }

  sprintf(str,"                                                                                                                          ┌──┬──┐ ");   prntPF_DL(str,1,0);
  sprintf(str,"                                                                                                                    Лист  │ 0│ 2│ ");   prntPF_DL(str,1,0);
  sprintf(str,"                                                                                                                          └──┴──┘ ");   prntPF_DL(str,1,0);
  sprintf(str,"                                                                                                                          ┌──┬──┐ ");   prntPF_DL(str,1,0);
  sprintf(str,"                                                                                                               Страница N │ %c│ %c│ ", N_STR[0], N_STR[1]);   prntPF_DL(str,1,0);
  sprintf(str,"                                                                                                                          └──┴──┘ ");   prntPF_DL(str,1,0);
  sprintf(str,"                                                                                                                  ┌─┬─┬─┬─┬─┬─┬─┐ ");   prntPF_DL(str,1,0);
  sprintf(str,"                                                                                                    Форма по КНД  │1│1│5│1│0│5│8│ ");   prntPF_DL(str,1,0);
  sprintf(str,"                                                                                                                  └─┴─┴─┴─┴─┴─┴─┘ ");   prntPF_DL(str,1,0);
  }

  sprintf(str,"                                                                                                                                  ");   prntPF_DL(str,1,0);
  sprintf(str," В случае несовпадения указывается адрес постоянно действующего исполнительного органа:                                           ");   prntPF_DL(str,1,0);
  sprintf(str," ┌─────────────────────────────────────────┬─┬─┬─┬─┬─┬─┬─────────────────────────────────────────────────────────────────────────┐");   prntPF_DL(str,1,0);
  sprintf(str," │Почтовый индекс                          │%s│%s│%s│%s│%s│%s│                                                                         │", afi0, afi1, afi2, afi3, afi4, afi5);   prntPF_DL(str,1,0);
  sprintf(str," ├─────────────────────────────────────────┼─┴─┴─┴─┴─┴─┴────────────────────────────────────────────────────────────────────┬─┬──┤");   prntPF_DL(str,1,0);
  sprintf(str," │Субъект Российской Федерации             │%-22.22s                                                       Код│%s│ %s│"            , afReg, afKodReg0, afKodReg1);   prntPF_DL(str,1,0);
  sprintf(str," ├─────────────────────────────────────────┼────────────────────────────────────────────────────────────────────────────────┴─┴──┤");   prntPF_DL(str,1,0);
  sprintf(str," │Район                                    │%-30.30s                                                       │"                      , afRai);   prntPF_DL(str,1,0);
  sprintf(str," ├─────────────────────────────────────────┼─────────────────────────────────────────────────────────────────────────────────────┤");   prntPF_DL(str,1,0);
  sprintf(str," │Город                                    │%-30.30s                                                       │"                      , afGor);   prntPF_DL(str,1,0);
  sprintf(str," ├─────────────────────────────────────────┼─────────────────────────────────────────────────────────────────────────────────────┤");   prntPF_DL(str,1,0);
  sprintf(str," │Населенный пункт (село, поселок и т.д.)  │%-30.30s                                                       │"                      , afNas);   prntPF_DL(str,1,0);
  sprintf(str," ├─────────────────────────────────────────┼─────────────────────────────────────────────────────────────────────────────────────┤");   prntPF_DL(str,1,0);
  sprintf(str," │Улица (проспект, переулок и т.д.)        │%-30.30s                                                       │"                      , afStr);   prntPF_DL(str,1,0);
  sprintf(str," ├─────────────────────────────────────────┼─────────────────────────────────────────────────────────────────────────────────────┤");   prntPF_DL(str,1,0);
  sprintf(str," │Номер дома (владения)                    │%-30.30s                                                       │"                      , afDom);   prntPF_DL(str,1,0);
  sprintf(str," ├─────────────────────────────────────────┼─────────────────────────────────────────────────────────────────────────────────────┤");   prntPF_DL(str,1,0);
  sprintf(str," │Номер корпуса (строения)                 │%-30.30s                                                       │"                      , afKor);   prntPF_DL(str,1,0);
  sprintf(str," ├─────────────────────────────────────────┼─────────────────────────────────────────────────────────────────────────────────────┤");   prntPF_DL(str,1,0);
  sprintf(str," │Номер квартиры (офиса)                   │%-30.30s                                                       │"                      , afKva);   prntPF_DL(str,1,0);
  sprintf(str," ├─────────────────────────────────────────┴─────────────────────────────────────────────────────────────────────────────────────┤");   prntPF_DL(str,1,0);
  sprintf(str," │Контактный телефон: Руководителя _________________________  Гл. бухгалтера                                                     │");   prntPF_DL(str,1,0);
  sprintf(str," └───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘");   prntPF_DL(str,1,0);

  CFile_DL.ListFeed();

  if (KindPaper_DL) {
  char N_STR[10]; if (NL_DL==1) { nlist_DL++; sprintf(N_STR,"%2d",nlist_DL); } else { sprintf(N_STR,"%2s","  "); }
  sprintf(str,"                                                                                                                          ┌──┬──┐ ");   prntPF_DL(str,1,0);
  sprintf(str,"                                                                                                                    Лист  │ 0│ 2│ ");   prntPF_DL(str,1,0);
  sprintf(str,"                                                                                                                          └──┴──┘ ");   prntPF_DL(str,1,0);
  sprintf(str,"                                                                                                                          ┌──┬──┐ ");   prntPF_DL(str,1,0);
  sprintf(str,"                                                                                                               Страница N │ %c│ %c│ ", N_STR[0], N_STR[1]);   prntPF_DL(str,1,0);
  sprintf(str,"                                                                                                                          └──┴──┘ ");   prntPF_DL(str,1,0);
  sprintf(str,"                                                                                                                  ┌─┬─┬─┬─┬─┬─┬─┐ ");   prntPF_DL(str,1,0);
  sprintf(str,"                                                                                                    Форма по КНД  │1│1│5│1│0│5│8│ ");   prntPF_DL(str,1,0);
  sprintf(str,"                                                                                                                  └─┴─┴─┴─┴─┴─┴─┘ ");   prntPF_DL(str,1,0);
  }

  if (ORG==1) {
    char ts[40]; 
    sprintf(ts,"%c",ado_ind[0]);       ai0=ts;
    sprintf(ts,"%c",ado_ind[1]);       ai1=ts;                         
    sprintf(ts,"%c",ado_ind[2]);       ai2=ts;                         
    sprintf(ts,"%c",ado_ind[3]);       ai3=ts;                         
    sprintf(ts,"%c",ado_ind[4]);       ai4=ts;                         
    sprintf(ts,"%c",ado_ind[5]);       ai5=ts;   
    sprintf(ts,"%-22.22s",ado_reg);    aReg=ts;
    sprintf(ts,"%c",oKodReg[0]);       aKodReg0=ts;
    sprintf(ts,"%c",oKodReg[1]);       aKodReg1=ts;
    sprintf(ts,"%-30.30s",ado_rai);    aRai=ts;
    sprintf(ts,"%-30.30s",ado_gor);    aGor=ts;
    sprintf(ts,"%-30.30s",ado_nas);    aNas=ts;
    sprintf(ts,"%-30.30s",ado_str);    aStr=ts;
    sprintf(ts,"%-30.30s",ado_dom);    aDom=ts;
    sprintf(ts,"%-30.30s",ado_kor);    aKor=ts;
    sprintf(ts,"%-30.30s",ado_kva);    aKva=ts;
    sprintf(ts,"%-25.25s",Tel);        aTel=ts;
  } 
  else {
    ai0=ai1=ai2=ai3=ai4=ai5=aReg=aKodReg0=aKodReg1=" ";
    aRai=aGor=aNas=aStr=aDom=aKor=aKva=aTel=" "; 
  }


  sprintf(str," Адрес обособленного подразделения организации:                                                                                   ");   prntPF_DL(str,1,0);
  sprintf(str," ┌─────────────────────────────────────────┬─┬─┬─┬─┬─┬─┬─────────────────────────────────────────────────────────────────────────┐");   prntPF_DL(str,1,0);
  sprintf(str," │Почтовый индекс                          │%s│%s│%s│%s│%s│%s│                                                                         │", ai0, ai1, ai2, ai3, ai4, ai5); prntPF_DL(str,1,0);
  sprintf(str," ├─────────────────────────────────────────┼─┴─┴─┴─┴─┴─┴────────────────────────────────────────────────────────────────────┬─┬──┤");   prntPF_DL(str,1,0);
  sprintf(str," │Субъект Российской Федерации             │ %-22.22s                                                      Код│%s│ %s│"           , aReg, aKodReg0, aKodReg1); prntPF_DL(str,1,0);
  sprintf(str," ├─────────────────────────────────────────┼────────────────────────────────────────────────────────────────────────────────┴─┴──┤");   prntPF_DL(str,1,0);
  sprintf(str," │Район                                    │ %-30.30s                                                      │"                     , aRai); prntPF_DL(str,1,0);
  sprintf(str," ├─────────────────────────────────────────┼─────────────────────────────────────────────────────────────────────────────────────┤");   prntPF_DL(str,1,0);
  sprintf(str," │Город                                    │ %-30.30s                                                      │"                     , aGor); prntPF_DL(str,1,0);
  sprintf(str," ├─────────────────────────────────────────┼─────────────────────────────────────────────────────────────────────────────────────┤");   prntPF_DL(str,1,0);
  sprintf(str," │Населенный пункт (село, поселок и т.д.)  │ %-30.30s                                                      │"                     , aNas); prntPF_DL(str,1,0);
  sprintf(str," ├─────────────────────────────────────────┼─────────────────────────────────────────────────────────────────────────────────────┤");   prntPF_DL(str,1,0);
  sprintf(str," │Улица (проспект, переулок и т.д.)        │ %-30.30s                                                      │"                     , aStr); prntPF_DL(str,1,0);
  sprintf(str," ├─────────────────────────────────────────┼─────────────────────────────────────────────────────────────────────────────────────┤");   prntPF_DL(str,1,0);
  sprintf(str," │Номер дома (владения)                    │ %-30.30s                                                      │"                     , aDom); prntPF_DL(str,1,0);
  sprintf(str," ├─────────────────────────────────────────┼─────────────────────────────────────────────────────────────────────────────────────┤");   prntPF_DL(str,1,0);
  sprintf(str," │Номер корпуса (строения)                 │ %-30.30s                                                      │"                     , aKor); prntPF_DL(str,1,0);
  sprintf(str," ├─────────────────────────────────────────┼─────────────────────────────────────────────────────────────────────────────────────┤");   prntPF_DL(str,1,0);
  sprintf(str," │Номер квартиры (офиса)                   │ %-30.30s                                                      │"                     , aKva); prntPF_DL(str,1,0);
  sprintf(str," ├─────────────────────────────────────────┴─────────────────────────────────────────────────────────────────────────────────────┤");   prntPF_DL(str,1,0);
  sprintf(str," │Контактный телефон: Руководителя %-25.25s  Гл. бухгалтера                                                     │"                , aTel); prntPF_DL(str,1,0);
  sprintf(str," └───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘");   prntPF_DL(str,1,0);

  int LastList=LIST[3]+LIST[4]+LIST[5]+LIST[5]+LIST[6]+LIST[7];
  if (LastList==0) { if (FLIST==1) { CFile_DL.ListFeed(); } } else { CFile_DL.ListFeed(); }

  } // end if LIST[2]

  if (LIST[3]==1) {

  char N_STR[10]; if (NL_DL==1) { nlist_DL++; sprintf(N_STR,"%2d",nlist_DL); } else { sprintf(N_STR,"%2s","  "); }

  if (ORG==2) {
    char ts[101]; 
    sprintf(ts,"%c",adr_ind[0]);       ai0=ts;
    sprintf(ts,"%c",adr_ind[1]);       ai1=ts;                         
    sprintf(ts,"%c",adr_ind[2]);       ai2=ts;                         
    sprintf(ts,"%c",adr_ind[3]);       ai3=ts;                         
    sprintf(ts,"%c",adr_ind[4]);       ai4=ts;                         
    sprintf(ts,"%c",adr_ind[5]);       ai5=ts;   
    sprintf(ts,"%-22.22s",adr_reg);    aReg=ts;
    sprintf(ts,"%c",KodReg[0]);        aKodReg0=ts;
    sprintf(ts,"%c",KodReg[1]);        aKodReg1=ts;
    sprintf(ts,"%-30.30s",adr_rai);    aRai=ts;
    sprintf(ts,"%-30.30s",adr_gor);    aGor=ts;
    sprintf(ts,"%-30.30s",adr_nas);    aNas=ts;
    sprintf(ts,"%-30.30s",adr_str);    aStr=ts;
    sprintf(ts,"%-30.30s",adr_dom);    aDom=ts;
    sprintf(ts,"%-30.30s",adr_kor);    aKor=ts;
    sprintf(ts,"%-30.30s",adr_kva);    aKva=ts;
    sprintf(ts,"%-25.25s",Tel);        aTel=ts;
    sprintf(ts,"%-100.100s",Org);      aOrg=ts;
  } 
  else {
    ai0=ai1=ai2=ai3=ai4=ai5=aReg=aKodReg0=aKodReg1=" ";
    aRai=aGor=aNas=aStr=aDom=aKor=aKva=aTel=aOrg=" "; 
  }

  sprintf(str,"                                                                                                     ┌─┬─┐                  ┌─┬─┐  ");   prntPF_DL(str,1,0);
  sprintf(str,"                                                                                               Лист  │ │3│       Страница N │%c│%c│  ", N_STR[0], N_STR[1]);   prntPF_DL(str,1,0);
  sprintf(str,"                                                                                                     └─┴─┘                  └─┴─┘  ");   prntPF_DL(str,1,0);
  sprintf(str,"                                                                                                                  ┌─┬─┬─┬─┬─┬─┬─┐  ");   prntPF_DL(str,1,0);
  sprintf(str,"                                                                                                     Форма по КНД │1│1│5│1│0│5│8│  ");   prntPF_DL(str,1,0);
  sprintf(str," II. Иностранные организации                                                                                      └─┴─┴─┴─┴─┴─┴─┘  ");   prntPF_DL(str,1,0);
  sprintf(str," ──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────");   prntPF_DL(str,1,0);
  sprintf(str," Номер контактного телефона ________________________________                                                                       ");   prntPF_DL(str,1,0);
  sprintf(str," ┌───┬────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐");   prntPF_DL(str,1,0);
  sprintf(str," │ A │Полный адрес отделения в Российской Федерации                                                                               │");   prntPF_DL(str,1,0);
  sprintf(str," │   ├───────────────────────────────────┬─┬─┬─┬─┬─┬─┬────────────────────────────────────────────────────────────────────────────┤");   prntPF_DL(str,1,0);
  sprintf(str," │   │Почтовый индекс                    │%s│%s│%s│%s│%s│%s│                                                                            │", ai0, ai1, ai2, ai3, ai4, ai5);   prntPF_DL(str,1,0);
  sprintf(str," │   ├───────────────────────────────────┼─┴─┴─┴─┴─┴─┴──────────────────────────────────────────────────────────────────────┬──┬──┤");   prntPF_DL(str,1,0);
  sprintf(str," │   │Субъект Российской Федерации       │%-22.22s                                                         Код│ %s│ %s│"            , aReg, aKodReg0, aKodReg1);   prntPF_DL(str,1,0);
  sprintf(str," │   ├───────────────────────────────────┼──────────────────────────────────────────────────────────────────────────────────┴──┴──┤");   prntPF_DL(str,1,0);
  sprintf(str," │   │Район                              │%-30.30s                                                          │"                      , aRai);   prntPF_DL(str,1,0);
  sprintf(str," │   ├───────────────────────────────────┼────────────────────────────────────────────────────────────────────────────────────────┤");   prntPF_DL(str,1,0);
  sprintf(str," │   │Город                              │%-30.30s                                                          │"                      , aGor);   prntPF_DL(str,1,0);
  sprintf(str," │   ├───────────────────────────────────┼────────────────────────────────────────────────────────────────────────────────────────┤");   prntPF_DL(str,1,0);
  sprintf(str," │   │Населенный пункт (село, поселок и  │%-30.30s                                                          │"                      , aNas);   prntPF_DL(str,1,0);
  sprintf(str," │   │т.д.)                              │                                                                                        │");   prntPF_DL(str,1,0);
  sprintf(str," │   ├───────────────────────────────────┼────────────────────────────────────────────────────────────────────────────────────────┤");   prntPF_DL(str,1,0);
  sprintf(str," │   │Улица (проспект, переулок и т.д.)  │%-30.30s                                                          │"                      , aStr);   prntPF_DL(str,1,0);
  sprintf(str," │   ├───────────────────────────────────┼────────────────────────────────────────────────────────────────────────────────────────┤");   prntPF_DL(str,1,0);
  sprintf(str," │   │Номер дома (владения)              │%-30.30s                                                          │"                      , aDom);   prntPF_DL(str,1,0);
  sprintf(str," │   ├───────────────────────────────────┼────────────────────────────────────────────────────────────────────────────────────────┤");   prntPF_DL(str,1,0);
  sprintf(str," │   │Номер корпуса (строения)           │%-30.30s                                                          │"                      , aKor);   prntPF_DL(str,1,0);
  sprintf(str," │   ├───────────────────────────────────┼────────────────────────────────────────────────────────────────────────────────────────┤");   prntPF_DL(str,1,0);
  sprintf(str," │   │Номер квартиры (офиса)             │%-30.30s                                                          │"                      , aKva);   prntPF_DL(str,1,0);
  sprintf(str," ├───┼───────────────────────────────────┴────────────────────────────────────────────────────────────────────────────────────────┤");   prntPF_DL(str,1,0);
  sprintf(str," │ B │Код                 ┌─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─────────────────────────────────────────────────────┤");   prntPF_DL(str,1,0);
  sprintf(str," │   │налогоплательщика в │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │                                                     │");   prntPF_DL(str,1,0);
  sprintf(str," │   │стране регистрации  └─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─────────────────────────────────────────────────────┤");   prntPF_DL(str,1,0);
  sprintf(str," │   │или его аналог (если                                                                                                        │");   prntPF_DL(str,1,0);
  sprintf(str," │   │имеется)                                                                                                                    │");   prntPF_DL(str,1,0);
  sprintf(str," ├───┼────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤");   prntPF_DL(str,1,0);
  sprintf(str," │   │Наименование         ┌──────────────────────────────────────────────────────────────────────────────────────────────────────┤");   prntPF_DL(str,1,0);
  sprintf(str," │ С │иностранной          │ %-100.100s │"                                                                                          , aOrg);   prntPF_DL(str,1,0);
  sprintf(str," │   │организации          └──────────────────────────────────────────────────────────────────────────────────────────────────────┤");   prntPF_DL(str,1,0);
  sprintf(str," ├───┼────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤");   prntPF_DL(str,1,0);
  sprintf(str," │ D │Страна регистрации   ┌─────────────────────────┐             ┌─┬─┐                                                          │");   prntPF_DL(str,1,0);
  sprintf(str," │   │(инкорпорации)       │                         │ Код страны *│ │ │                                                          │");   prntPF_DL(str,1,0);
  sprintf(str," │   │                     └─────────────────────────┘             └─┴─┘                                                          │");   prntPF_DL(str,1,0);
  sprintf(str," ├───┼─────────────────────────────┬──────────────────────────────────────────────────────────────────────────────────────────────┤");   prntPF_DL(str,1,0);
  sprintf(str," │ Е │Адрес, указанный в           │                                                                                              │");   prntPF_DL(str,1,0);
  sprintf(str," │   │учредительных                │                                                                                              │");   prntPF_DL(str,1,0);
  sprintf(str," │   │документах иностранной       │                                                                                              │");   prntPF_DL(str,1,0);
  sprintf(str," │   │организации                  │                                                                                              │");   prntPF_DL(str,1,0);
  sprintf(str," └───┴─────────────────────────────┴──────────────────────────────────────────────────────────────────────────────────────────────┘");   prntPF_DL(str,1,0);
  sprintf(str," * ─ по справочнику \"BIC Directory\"                                                                                              ");   prntPF_DL(str,1,0);

  int LastList=LIST[5]+LIST[5]+LIST[6]+LIST[7];
  if (LastList==0) { if (FLIST==1) { CFile_DL.ListFeed(); } } else { CFile_DL.ListFeed(); }

  } // end if LIST[3]


  if (LIST[4]==1) {

  char N_STR[10]; if (NL_DL==1) { nlist_DL++; sprintf(N_STR,"%2d",nlist_DL); } else { sprintf(N_STR,"%2s","  "); }

  if (ORG==3) {
    char ts[101]; 
    sprintf(ts,"%c",adr_ind[0]);       ai0=ts;
    sprintf(ts,"%c",adr_ind[1]);       ai1=ts;                         
    sprintf(ts,"%c",adr_ind[2]);       ai2=ts;                         
    sprintf(ts,"%c",adr_ind[3]);       ai3=ts;                         
    sprintf(ts,"%c",adr_ind[4]);       ai4=ts;                         
    sprintf(ts,"%c",adr_ind[5]);       ai5=ts;   
    sprintf(ts,"%-22.22s",adr_reg);    aReg=ts;
    sprintf(ts,"%c",KodReg[0]);        aKodReg0=ts;
    sprintf(ts,"%c",KodReg[1]);        aKodReg1=ts;
    sprintf(ts,"%-30.30s",adr_rai);    aRai=ts;
    sprintf(ts,"%-30.30s",adr_gor);    aGor=ts;
    sprintf(ts,"%-30.30s",adr_nas);    aNas=ts;
    sprintf(ts,"%-30.30s",adr_str);    aStr=ts;
    sprintf(ts,"%-30.30s",adr_dom);    aDom=ts;
    sprintf(ts,"%-30.30s",adr_kor);    aKor=ts;
    sprintf(ts,"%-30.30s",adr_kva);    aKva=ts;
    sprintf(ts,"%-25.25s",Tel);        aTel=ts;
  } 
  else {
    ai0=ai1=ai2=ai3=ai4=ai5=aReg=aKodReg0=aKodReg1=" ";
    aRai=aGor=aNas=aStr=aDom=aKor=aKva=aTel=" "; 
  }

  sprintf(str,"                                                                                                                           ┌──┬──┐ ");   prntPF_DL(str,1,0);
  sprintf(str,"                                                                                                                     Лист  │ 0│ 4│ ");   prntPF_DL(str,1,0);
  sprintf(str,"                                                                                                                           └──┴──┘ ");   prntPF_DL(str,1,0);
  sprintf(str,"                                                                                                                           ┌──┬──┐ ");   prntPF_DL(str,1,0);
  sprintf(str,"                                                                                                                Страница N │ %c│ %c│ ", N_STR[0], N_STR[1]);   prntPF_DL(str,1,0);
  sprintf(str,"                                                                                                                           └──┴──┘ ");   prntPF_DL(str,1,0);
  sprintf(str,"                                                                                                                    ┌─┬─┬─┬─┬─┬─┬─┐");   prntPF_DL(str,1,0);
  sprintf(str,"                                                                                                       Форма по КНД │1│1│5│1│0│5│8│");   prntPF_DL(str,1,0);
  sprintf(str,"                                                                                                                    └─┴─┴─┴─┴─┴─┴─┘");   prntPF_DL(str,1,0);
  sprintf(str," III. Физические лица                                                                                                              ");   prntPF_DL(str,1,0);
  sprintf(str," Номер контактного телефона индивидуального предпринимателя (физического лица),                                                    ");   prntPF_DL(str,1,0);
  sprintf(str," выступающего в качестве работодателя: служебный ________________________ ; домашний____________________________                   ");   prntPF_DL(str,1,0);
  sprintf(str," ┌─────────────────────────────────────────┬──────────────────────────────────────────────────────────────────────────────────────┐");   prntPF_DL(str,1,0);
  sprintf(str," │Дата рождения                            │                                                                                      │");   prntPF_DL(str,1,0);
  sprintf(str," ├─────────────────────────────────────────┼──────────────────────────────────────────────────────────────────────────────────────┤");   prntPF_DL(str,1,0);
  sprintf(str," │Место рождения                           │                                                                                      │");   prntPF_DL(str,1,0);
  sprintf(str," ├─────────────────────────────────────────┼──────────────────────────────────────────────────────────────────────────────────────┤");   prntPF_DL(str,1,0);
  sprintf(str," │Пол:                                     │      ┌─┐      ┌─┐ (нужное                                                            │");   prntPF_DL(str,1,0);
  sprintf(str," │                                         │ муж. │ │ жен. │ │ отметить                                                           │");   prntPF_DL(str,1,0);
  sprintf(str," │                                         │      └─┘      └─┘ знаком V)                                                          │");   prntPF_DL(str,1,0);
  sprintf(str," ├─────────────────────────────────────────┼──────────────────────────────────────────────────────────────────────────────────────┤");   prntPF_DL(str,1,0);
  sprintf(str," │Гражданство                              │                                                                                      │");   prntPF_DL(str,1,0);
  sprintf(str," ├─────────────────────────────────────────┼─────────────────────────────────────────────────────────────────────────┬─┬─┬────────┤");   prntPF_DL(str,1,0);
  sprintf(str," │Вид документа, удостоверяющего личность  │                                                                      Код│ │ │        │");   prntPF_DL(str,1,0);
  sprintf(str," ├─────────────────────────────────────────┼─────────────────────────────────────────────────────────────────────────┴─┴─┴────────┤");   prntPF_DL(str,1,0);
  sprintf(str," │Серия                                    │                                                                                      │");   prntPF_DL(str,1,0);
  sprintf(str," ├─────────────────────────────────────────┼──────────────────────────────────────────────────────────────────────────────────────┤");   prntPF_DL(str,1,0);
  sprintf(str," │Номер                                    │                                                                                      │");   prntPF_DL(str,1,0);
  if ( pl==0 ) {
  sprintf(str," ├─────────────────────────────────────────┼──────────────────────────────────────────────────────────────────────────────────────┤");   prntPF_DL(str,1,0);
  }
  if ( pl==1 ) {
  sprintf(str," └─────────────────────────────────────────┴──────────────────────────────────────────────────────────────────────────────────────┘");   prntPF_DL(str,1,0);
  CFile_DL.ListFeed();
  char N_STR[10]; if (NL_DL==1) { nlist_DL++; sprintf(N_STR,"%2d",nlist_DL); } else { sprintf(N_STR,"%2s","  "); }
  sprintf(str,"                                                                                                                           ┌──┬──┐ ");   prntPF_DL(str,1,0);
  sprintf(str,"                                                                                                                     Лист  │ 0│ 4│ ");   prntPF_DL(str,1,0);
  sprintf(str,"                                                                                                                           └──┴──┘ ");   prntPF_DL(str,1,0);
  sprintf(str,"                                                                                                                           ┌──┬──┐ ");   prntPF_DL(str,1,0);
  sprintf(str,"                                                                                                                Страница N │ %c│ %c│ ", N_STR[0], N_STR[1]);   prntPF_DL(str,1,0);
  sprintf(str,"                                                                                                                           └──┴──┘ ");   prntPF_DL(str,1,0);
  sprintf(str,"                                                                                                                    ┌─┬─┬─┬─┬─┬─┬─┐");   prntPF_DL(str,1,0);
  sprintf(str,"                                                                                                       Форма по КНД │1│1│5│1│0│5│8│");   prntPF_DL(str,1,0);
  sprintf(str,"                                                                                                                    └─┴─┴─┴─┴─┴─┴─┘");   prntPF_DL(str,1,0);
  sprintf(str," ┌─────────────────────────────────────────┬──────────────────────────────────────────────────────────────────────────────────────┐");   prntPF_DL(str,1,0);
  }
  sprintf(str," │Дата выдачи документа                    │                                                                                      │");   prntPF_DL(str,1,0);
  sprintf(str," ├─────────────────────────────────────────┼──────────────────────────────────────────────────────────────────────────────────────┤");   prntPF_DL(str,1,0);
  sprintf(str," │Адрес места жительства в Российской      │             Х                                                                        │");   prntPF_DL(str,1,0);
  sprintf(str," │Федерации:                               │                                                                                      │");   prntPF_DL(str,1,0);
  sprintf(str," ├─────────────────────────────────────────┼─┬─┬─┬─┬─┬─┬──────────────────────────────────────────────────────────────────────────┤");   prntPF_DL(str,1,0);
  sprintf(str," │Почтовый индекс                          │%s│%s│%s│%s│%s│%s│                                                                          │", ai0, ai1, ai2, ai3, ai4, ai5);   prntPF_DL(str,1,0);
  sprintf(str," ├─────────────────────────────────────────┼─┴─┴─┴─┴─┴─┴─────────────────────────────────────────────────────────────┬─┬─┬────────┤");   prntPF_DL(str,1,0);
  sprintf(str," │Субъект Российской Федерации             │%-22.22s                                                Код│%s│%s│        │"            , aReg, aKodReg0, aKodReg1);   prntPF_DL(str,1,0);
  sprintf(str," ├─────────────────────────────────────────┼─────────────────────────────────────────────────────────────────────────┴─┴─┴────────┤");   prntPF_DL(str,1,0);
  sprintf(str," │Район                                    │%-30.30s                                                        │"                      , aRai);   prntPF_DL(str,1,0);
  sprintf(str," ├─────────────────────────────────────────┼──────────────────────────────────────────────────────────────────────────────────────┤");   prntPF_DL(str,1,0);
  sprintf(str," │Город                                    │%-30.30s                                                        │"                      , aGor);   prntPF_DL(str,1,0);
  sprintf(str," ├─────────────────────────────────────────┼──────────────────────────────────────────────────────────────────────────────────────┤");   prntPF_DL(str,1,0);
  sprintf(str," │Населенный пункт (село, поселок и т.д.)  │%-30.30s                                                        │"                      , aNas);   prntPF_DL(str,1,0);
  sprintf(str," ├─────────────────────────────────────────┼──────────────────────────────────────────────────────────────────────────────────────┤");   prntPF_DL(str,1,0);
  sprintf(str," │Улица (проспект, переулок и т.д.)        │%-30.30s                                                        │"                      , aStr);   prntPF_DL(str,1,0);
  sprintf(str," ├─────────────────────────────────────────┼──────────────────────────────────────────────────────────────────────────────────────┤");   prntPF_DL(str,1,0);
  sprintf(str," │Номер дома (владения)                    │%-30.30s                                                        │"                      , aDom);   prntPF_DL(str,1,0);
  sprintf(str," ├─────────────────────────────────────────┼──────────────────────────────────────────────────────────────────────────────────────┤");   prntPF_DL(str,1,0);
  sprintf(str," │Номер корпуса (строения)                 │%-30.30s                                                        │"                      , aKor);   prntPF_DL(str,1,0);
  sprintf(str," ├─────────────────────────────────────────┼──────────────────────────────────────────────────────────────────────────────────────┤");   prntPF_DL(str,1,0);
  sprintf(str," │Номер квартиры                           │%-30.30s                                                        │"                      , aKva);   prntPF_DL(str,1,0);
  sprintf(str," └─────────────────────────────────────────┴──────────────────────────────────────────────────────────────────────────────────────┘");   prntPF_DL(str,1,0);

  int LastList=LIST[5]+LIST[6]+LIST[7];
  if (LastList==0) { if (FLIST==1) { CFile_DL.ListFeed(); } } else { CFile_DL.ListFeed(); }

  } // end if LIST[4]



  if (LIST[5]==1) {

  char N_STR[10]; if (NL_DL==1) { nlist_DL++; sprintf(N_STR,"%2d",nlist_DL); } else { sprintf(N_STR,"%2s","  "); }

  sprintf(str,"                                                                                                                           ┌──┬──┐               "); prntPF_DL(str,1,0);
  sprintf(str,"                                                                                                                     Лист  │ 0│ 5│               "); prntPF_DL(str,1,0);
  sprintf(str,"                                                                                                                           └──┴──┘               "); prntPF_DL(str,1,0);
  sprintf(str,"                                                                                                                           ┌──┬──┐               "); prntPF_DL(str,1,0);
  sprintf(str,"                                                                                                                Страница N │ %c│ %c│             ", N_STR[0], N_STR[1]);   prntPF_DL(str,1,0);
  sprintf(str,"                                                                                                                           └──┴──┘               "); prntPF_DL(str,1,0);
  sprintf(str,"                                                                                                                    ┌─┬─┬─┬─┬─┬─┬─┐              "); prntPF_DL(str,1,0);
  sprintf(str,"                                                                                                       Форма по КНД │1│1│5│1│0│5│8│              "); prntPF_DL(str,1,0);
  sprintf(str,"                                                                                                                    └─┴─┴─┴─┴─┴─┴─┘              "); prntPF_DL(str,1,0);
  sprintf(str,"                                   I. РАСЧЕТ ПО АВАНСОВЫМ ПЛАТЕЖАМ ПО СТРАХОВЫМ ВЗНОСАМ                                                          "); prntPF_DL(str,1,0);
  sprintf(str," ┌───────────────────────────────┬──────┬─────────────────────────┬─────────────────────────┬─────────────────────────┬─────────────────────────┐"); prntPF_DL(str,1,0);
  sprintf(str," │ Наименование показателя       │Код   │Для мужчин 1952  года    │Для мужчин с 1953 по 1966│    Для лиц 1967 года    │ ВСЕГО                   │"); prntPF_DL(str,1,0);
  sprintf(str," │                               │строки│рождения и старше и      │ год рождения и женщин с │    рождения и моложе    │                         │"); prntPF_DL(str,1,0);
  sprintf(str," │                               │      │женщин 1956 года рождения│1957 по 1966 год рождения│                         │                         │"); prntPF_DL(str,1,0);
  sprintf(str," │                               │      │и старше                 │                         │                         │                         │"); prntPF_DL(str,1,0);
  sprintf(str," │                               │      ├──────── по данным ──────┼──────── по данным ──────┼──────── по данным ──────┼───────── по данным ─────┤"); prntPF_DL(str,1,0);
  sprintf(str," │                               │      │  налогопла-  │налогового│  налогопла-  │налогового│  налогопла-  │налогового│  налогопла-  │налогового│"); prntPF_DL(str,1,0);
  sprintf(str," ├───────────────────────────────┼──────┼── тельщика ──┼─ органа ─┼── тельщика ──┼─ органа ─┼── тельщика ──┼─ органа ─┼── тельщика ──┼─органа───┤"); prntPF_DL(str,1,0);
  sprintf(str," │ 1                             │ 2    │ 3            │ 4        │ 5            │ 6        │ 7            │ 8        │ 9            │ 10       │"); prntPF_DL(str,1,0);
  sprintf(str," │                               │      │              │          │              │          │              │          │ ( гр.3+гр.5+ │(гр.4+гр.6│"); prntPF_DL(str,1,0);
  sprintf(str," │                               │      │              │          │              │          │              │          │     гр.7 )   │  + гр.8) │"); prntPF_DL(str,1,0);
  sprintf(str," ├───────────────────────────────┼──────┼──────────────┼──────────┼──────────────┼──────────┼──────────────┼──────────┼──────────────┼──────────┤"); prntPF_DL(str,1,0);
  sprintf(str," │База для начисления страховых  │ 0100 │%s│          │%s│          │%s│          │%s│          │"                                               , s0100_3, s0100_5, s0100_7, s0100_9); prntPF_DL(str,1,0);
  sprintf(str," │взносов за отчетный период,    │      │              │          │              │          │              │          │              │          │"); prntPF_DL(str,1,0);
  sprintf(str," │всего                          │      │              │          │              │          │              │          │              │          │"); prntPF_DL(str,1,0);
  sprintf(str," ├───────────────────────────────┼──────┼──────────────┼──────────┼──────────────┼──────────┼──────────────┼──────────┼──────────────┼──────────┤"); prntPF_DL(str,1,0);
  sprintf(str," │в том числе последний          │ 0110 │%s│          │%s│          │%s│          │%s│          │"                                                , s0110_3, s0110_5, s0110_7, s0110_9); prntPF_DL(str,1,0);
  sprintf(str," │квартал отчетного периода      │      │              │          │              │          │              │          │              │          │"); prntPF_DL(str,1,0);
  sprintf(str," │(стр.0120+стр.0130+стр.0140)   │      │              │          │              │          │              │          │              │          │"); prntPF_DL(str,1,0);
  sprintf(str," ├───────────────────────────────┼──────┼──────────────┼──────────┼──────────────┼──────────┼──────────────┼──────────┼──────────────┼──────────┤"); prntPF_DL(str,1,0);
  sprintf(str," │из него: 1 месяц               │ 0120 │%s│          │%s│          │%s│          │%s│          │"                                                , s0120_3, s0120_5, s0120_7, s0120_9); prntPF_DL(str,1,0);
  sprintf(str," ├───────────────────────────────┼──────┼──────────────┼──────────┼──────────────┼──────────┼──────────────┼──────────┼──────────────┼──────────┤"); prntPF_DL(str,1,0);
  sprintf(str," │2 месяц                        │ 0130 │%s│          │%s│          │%s│          │%s│          │"                                                , s0130_3, s0130_5, s0130_7, s0130_9); prntPF_DL(str,1,0);
  sprintf(str," ├───────────────────────────────┼──────┼──────────────┼──────────┼──────────────┼──────────┼──────────────┼──────────┼──────────────┼──────────┤"); prntPF_DL(str,1,0);
  sprintf(str," │3 месяц                        │ 0140 │%s│          │%s│          │%s│          │%s│          │"                                                , s0140_3, s0140_5, s0140_7, s0140_9); prntPF_DL(str,1,0);

  if ( pl==0 ) {
  sprintf(str," ├───────────────────────────────┼──────┼──────────────┼──────────┼──────────────┼──────────┼──────────────┼──────────┼──────────────┼──────────┤"); prntPF_DL(str,1,0);
  }

  if ( pl==1 ) {
  sprintf(str," └───────────────────────────────┴──────┴──────────────┴──────────┴──────────────┴──────────┴──────────────┴──────────┴──────────────┴──────────┘"); prntPF_DL(str,1,0);
  if (NL_DL==1) { nlist_DL++; sprintf(N_STR,"%2d",nlist_DL); } else { sprintf(N_STR,"%2s","  "); }

  CFile_DL.ListFeed();

  sprintf(str,"                                                                                                ┌──┬──┐                    ┌──┬──┐               "); prntPF_DL(str,1,0);
  sprintf(str,"                                                                                          Лист  │ 0│ 5│         Страница N │ %c│ %c│             ", N_STR[0], N_STR[1]);   prntPF_DL(str,1,0);
  sprintf(str,"                                                                                                └──┴──┘                    └──┴──┘               "); prntPF_DL(str,1,0);
  sprintf(str,"                                                                                                                    ┌─┬─┬─┬─┬─┬─┬─┐              "); prntPF_DL(str,1,0);
  sprintf(str,"                                                                                                       Форма по КНД │1│1│5│1│0│5│8│              "); prntPF_DL(str,1,0);
  sprintf(str,"                                                                                                                    └─┴─┴─┴─┴─┴─┴─┘              "); prntPF_DL(str,1,0);
  sprintf(str," ┌───────────────────────────────┬──────┬──────────────┬──────────┬──────────────┬──────────┬──────────────┬──────────┬──────────────┬──────────┐"); prntPF_DL(str,1,0);
  sprintf(str," │ 1                             │ 2    │ 3            │ 4        │ 5            │ 6        │ 7            │ 8        │ 9            │ 10       │"); prntPF_DL(str,1,0);
  sprintf(str," ├───────────────────────────────┼──────┼──────────────┼──────────┼──────────────┼──────────┼──────────────┼──────────┼──────────────┼──────────┤"); prntPF_DL(str,1,0);
  }
  sprintf(str," │Сумма начисленных авансовых    │ 0200 │%s│          │%s│          │%s│          │%s│          │"                                                , s0200_3, s0200_5, s0200_7, s0200_9); prntPF_DL(str,1,0);
  sprintf(str," │платежей по страховым взносам  │      │              │          │              │          │              │          │              │          │"); prntPF_DL(str,1,0);
  sprintf(str," │на обязательное пенсионное     │      │              │          │              │          │              │          │              │          │"); prntPF_DL(str,1,0);
  sprintf(str," │страхование за отчетный период,│      │              │          │              │          │              │          │              │          │"); prntPF_DL(str,1,0);
  sprintf(str," │всего                          │      │              │          │              │          │              │          │              │          │"); prntPF_DL(str,1,0);
  sprintf(str," ├───────────────────────────────┼──────┼──────────────┼──────────┼──────────────┼──────────┼──────────────┼──────────┼──────────────┼──────────┤"); prntPF_DL(str,1,0);
  sprintf(str," │в том числе последний          │ 0210 │%s│          │%s│          │%s│          │%s│          │"                                                , s0210_3, s0210_5, s0210_7, s0210_9); prntPF_DL(str,1,0);
  sprintf(str," │квартал отчетного периода      │      │              │          │              │          │              │          │              │          │"); prntPF_DL(str,1,0);
  sprintf(str," │(стр.0220+стр.0230+стр.0240)   │      │              │          │              │          │              │          │              │          │"); prntPF_DL(str,1,0);
  sprintf(str," ├───────────────────────────────┼──────┼──────────────┼──────────┼──────────────┼──────────┼──────────────┼──────────┼──────────────┼──────────┤"); prntPF_DL(str,1,0);
  sprintf(str," │из него: 1 месяц               │ 0220 │%s│          │%s│          │%s│          │%s│          │"                                                , s0220_3, s0220_5, s0220_7, s0220_9); prntPF_DL(str,1,0);
  sprintf(str," ├───────────────────────────────┼──────┼──────────────┼──────────┼──────────────┼──────────┼──────────────┼──────────┼──────────────┼──────────┤"); prntPF_DL(str,1,0);
  sprintf(str," │2 месяц                        │ 0230 │%s│          │%s│          │%s│          │%s│          │"                                                , s0230_3, s0230_5, s0230_7, s0230_9); prntPF_DL(str,1,0);
  sprintf(str," ├───────────────────────────────┼──────┼──────────────┼──────────┼──────────────┼──────────┼──────────────┼──────────┼──────────────┼──────────┤"); prntPF_DL(str,1,0);
  sprintf(str," │3 месяц                        │ 0240 │%s│          │%s│          │%s│          │%s│          │"                                                , s0240_3, s0240_5, s0240_7, s0240_9); prntPF_DL(str,1,0);

  if ( pl==0 ) {
  sprintf(str," └───────────────────────────────┴──────┴──────────────┴──────────┴──────────────┴──────────┴──────────────┴──────────┴──────────────┴──────────┘"); prntPF_DL(str,1,0);

  if (NL_DL==1) { nlist_DL++; sprintf(N_STR,"%2d",nlist_DL); } else { sprintf(N_STR,"%2s","  "); }
  CFile_DL.ListFeed();

  sprintf(str,"                                                                                                                           ┌──┬──┐               "); prntPF_DL(str,1,0);
  sprintf(str,"                                                                                                                     Лист  │ 0│ 5│               "); prntPF_DL(str,1,0);
  sprintf(str,"                                                                                                                           └──┴──┘               "); prntPF_DL(str,1,0);
  sprintf(str,"                                                                                                                           ┌──┬──┐               "); prntPF_DL(str,1,0);
  sprintf(str,"                                                                                                                Страница N │ %c│ %c│             ", N_STR[0], N_STR[1]);   prntPF_DL(str,1,0);
  sprintf(str,"                                                                                                                           └──┴──┘               "); prntPF_DL(str,1,0);
  sprintf(str,"                                                                                                                    ┌─┬─┬─┬─┬─┬─┬─┐              "); prntPF_DL(str,1,0);
  sprintf(str,"                                                                                                       Форма по КНД │1│1│5│1│0│5│8│              "); prntPF_DL(str,1,0);
  sprintf(str,"                                                                                                                    └─┴─┴─┴─┴─┴─┴─┘              "); prntPF_DL(str,1,0);
  sprintf(str," ┌───────────────────────────────┬──────┬──────────────┬──────────┬──────────────┬──────────┬──────────────┬──────────┬──────────────┬──────────┐"); prntPF_DL(str,1,0);
  sprintf(str," │ 1                             │ 2    │ 3            │ 4        │ 5            │ 6        │ 7            │ 8        │ 9            │ 10       │"); prntPF_DL(str,1,0);
  sprintf(str," ├───────────────────────────────┼──────┼──────────────┼──────────┼──────────────┼──────────┼──────────────┼──────────┼──────────────┼──────────┤"); prntPF_DL(str,1,0);
  }
  if ( pl==1 ) {
  sprintf(str," ├───────────────────────────────┼──────┼──────────────┼──────────┼──────────────┼──────────┼──────────────┼──────────┼──────────────┼──────────┤"); prntPF_DL(str,1,0);
  }
  sprintf(str," │Из них: Сумма начисленных      │ 0300 │%s│          │%s│          │%s│          │%s│          │"                                                , s0300_3, s0300_5, s0300_7, s0300_9); prntPF_DL(str,1,0);
  sprintf(str," │авансовых платежей по страховым│      │              │          │              │          │              │          │              │          │"); prntPF_DL(str,1,0);
  sprintf(str," │взносам на страховую часть     │      │              │          │              │          │              │          │              │          │"); prntPF_DL(str,1,0);
  sprintf(str," │трудовой пенсии за отчетный    │      │              │          │              │          │              │          │              │          │"); prntPF_DL(str,1,0);
  sprintf(str," │период, всего                  │      │              │          │              │          │              │          │              │          │"); prntPF_DL(str,1,0);
  sprintf(str," ├───────────────────────────────┼──────┼──────────────┼──────────┼──────────────┼──────────┼──────────────┼──────────┼──────────────┼──────────┤"); prntPF_DL(str,1,0);
  sprintf(str," │в том числе последний квартал  │ 0310 │%s│          │%s│          │%s│          │%s│          │"                                                , s0310_3, s0310_5, s0310_7, s0310_9); prntPF_DL(str,1,0);
  sprintf(str," │отчетного периода              │      │              │          │              │          │              │          │              │          │"); prntPF_DL(str,1,0);
  sprintf(str," │(стр.0320+стр.0330+стр.0340)   │      │              │          │              │          │              │          │              │          │"); prntPF_DL(str,1,0);
  sprintf(str," ├───────────────────────────────┼──────┼──────────────┼──────────┼──────────────┼──────────┼──────────────┼──────────┼──────────────┼──────────┤"); prntPF_DL(str,1,0);
  sprintf(str," │из него: 1 месяц               │ 0320 │%s│          │%s│          │%s│          │%s│          │"                                                , s0320_3, s0320_5, s0320_7, s0320_9); prntPF_DL(str,1,0);
  sprintf(str," ├───────────────────────────────┼──────┼──────────────┼──────────┼──────────────┼──────────┼──────────────┼──────────┼──────────────┼──────────┤"); prntPF_DL(str,1,0);
  sprintf(str," │2 месяц                        │ 0330 │%s│          │%s│          │%s│          │%s│          │"                                                , s0330_3, s0330_5, s0330_7, s0330_9); prntPF_DL(str,1,0);
  sprintf(str," ├───────────────────────────────┼──────┼──────────────┼──────────┼──────────────┼──────────┼──────────────┼──────────┼──────────────┼──────────┤"); prntPF_DL(str,1,0);
  sprintf(str," │3 месяц                        │ 0340 │%s│          │%s│          │%s│          │%s│          │"                                                , s0340_3, s0340_5, s0340_7, s0340_9); prntPF_DL(str,1,0);
  if ( pl==0 ) {
  sprintf(str," ├───────────────────────────────┼──────┼──────────────┼──────────┼──────────────┼──────────┼──────────────┼──────────┼──────────────┼──────────┤"); prntPF_DL(str,1,0);
  }
  if ( pl==1 ) {
  sprintf(str," └───────────────────────────────┴──────┴──────────────┴──────────┴──────────────┴──────────┴──────────────┴──────────┴──────────────┴──────────┘"); prntPF_DL(str,1,0);

  if (NL_DL==1) { nlist_DL++; sprintf(N_STR,"%2d",nlist_DL); } else { sprintf(N_STR,"%2s","  "); }
  CFile_DL.ListFeed();

  sprintf(str,"                                                                                                ┌──┬──┐                    ┌──┬──┐               "); prntPF_DL(str,1,0);
  sprintf(str,"                                                                                          Лист  │ 0│ 5│         Страница N │ %c│ %c│             ", N_STR[0], N_STR[1]);   prntPF_DL(str,1,0);
  sprintf(str,"                                                                                                └──┴──┘                    └──┴──┘               "); prntPF_DL(str,1,0);
  sprintf(str,"                                                                                                                    ┌─┬─┬─┬─┬─┬─┬─┐              "); prntPF_DL(str,1,0);
  sprintf(str,"                                                                                                       Форма по КНД │1│1│5│1│0│5│8│              "); prntPF_DL(str,1,0);
  sprintf(str,"                                                                                                                    └─┴─┴─┴─┴─┴─┴─┘              "); prntPF_DL(str,1,0);
  sprintf(str," ┌───────────────────────────────┬──────┬──────────────┬──────────┬──────────────┬──────────┬──────────────┬──────────┬──────────────┬──────────┐"); prntPF_DL(str,1,0);
  sprintf(str," │ 1                             │ 2    │ 3            │ 4        │ 5            │ 6        │ 7            │ 8        │ 9            │ 10       │"); prntPF_DL(str,1,0);
  sprintf(str," ├───────────────────────────────┼──────┼──────────────┼──────────┼──────────────┼──────────┼──────────────┼──────────┼──────────────┼──────────┤"); prntPF_DL(str,1,0);
  }

  sprintf(str," │Сумма начисленных авансовых    │ 0400 │ X            │ X        │%s│          │%s│          │%s│          │"                                    ,          s0400_5, s0400_7, s0400_9); prntPF_DL(str,1,0);
  sprintf(str," │платежей по страховым взносам  │      │              │          │              │          │              │          │              │          │"); prntPF_DL(str,1,0);
  sprintf(str," │на накопительную часть трудовой│      │              │          │              │          │              │          │              │          │"); prntPF_DL(str,1,0);
  sprintf(str," │пенсии за отчетный период,всего│      │              │          │              │          │              │          │              │          │"); prntPF_DL(str,1,0);
  sprintf(str," ├───────────────────────────────┼──────┼──────────────┼──────────┼──────────────┼──────────┼──────────────┼──────────┼──────────────┼──────────┤"); prntPF_DL(str,1,0);
  sprintf(str," │в том числе последний квартал  │ 0410 │ X            │ X        │%s│          │%s│          │%s│          │"                                    ,          s0410_5, s0410_7, s0410_9); prntPF_DL(str,1,0);
  sprintf(str," │отчетного периода              │      │              │          │              │          │              │          │              │          │"); prntPF_DL(str,1,0);
  sprintf(str," │(стр.0420+стр.0430+стр.0440)   │      │              │          │              │          │              │          │              │          │"); prntPF_DL(str,1,0);
  sprintf(str," ├───────────────────────────────┼──────┼──────────────┼──────────┼──────────────┼──────────┼──────────────┼──────────┼──────────────┼──────────┤"); prntPF_DL(str,1,0);
  sprintf(str," │Из него: 1 месяц               │ 0420 │ X            │ X        │%s│          │%s│          │%s│          │"                                    ,          s0420_5, s0420_7, s0420_9); prntPF_DL(str,1,0);
  sprintf(str," ├───────────────────────────────┼──────┼──────────────┼──────────┼──────────────┼──────────┼──────────────┼──────────┼──────────────┼──────────┤"); prntPF_DL(str,1,0);
  sprintf(str," │2 месяц                        │ 0430 │ X            │ X        │%s│          │%s│          │%s│          │"                                    ,          s0430_5, s0430_7, s0430_9); prntPF_DL(str,1,0);
  sprintf(str," ├───────────────────────────────┼──────┼──────────────┼──────────┼──────────────┼──────────┼──────────────┼──────────┼──────────────┼──────────┤"); prntPF_DL(str,1,0);
  sprintf(str," │3 месяц                        │ 0440 │ X            │ X        │%s│          │%s│          │%s│          │"                                    ,          s0440_5, s0440_7, s0440_9); prntPF_DL(str,1,0);
  sprintf(str," └───────────────────────────────┴──────┴──────────────┴──────────┴──────────────┴──────────┴──────────────┴──────────┴──────────────┴──────────┘"); prntPF_DL(str,1,0);
  sprintf(str,"    Наличие права на применение регрессивных тарифов страховых взносов в последнем квартале отчетного периода (нужное подчеркнуть)               "); prntPF_DL(str,1,0);
  sprintf(str,"    1-й месяц имеет (не имеет) право на применение регрессивных тарифов страховых взносов                                                        "); prntPF_DL(str,1,0);
  sprintf(str,"              %s                                                                                                                                 ", (RFLAG1==1)?YesStr:NoStr); prntPF_DL(str,1,0);
  sprintf(str,"    2-й месяц имеет (не имеет) право на применение регрессивных тарифов страховых взносов                                                        "); prntPF_DL(str,1,0);
  sprintf(str,"              %s                                                                                                                                 ", (RFLAG2==1)?YesStr:NoStr); prntPF_DL(str,1,0);
  sprintf(str,"    3-й месяц имеет (не имеет) право на применение регрессивных тарифов страховых взносов                                                        "); prntPF_DL(str,1,0);
  sprintf(str,"              %s                                                                                                                                 ", (RFLAG3==1)?YesStr:NoStr); prntPF_DL(str,1,0);

  int LastList=LIST[6]+LIST[7];
  if (LastList==0) { if (FLIST==1) { CFile_DL.ListFeed(); } } else { CFile_DL.ListFeed(); }

  } // end if LIST[5]



  if (LIST[6]==1) {

  char N_STR[10]; if (NL_DL==1) { nlist_DL++; sprintf(N_STR,"%2d",nlist_DL); } else { sprintf(N_STR,"%2s","  "); }

  sprintf(str,"                                                                              ┌──┬──┐         "); prntPF_DL(str,1,0);
  sprintf(str,"                                                                        Лист  │ 0│ 6│         "); prntPF_DL(str,1,0);
  sprintf(str,"                                                                              └──┴──┘         "); prntPF_DL(str,1,0);
  sprintf(str,"                                                                              ┌──┬──┐         "); prntPF_DL(str,1,0);
  sprintf(str,"                                                                   Страница N │ %c│ %c│       ", N_STR[0], N_STR[1]);   prntPF_DL(str,1,0);
  sprintf(str,"                                                                              └──┴──┘         "); prntPF_DL(str,1,0);
  sprintf(str,"                                                                       ┌─┬─┬─┬─┬─┬─┬─┐        "); prntPF_DL(str,1,0);
  sprintf(str,"                                                          Форма по КНД │1│1│5│1│0│5│8│        "); prntPF_DL(str,1,0);
  sprintf(str,"                                                                       └─┴─┴─┴─┴─┴─┴─┘        "); prntPF_DL(str,1,0);

  sprintf(str,"  Справочно:                                                            (в рублях и копейках) "); prntPF_DL(str,1,0);
  sprintf(str," ┌───────────────────────────────┬──────┬──────────────┬─────────────────────────────────────┐"); prntPF_DL(str,1,0);
  sprintf(str," │                               │Код   │ Всего        │ в том числе                         │"); prntPF_DL(str,1,0); 
  sprintf(str," │                               │строки│              ├──────────────────┬──────────────────┤"); prntPF_DL(str,1,0);
  sprintf(str," │                               │      │              │на страховую часть│на накопительную  │"); prntPF_DL(str,1,0);
  sprintf(str," │                               │      │              │трудовой пенсии   │часть трудовой    │"); prntPF_DL(str,1,0);
  sprintf(str," │                               │      │              │                  │пенсии            │"); prntPF_DL(str,1,0);
  sprintf(str," ├───────────────────────────────┼──────┼──────────────┼──────────────────┼──────────────────┤"); prntPF_DL(str,1,0);
  sprintf(str," │ 1                             │ 2    │ 3            │ 4                │ 5                │"); prntPF_DL(str,1,0);
  sprintf(str," ├───────────────────────────────┼──────┼──────────────┼──────────────────┼──────────────────┤"); prntPF_DL(str,1,0);
  sprintf(str," │Уплачено страховых платежей по │ 010  │%s│    %s│    %s│"                                    , s010_3, s010_4, s010_5); prntPF_DL(str,1,0);
  sprintf(str," │страховым взносам на обязатель-│      │              │                  │                  │"); prntPF_DL(str,1,0);
  sprintf(str," │ное пенсионное страхование за  │      │              │                  │                  │"); prntPF_DL(str,1,0);
  sprintf(str," │отчетный период по данным      │      │              │                  │                  │"); prntPF_DL(str,1,0);
  sprintf(str," │страхователя                   │      │              │                  │                  │"); prntPF_DL(str,1,0);
  sprintf(str," ├───────────────────────────────┼──────┼──────────────┼──────────────────┼──────────────────┤"); prntPF_DL(str,1,0);
  sprintf(str," │в том числе за последний       │ 011  │%s│    %s│    %s│"                                    , s011_3, s011_4, s011_5); prntPF_DL(str,1,0);
  sprintf(str," │квартал отчетного периода      │      │              │                  │                  │"); prntPF_DL(str,1,0);
  sprintf(str," ├───────────────────────────────┼──────┼──────────────┼──────────────────┼──────────────────┤"); prntPF_DL(str,1,0);
  sprintf(str," │из него - 1 месяц              │ 012  │%s│    %s│    %s│"                                    , s012_3, s012_4, s012_5); prntPF_DL(str,1,0);
  sprintf(str," ├───────────────────────────────┼──────┼──────────────┼──────────────────┼──────────────────┤"); prntPF_DL(str,1,0);
  sprintf(str," │2 месяц                        │ 013  │%s│    %s│    %s│"                                    , s013_3, s013_4, s013_5); prntPF_DL(str,1,0);
  sprintf(str," ├───────────────────────────────┼──────┼──────────────┼──────────────────┼──────────────────┤"); prntPF_DL(str,1,0);
  sprintf(str," │3 месяц                        │ 014  │%s│    %s│    %s│"                                    , s014_3, s014_4, s014_5); prntPF_DL(str,1,0);
  sprintf(str," ├───────────────────────────────┼──────┼──────────────┼──────────────────┼──────────────────┤"); prntPF_DL(str,1,0);
  sprintf(str," │Разница между суммами авансовых│ 015  │%s│    %s│    %s│"                                    , s015_3, s015_4, s015_5); prntPF_DL(str,1,0);
  sprintf(str," │платежей по страховым взносам, │      │              │                  │                  │"); prntPF_DL(str,1,0);
  sprintf(str," │уплаченными за отчетный период,│      │              │                  │                  │"); prntPF_DL(str,1,0);
  sprintf(str," │и суммой авансовых платежей по │      │              │                  │                  │"); prntPF_DL(str,1,0);
  sprintf(str," │страховым взносам, подлежащей  │      │              │                  │                  │"); prntPF_DL(str,1,0);
  sprintf(str," │уплате за отчетный период в    │      │              │                  │                  │"); prntPF_DL(str,1,0);
  sprintf(str," │соответствии с расчетом        │      │              │                  │                  │"); prntPF_DL(str,1,0);
  sprintf(str," └───────────────────────────────┴──────┴──────────────┴──────────────────┴──────────────────┘"); prntPF_DL(str,1,0);

  int LastList=LIST[7];
  if (LastList==0) { if (FLIST==1) { CFile_DL.ListFeed(); } } else { CFile_DL.ListFeed(); }

  } // end if LIST[6]

  CFile_DL.ListFeed();

  if (LIST[7]==1) {

  sprintf(str,"                       II. РАСЧЕТ ДЛЯ ЗАПОЛНЕНИЯ СТРОК 0300 И 0400                                                          (в рублях и копейках)              "); prntPF_DL(str,1,0);
  sprintf(str,"┌────────┬───┬────────────────────────────────────┬─────────────────────────────────────────────────────┬─────────────────────────────────────────────────────┐"); prntPF_DL(str,1,0);
  sprintf(str,"│        │Код│Для мужчин 1952 года рождения и     │Для мужчин с 1953 по 1966 год рождения и             │Для лиц 1967 года рождения и моложе                  │"); prntPF_DL(str,1,0);
  sprintf(str,"│        │   │старше и женщин 1956 года           │женщин с 1957 по 1966 год рождения                   │                                                     │"); prntPF_DL(str,1,0);
  sprintf(str,"│        │   │рождения и старше                   │                                                     │                                                     │"); prntPF_DL(str,1,0);
  sprintf(str,"│        │   ├────────────┬─────────────────┬─────┼────────────┬──────────────────────────────────┬─────┼────────────┬──────────────────────────────────┬─────┤"); prntPF_DL(str,1,0);
  sprintf(str,"│        │   │База для    │Начислено стра-  │Чис- │База для    │Начислено страховых взносов на:   │Чис- │База для    │Начислено страховых взносов на:   │Чис- │"); prntPF_DL(str,1,0);
  sprintf(str,"│        │   │начисления  │ховых взносов    │лен- │начисления  ├─────────────────┬────────────────┤лен- │начисления  ├─────────────────┬────────────────┤лен- │"); prntPF_DL(str,1,0);
  sprintf(str,"│        │   │страховых   │на страховую     │ность│страховых   │страховую часть  │накопительную   │ность│страховых   │страховую часть  │накопилтельную  │ность│"); prntPF_DL(str,1,0);
  sprintf(str,"│        │   │взносов     │часть трудовой   │     │взносов     │трудовой пенсии  │часть трудовой  │     │взносов     │трудовой пенсии  │часть трудовой  │     │"); prntPF_DL(str,1,0);
  sprintf(str,"│        │   │            │пенсии           │     │            │                 │пенсии          │     │            │                 │пенсии          │     │"); prntPF_DL(str,1,0);
  sprintf(str,"│        │   │            ├─────┬───────────┤     │            ├─────┬───────────┼─────┬──────────┤     │            ├─────┬───────────┼─────┬──────────┤     │"); prntPF_DL(str,1,0);
  sprintf(str,"│        │   │            │Тариф│ Сумма,    │     │            │Тариф│ Сумма,    │Тариф│ Сумма,   │     │            │Тариф│ Сумма,    │Тариф│ Сумма,   │     │"); prntPF_DL(str,1,0);
  sprintf(str,"│        │   │            │%%/руб│руб.,коп.  │     │            │%%/руб│руб.,коп.  │%%/руб│руб.,коп. │     │            │%%/руб│руб.,коп.  │%%/руб│руб.,коп. │     │"); prntPF_DL(str,1,0);
  sprintf(str,"├────────┼───┼────────────┼─────┼───────────┼─────┼────────────┼─────┼───────────┼─────┼──────────┼─────┼────────────┼─────┼───────────┼─────┼──────────┼─────┤"); prntPF_DL(str,1,0);
  sprintf(str,"│    1   │ 2 │    3       │  4  │   5       │  6  │    7       │  8  │   9       │ 10  │   11     │ 12  │    13      │ 14  │   15      │ 16  │   17     │ 18  │"); prntPF_DL(str,1,0);
  sprintf(str,"├────────┼───┼────────────┼─────┼───────────┼─────┼────────────┼─────┼───────────┼─────┼──────────┼─────┼────────────┼─────┼───────────┼─────┼──────────┼─────┤"); prntPF_DL(str,1,0);
  sprintf(str,"│До100000│100│%s│%s│%s│%s│%s│%s│%s│%s│%s│%s│%s│%s│%s│%s│%s│%s│"                                                                                                 , s100_3, P1T5, s100_5, s100_6, s100_7, P1T71, s100_9, P1T72, s100_11, s100_12, s100_13, P1T91, s100_15, P1T92, s100_17, s100_18);  prntPF_DL(str,1,0);
  sprintf(str,"├────────┼───┼────────────┼─────┼───────────┼─────┼────────────┼─────┼───────────┼─────┼──────────┼─────┼────────────┼─────┼───────────┼─────┼──────────┼─────┤");                                                                                                                                  prntPF_DL(str,1,0);
  sprintf(str,"│От100001│200│%s│  Х  │%s│%s│%s│  Х  │%s│  Х  │%s│%s│%s│  Х  │%s│  Х  │%s│%s│"                                                                                  , s200_3      , s200_5, s200_6, s200_7       , s200_9       , s200_11, s200_12, s200_13       , s200_15       , s200_17, s200_18);  prntPF_DL(str,1,0);
  sprintf(str,"│до300000│   │            │     │           │     │            │     │           │     │          │     │            │     │           │     │          │     │");                                                                                                                                  prntPF_DL(str,1,0);
  sprintf(str,"├────────┼───┼────────────┼─────┼───────────┼─────┼────────────┼─────┼───────────┼─────┼──────────┼─────┼────────────┼─────┼───────────┼─────┼──────────┼─────┤");                                                                                                                                  prntPF_DL(str,1,0);
  sprintf(str,"│100000р.│210│%s│%s│%s│  X  │%s│%s│%s│%s│%s│  X  │%s│%s│%s│%s│%s│  X  │"                                                                                        , s210_3, P3T5, s210_5        , s210_7, P3T71, s210_9, P3T72, s210_11         , s210_13, P3T91, s210_15, P3T92, s210_17         );  prntPF_DL(str,1,0);
  sprintf(str,"├────────┼───┼────────────┼─────┼───────────┼─────┼────────────┼─────┼───────────┼─────┼──────────┼─────┼────────────┼─────┼───────────┼─────┼──────────┼─────┤");                                                                                                                                  prntPF_DL(str,1,0);
  sprintf(str,"│>100000р│220│%s│%s│%s│  Х  │%s│%s│%s│%s│%s│  Х  │%s│%s│%s│%s│%s│  Х  │"                                                                                        , s220_3, P4T5, s220_5        , s220_7, P4T71, s220_9, P4T72, s220_11         , s220_13, P4T91, s220_15, P4T92, s220_17         );  prntPF_DL(str,1,0);
  sprintf(str,"├────────┼───┼────────────┼─────┼───────────┼─────┼────────────┼─────┼───────────┼─────┼──────────┼─────┼────────────┼─────┼───────────┼─────┼──────────┼─────┤");                                                                                                                                  prntPF_DL(str,1,0);
  sprintf(str,"│От300001│300│%s│  Х  │%s│%s│%s│  Х  │%s│  Х  │%s│%s│%s│  Х  │%s│  Х  │%s│%s│"                                                                                  , s300_3      , s300_5, s300_6, s300_7       , s300_9       , s300_11, s300_12, s300_13       , s300_15       , s300_17, s300_18);  prntPF_DL(str,1,0);
  sprintf(str,"│до600000│   │            │     │           │     │            │     │           │     │          │     │            │     │           │     │          │     │");                                                                                                                                  prntPF_DL(str,1,0);
  sprintf(str,"├────────┼───┼────────────┼─────┼───────────┼─────┼────────────┼─────┼───────────┼─────┼──────────┼─────┼────────────┼─────┼───────────┼─────┼──────────┼─────┤");                                                                                                                                  prntPF_DL(str,1,0);
  sprintf(str,"│300000р.│310│%s│%s│%s│  X  │%s│%s│%s│%s│%s│  X  │%s│%s│%s│%s│%s│  X  │"                                                                                        , s310_3, P6T5, s310_5        , s310_7, P6T71, s310_9, P6T72, s310_11         , s310_13, P6T91, s310_15, P6T92, s310_17         );  prntPF_DL(str,1,0);
  sprintf(str,"├────────┼───┼────────────┼─────┼───────────┼─────┼────────────┼─────┼───────────┼─────┼──────────┼─────┼────────────┼─────┼───────────┼─────┼──────────┼─────┤");                                                                                                                                  prntPF_DL(str,1,0);
  sprintf(str,"│> 300000│320│%s│%s│%s│  Х  │%s│%s│%s│%s│%s│  Х  │%s│%s│%s│%s│%s│  Х  │"                                                                                        , s320_3, P7T5, s320_5        , s320_7, P7T71, s320_9, P7T72, s320_11         , s320_13, P7T91, s320_15, P7T92, s320_17         );  prntPF_DL(str,1,0);
  sprintf(str,"├────────┼───┼────────────┼─────┼───────────┼─────┼────────────┼─────┼───────────┼─────┼──────────┼─────┼────────────┼─────┼───────────┼─────┼──────────┼─────┤");                                                                                                                                  prntPF_DL(str,1,0);
  sprintf(str,"│> 600000│400│%s│%s│%s│%s│%s│%s│%s│%s│%s│%s│%s│%s│%s│%s│%s│%s│"                                                                                                 , s400_3, P0T5, s400_5, s400_6, s400_7, P0T71, s400_9, P0T72, s400_11, s400_12, s400_13, P0T91, s400_15, P0T92, s400_17, s400_18);  prntPF_DL(str,1,0);
  sprintf(str,"├────────┼───┼────────────┼─────┼───────────┼─────┼────────────┼─────┼───────────┼─────┼──────────┼─────┼────────────┼─────┼───────────┼─────┼──────────┼─────┤");                                                                                                                                  prntPF_DL(str,1,0);
  sprintf(str,"│ Итого: │500│%s│  Х  │%s│%s│%s│  Х  │%s│  Х  │%s│%s│%s│  Х  │%s│  Х  │%s│%s│"                                                                                  , s500_3      , s500_5, s500_6, s500_7       , s500_9       , s500_11, s500_12, s500_13       , s500_15       , s500_17, s500_18);  prntPF_DL(str,1,0);
  sprintf(str,"└────────┴───┴────────────┴─────┴───────────┴─────┴────────────┴─────┴───────────┴─────┴──────────┴─────┴────────────┴─────┴───────────┴─────┴──────────┴─────┘");                                                                                                                                  prntPF_DL(str,1,0);
  sprintf(str,"   _____________________________________________________   _____________     ________________________________                                                  "); prntPF_DL(str,1,0);
  sprintf(str,"         должность работника Инспекции МНС России             подпись              расшифровка подписи                                                         "); prntPF_DL(str,1,0);
  sprintf(str,"   \"__\" _____________ 20__ года.                                                                                                                             "); prntPF_DL(str,1,0);
  sprintf(str,"            (дата)                                                                                                                                             "); prntPF_DL(str,1,0);
                                                                                                                                                                                          

  if (FLIST==1) { CFile_DL.ListFeed(); } 

  } // end if LIST[7]
  } // end if EXCEL==0

  if (EXCEL==1)
  {
    var xls=CreateObject("Excel.Application");
    try
    {
//    xls.Visible=true;
    char Dir[128];
    GetCurrentDirectory(128,Dir);
    string nm="RASPF.XLS";
    var WorkDir = Dir + "\\";
    xls.Caption="╨рёўхЄ яю ртрэёют√ь яырЄхцрь т ╧╘";
    xls.Workbooks.Add(WorkDir+nm);

    string name=xls.Workbooks.Item(1).Name;

    string tString;

    // 1-й лист
    OemToChar(Nni,Nni);
    OemToChar(Org,Org);
    OemToChar(Ruk,Ruk);
    OemToChar(Glb,Glb);
    char god1[10]; sprintf(god1,"%c%c", edat[5], edat[6]);
    char TmpChar[10];
    xls.Workbooks.Item(name).Worksheets.Item(1).Range("C10").Value=MesPer1;
    xls.Workbooks.Item(name).Worksheets.Item(1).Range("Z10").Value=static_cast_to_string(god1);
    xls.Workbooks.Item(name).Worksheets.Item(1).Range("L13").Value=static_cast_to_string(Nni);
    sprintf(TmpChar,"%c",Cni[0]);
    xls.Workbooks.Item(name).Worksheets.Item(1).Range("BQ13").Value=static_cast_to_string(TmpChar);
    sprintf(TmpChar,"%c",Cni[1]);
    xls.Workbooks.Item(name).Worksheets.Item(1).Range("BT13").Value=static_cast_to_string(TmpChar);
    sprintf(TmpChar,"%c",Cni[2]);
    xls.Workbooks.Item(name).Worksheets.Item(1).Range("BV13").Value=static_cast_to_string(TmpChar);
    sprintf(TmpChar,"%c",Cni[3]);
    xls.Workbooks.Item(name).Worksheets.Item(1).Range("BX13").Value=static_cast_to_string(TmpChar);
    xls.Workbooks.Item(name).Worksheets.Item(1).Range("AE15").Value=vOrg[0];
    xls.Workbooks.Item(name).Worksheets.Item(1).Range("AY15").Value=vOrg[1];
    xls.Workbooks.Item(name).Worksheets.Item(1).Range("BQ15").Value=vOrg[3];
    xls.Workbooks.Item(name).Worksheets.Item(1).Range("AG19").Value=vOrg[2];
    xls.Workbooks.Item(name).Worksheets.Item(1).Range("B25").Value=static_cast_to_string(Org);
    if (ORG!=3) { 
    sprintf(TmpChar,"%c",Inn[0]);
    xls.Workbooks.Item(name).Worksheets.Item(1).Range("AB28").Value=static_cast_to_string(TmpChar);
    sprintf(TmpChar,"%c",Inn[1]);
    xls.Workbooks.Item(name).Worksheets.Item(1).Range("AF28").Value=static_cast_to_string(TmpChar);
    sprintf(TmpChar,"%c",Inn[2]);
    xls.Workbooks.Item(name).Worksheets.Item(1).Range("AI28").Value=static_cast_to_string(TmpChar);
    sprintf(TmpChar,"%c",Inn[3]);
    xls.Workbooks.Item(name).Worksheets.Item(1).Range("AM28").Value=static_cast_to_string(TmpChar);
    sprintf(TmpChar,"%c",Inn[4]);
    xls.Workbooks.Item(name).Worksheets.Item(1).Range("AQ28").Value=static_cast_to_string(TmpChar);
    sprintf(TmpChar,"%c",Inn[5]);
    xls.Workbooks.Item(name).Worksheets.Item(1).Range("AU28").Value=static_cast_to_string(TmpChar);
    sprintf(TmpChar,"%c",Inn[6]);
    xls.Workbooks.Item(name).Worksheets.Item(1).Range("AY28").Value=static_cast_to_string(TmpChar);
    sprintf(TmpChar,"%c",Inn[7]);
    xls.Workbooks.Item(name).Worksheets.Item(1).Range("BB28").Value=static_cast_to_string(TmpChar);
    sprintf(TmpChar,"%c",Inn[8]);
    xls.Workbooks.Item(name).Worksheets.Item(1).Range("BF28").Value=static_cast_to_string(TmpChar);
    sprintf(TmpChar,"%c",Inn[9]);
    xls.Workbooks.Item(name).Worksheets.Item(1).Range("BI28").Value=static_cast_to_string(TmpChar);

    sprintf(TmpChar,"%c",Kpp[0]);
    xls.Workbooks.Item(name).Worksheets.Item(1).Range("L30").Value=static_cast_to_string(TmpChar);
    sprintf(TmpChar,"%c",Kpp[1]);
    xls.Workbooks.Item(name).Worksheets.Item(1).Range("N30").Value=static_cast_to_string(TmpChar);
    sprintf(TmpChar,"%c",Kpp[2]);
    xls.Workbooks.Item(name).Worksheets.Item(1).Range("O30").Value=static_cast_to_string(TmpChar);
    sprintf(TmpChar,"%c",Kpp[3]);
    xls.Workbooks.Item(name).Worksheets.Item(1).Range("Q30").Value=static_cast_to_string(TmpChar);
    sprintf(TmpChar,"%c",Kpp[4]);
    xls.Workbooks.Item(name).Worksheets.Item(1).Range("R30").Value=static_cast_to_string(TmpChar);
    sprintf(TmpChar,"%c",Kpp[5]);
    xls.Workbooks.Item(name).Worksheets.Item(1).Range("T30").Value=static_cast_to_string(TmpChar);
    sprintf(TmpChar,"%c",Kpp[6]);
    xls.Workbooks.Item(name).Worksheets.Item(1).Range("W30").Value=static_cast_to_string(TmpChar);
    sprintf(TmpChar,"%c",Kpp[7]);
    xls.Workbooks.Item(name).Worksheets.Item(1).Range("Y30").Value=static_cast_to_string(TmpChar);
    sprintf(TmpChar,"%c",Kpp[8]);
    xls.Workbooks.Item(name).Worksheets.Item(1).Range("AA30").Value=static_cast_to_string(TmpChar);

    sprintf(TmpChar,"%c",Kop[0]);
    xls.Workbooks.Item(name).Worksheets.Item(1).Range("AG30").Value=static_cast_to_string(TmpChar);
    sprintf(TmpChar,"%c",Kop[1]);
    xls.Workbooks.Item(name).Worksheets.Item(1).Range("AI30").Value=static_cast_to_string(TmpChar);
    sprintf(TmpChar,"%c",Kop[2]);
    xls.Workbooks.Item(name).Worksheets.Item(1).Range("AL30").Value=static_cast_to_string(TmpChar);
    sprintf(TmpChar,"%c",Kop[3]);
    xls.Workbooks.Item(name).Worksheets.Item(1).Range("AP30").Value=static_cast_to_string(TmpChar);
    sprintf(TmpChar,"%c",Kop[4]);
    xls.Workbooks.Item(name).Worksheets.Item(1).Range("AS30").Value=static_cast_to_string(TmpChar);
    sprintf(TmpChar,"%c",Kop[5]);
    xls.Workbooks.Item(name).Worksheets.Item(1).Range("AV30").Value=static_cast_to_string(TmpChar);
    sprintf(TmpChar,"%c",Kop[6]);
    xls.Workbooks.Item(name).Worksheets.Item(1).Range("AY30").Value=static_cast_to_string(TmpChar);
    sprintf(TmpChar,"%c",Kop[7]);
    xls.Workbooks.Item(name).Worksheets.Item(1).Range("BA30").Value=static_cast_to_string(TmpChar);
    sprintf(TmpChar,"%c",Kop[8]);
    xls.Workbooks.Item(name).Worksheets.Item(1).Range("BE30").Value=static_cast_to_string(TmpChar);
    }


    if (ORG==3) {
    sprintf(TmpChar,"%c",Inn[0]);
    xls.Workbooks.Item(name).Worksheets.Item(1).Range("O33").Value=static_cast_to_string(TmpChar);
    sprintf(TmpChar,"%c",Inn[1]);
    xls.Workbooks.Item(name).Worksheets.Item(1).Range("Q33").Value=static_cast_to_string(TmpChar);
    sprintf(TmpChar,"%c",Inn[2]);
    xls.Workbooks.Item(name).Worksheets.Item(1).Range("R33").Value=static_cast_to_string(TmpChar);
    sprintf(TmpChar,"%c",Inn[3]);
    xls.Workbooks.Item(name).Worksheets.Item(1).Range("T33").Value=static_cast_to_string(TmpChar);
    sprintf(TmpChar,"%c",Inn[4]);
    xls.Workbooks.Item(name).Worksheets.Item(1).Range("W33").Value=static_cast_to_string(TmpChar);
    sprintf(TmpChar,"%c",Inn[5]);
    xls.Workbooks.Item(name).Worksheets.Item(1).Range("Y33").Value=static_cast_to_string(TmpChar);
    sprintf(TmpChar,"%c",Inn[6]);
    xls.Workbooks.Item(name).Worksheets.Item(1).Range("AA33").Value=static_cast_to_string(TmpChar);
    sprintf(TmpChar,"%c",Inn[7]);
    xls.Workbooks.Item(name).Worksheets.Item(1).Range("AC33").Value=static_cast_to_string(TmpChar);
    sprintf(TmpChar,"%c",Inn[8]);
    xls.Workbooks.Item(name).Worksheets.Item(1).Range("AG33").Value=static_cast_to_string(TmpChar);
    sprintf(TmpChar,"%c",Inn[9]);
    xls.Workbooks.Item(name).Worksheets.Item(1).Range("AI33").Value=static_cast_to_string(TmpChar);
    sprintf(TmpChar,"%c",Inn[10]);
    xls.Workbooks.Item(name).Worksheets.Item(1).Range("AL33").Value=static_cast_to_string(TmpChar);
    sprintf(TmpChar,"%c",Inn[11]);
    xls.Workbooks.Item(name).Worksheets.Item(1).Range("AP33").Value=static_cast_to_string(TmpChar);
    }
    xls.Workbooks.Item(name).Worksheets.Item(1).Range("R35").Value=static_cast_to_string(RTrim(Pen));
    if (ORG!=3) 
    {
    xls.Workbooks.Item(name).Worksheets.Item(1).Range("K43").Value=static_cast_to_string(Ruk);
    xls.Workbooks.Item(name).Worksheets.Item(1).Range("N46").Value=static_cast_to_string(Glb);
    sprintf(TmpChar,"%c",Iru[0]);
    xls.Workbooks.Item(name).Worksheets.Item(1).Range("F45").Value=static_cast_to_string(TmpChar);
    sprintf(TmpChar,"%c",Iru[1]);
    xls.Workbooks.Item(name).Worksheets.Item(1).Range("H45").Value=static_cast_to_string(TmpChar);
    sprintf(TmpChar,"%c",Iru[2]);
    xls.Workbooks.Item(name).Worksheets.Item(1).Range("J45").Value=static_cast_to_string(TmpChar);
    sprintf(TmpChar,"%c",Iru[3]);
    xls.Workbooks.Item(name).Worksheets.Item(1).Range("L45").Value=static_cast_to_string(TmpChar);
    sprintf(TmpChar,"%c",Iru[4]);
    xls.Workbooks.Item(name).Worksheets.Item(1).Range("N45").Value=static_cast_to_string(TmpChar);
    sprintf(TmpChar,"%c",Iru[5]);
    xls.Workbooks.Item(name).Worksheets.Item(1).Range("O45").Value=static_cast_to_string(TmpChar);
    sprintf(TmpChar,"%c",Iru[6]);
    xls.Workbooks.Item(name).Worksheets.Item(1).Range("Q45").Value=static_cast_to_string(TmpChar);
    sprintf(TmpChar,"%c",Iru[7]);
    xls.Workbooks.Item(name).Worksheets.Item(1).Range("R45").Value=static_cast_to_string(TmpChar);
    sprintf(TmpChar,"%c",Iru[8]);
    xls.Workbooks.Item(name).Worksheets.Item(1).Range("T45").Value=static_cast_to_string(TmpChar);
    sprintf(TmpChar,"%c",Iru[9]);
    xls.Workbooks.Item(name).Worksheets.Item(1).Range("W45").Value=static_cast_to_string(TmpChar);
    sprintf(TmpChar,"%c",Iru[10]);
    xls.Workbooks.Item(name).Worksheets.Item(1).Range("Y45").Value=static_cast_to_string(TmpChar);
    sprintf(TmpChar,"%c",Iru[11]);
    xls.Workbooks.Item(name).Worksheets.Item(1).Range("AA45").Value=static_cast_to_string(TmpChar);
    sprintf(TmpChar,"%c",StrDate[0]);
    xls.Workbooks.Item(name).Worksheets.Item(1).Range("BK45").Value=static_cast_to_string(TmpChar);
    sprintf(TmpChar,"%c",StrDate[1]);
    xls.Workbooks.Item(name).Worksheets.Item(1).Range("BN45").Value=static_cast_to_string(TmpChar);
    sprintf(TmpChar,"%c",StrDate[3]);
    xls.Workbooks.Item(name).Worksheets.Item(1).Range("BS45").Value=static_cast_to_string(TmpChar);
    sprintf(TmpChar,"%c",StrDate[4]);
    xls.Workbooks.Item(name).Worksheets.Item(1).Range("BU45").Value=static_cast_to_string(TmpChar);
    sprintf(TmpChar,"%c",StrDate[6]);
    xls.Workbooks.Item(name).Worksheets.Item(1).Range("BY45").Value=static_cast_to_string(TmpChar);
    sprintf(TmpChar,"%c",StrDate[7]);
    xls.Workbooks.Item(name).Worksheets.Item(1).Range("CB45").Value=static_cast_to_string(TmpChar);
    sprintf(TmpChar,"%c",StrDate[8]);
    xls.Workbooks.Item(name).Worksheets.Item(1).Range("CD45").Value=static_cast_to_string(TmpChar);
    sprintf(TmpChar,"%c",StrDate[9]);
    xls.Workbooks.Item(name).Worksheets.Item(1).Range("CG45").Value=static_cast_to_string(TmpChar);
    sprintf(TmpChar,"%c",Igl[0]);
    xls.Workbooks.Item(name).Worksheets.Item(1).Range("F48").Value=static_cast_to_string(TmpChar);
    sprintf(TmpChar,"%c",Igl[1]);
    xls.Workbooks.Item(name).Worksheets.Item(1).Range("H48").Value=static_cast_to_string(TmpChar);
    sprintf(TmpChar,"%c",Igl[2]);
    xls.Workbooks.Item(name).Worksheets.Item(1).Range("J48").Value=static_cast_to_string(TmpChar);
    sprintf(TmpChar,"%c",Igl[3]);
    xls.Workbooks.Item(name).Worksheets.Item(1).Range("L48").Value=static_cast_to_string(TmpChar);
    sprintf(TmpChar,"%c",Igl[4]);
    xls.Workbooks.Item(name).Worksheets.Item(1).Range("N48").Value=static_cast_to_string(TmpChar);
    sprintf(TmpChar,"%c",Igl[5]);
    xls.Workbooks.Item(name).Worksheets.Item(1).Range("O48").Value=static_cast_to_string(TmpChar);
    sprintf(TmpChar,"%c",Igl[6]);
    xls.Workbooks.Item(name).Worksheets.Item(1).Range("Q48").Value=static_cast_to_string(TmpChar);
    sprintf(TmpChar,"%c",Igl[7]);
    xls.Workbooks.Item(name).Worksheets.Item(1).Range("R48").Value=static_cast_to_string(TmpChar);
    sprintf(TmpChar,"%c",Igl[8]);
    xls.Workbooks.Item(name).Worksheets.Item(1).Range("T48").Value=static_cast_to_string(TmpChar);
    sprintf(TmpChar,"%c",Igl[9]);
    xls.Workbooks.Item(name).Worksheets.Item(1).Range("W48").Value=static_cast_to_string(TmpChar);
    sprintf(TmpChar,"%c",Igl[10]);
    xls.Workbooks.Item(name).Worksheets.Item(1).Range("Y48").Value=static_cast_to_string(TmpChar);
    sprintf(TmpChar,"%c",Igl[11]);
    xls.Workbooks.Item(name).Worksheets.Item(1).Range("AA48").Value=static_cast_to_string(TmpChar);
    sprintf(TmpChar,"%c",StrDate[0]);
    xls.Workbooks.Item(name).Worksheets.Item(1).Range("BK48").Value=static_cast_to_string(TmpChar);
    sprintf(TmpChar,"%c",StrDate[1]);
    xls.Workbooks.Item(name).Worksheets.Item(1).Range("BN48").Value=static_cast_to_string(TmpChar);
    sprintf(TmpChar,"%c",StrDate[3]);
    xls.Workbooks.Item(name).Worksheets.Item(1).Range("BS48").Value=static_cast_to_string(TmpChar);
    sprintf(TmpChar,"%c",StrDate[4]);
    xls.Workbooks.Item(name).Worksheets.Item(1).Range("BU48").Value=static_cast_to_string(TmpChar);
    sprintf(TmpChar,"%c",StrDate[6]);
    xls.Workbooks.Item(name).Worksheets.Item(1).Range("BY48").Value=static_cast_to_string(TmpChar);
    sprintf(TmpChar,"%c",StrDate[7]);
    xls.Workbooks.Item(name).Worksheets.Item(1).Range("CB48").Value=static_cast_to_string(TmpChar);
    sprintf(TmpChar,"%c",StrDate[8]);
    xls.Workbooks.Item(name).Worksheets.Item(1).Range("CD48").Value=static_cast_to_string(TmpChar);
    sprintf(TmpChar,"%c",StrDate[9]);
    xls.Workbooks.Item(name).Worksheets.Item(1).Range("CG48").Value=static_cast_to_string(TmpChar);
    sprintf(TmpChar,"%c",StrDate[0]);
    xls.Workbooks.Item(name).Worksheets.Item(1).Range("BK51").Value=static_cast_to_string(TmpChar);
    sprintf(TmpChar,"%c",StrDate[1]);
    xls.Workbooks.Item(name).Worksheets.Item(1).Range("BN51").Value=static_cast_to_string(TmpChar);
    sprintf(TmpChar,"%c",StrDate[3]);
    xls.Workbooks.Item(name).Worksheets.Item(1).Range("BS51").Value=static_cast_to_string(TmpChar);
    sprintf(TmpChar,"%c",StrDate[4]);
    xls.Workbooks.Item(name).Worksheets.Item(1).Range("BU51").Value=static_cast_to_string(TmpChar);
    sprintf(TmpChar,"%c",StrDate[6]);
    xls.Workbooks.Item(name).Worksheets.Item(1).Range("BY51").Value=static_cast_to_string(TmpChar);
    sprintf(TmpChar,"%c",StrDate[7]);
    xls.Workbooks.Item(name).Worksheets.Item(1).Range("CB51").Value=static_cast_to_string(TmpChar);
    sprintf(TmpChar,"%c",StrDate[8]);
    xls.Workbooks.Item(name).Worksheets.Item(1).Range("CD51").Value=static_cast_to_string(TmpChar);
    sprintf(TmpChar,"%c",StrDate[9]);
    xls.Workbooks.Item(name).Worksheets.Item(1).Range("CG51").Value=static_cast_to_string(TmpChar);
    }
    else
    {
    sprintf(TmpChar,"%c",StrDate[0]);
    xls.Workbooks.Item(name).Worksheets.Item(1).Range("BK53").Value=static_cast_to_string(TmpChar);
    sprintf(TmpChar,"%c",StrDate[1]);
    xls.Workbooks.Item(name).Worksheets.Item(1).Range("BN53").Value=static_cast_to_string(TmpChar);
    sprintf(TmpChar,"%c",StrDate[3]);
    xls.Workbooks.Item(name).Worksheets.Item(1).Range("BS53").Value=static_cast_to_string(TmpChar);
    sprintf(TmpChar,"%c",StrDate[4]);
    xls.Workbooks.Item(name).Worksheets.Item(1).Range("BU53").Value=static_cast_to_string(TmpChar);
    sprintf(TmpChar,"%c",StrDate[6]);
    xls.Workbooks.Item(name).Worksheets.Item(1).Range("BY53").Value=static_cast_to_string(TmpChar);
    sprintf(TmpChar,"%c",StrDate[7]);
    xls.Workbooks.Item(name).Worksheets.Item(1).Range("CB53").Value=static_cast_to_string(TmpChar);
    sprintf(TmpChar,"%c",StrDate[8]);
    xls.Workbooks.Item(name).Worksheets.Item(1).Range("CD53").Value=static_cast_to_string(TmpChar);
    sprintf(TmpChar,"%c",StrDate[9]);
    xls.Workbooks.Item(name).Worksheets.Item(1).Range("CG53").Value=static_cast_to_string(TmpChar);

    sprintf(TmpChar,"%c",StrDate[0]);
    xls.Workbooks.Item(name).Worksheets.Item(1).Range("BK56").Value=static_cast_to_string(TmpChar);
    sprintf(TmpChar,"%c",StrDate[1]);
    xls.Workbooks.Item(name).Worksheets.Item(1).Range("BN56").Value=static_cast_to_string(TmpChar);
    sprintf(TmpChar,"%c",StrDate[3]);
    xls.Workbooks.Item(name).Worksheets.Item(1).Range("BS56").Value=static_cast_to_string(TmpChar);
    sprintf(TmpChar,"%c",StrDate[4]);
    xls.Workbooks.Item(name).Worksheets.Item(1).Range("BU56").Value=static_cast_to_string(TmpChar);
    sprintf(TmpChar,"%c",StrDate[6]);
    xls.Workbooks.Item(name).Worksheets.Item(1).Range("BY56").Value=static_cast_to_string(TmpChar);
    sprintf(TmpChar,"%c",StrDate[7]);
    xls.Workbooks.Item(name).Worksheets.Item(1).Range("CB56").Value=static_cast_to_string(TmpChar);
    sprintf(TmpChar,"%c",StrDate[8]);
    xls.Workbooks.Item(name).Worksheets.Item(1).Range("CD56").Value=static_cast_to_string(TmpChar);
    sprintf(TmpChar,"%c",StrDate[9]);
    xls.Workbooks.Item(name).Worksheets.Item(1).Range("CG56").Value=static_cast_to_string(TmpChar);
    }

    // 2-й лист

    char ts[40]; 
    sprintf(ts,"%c",adr_ind[0]);                      ai0=ts;
    sprintf(ts,"%c",adr_ind[1]);                      ai1=ts;                         
    sprintf(ts,"%c",adr_ind[2]);                      ai2=ts;                         
    sprintf(ts,"%c",adr_ind[3]);                      ai3=ts;                         
    sprintf(ts,"%c",adr_ind[4]);                      ai4=ts;                         
    sprintf(ts,"%c",adr_ind[5]);                      ai5=ts;   
    sprintf(ts,"%-22.22s",adr_reg); OemToChar(ts,ts); aReg=ts;
    sprintf(ts,"%c",KodReg[0]);                       aKodReg0=ts;
    sprintf(ts,"%c",KodReg[1]);                       aKodReg1=ts;
    sprintf(ts,"%-30.30s",adr_rai); OemToChar(ts,ts); aRai=ts;
    sprintf(ts,"%-30.30s",adr_gor); OemToChar(ts,ts); aGor=ts;
    sprintf(ts,"%-30.30s",adr_nas); OemToChar(ts,ts); aNas=ts;
    sprintf(ts,"%-30.30s",adr_str); OemToChar(ts,ts); aStr=ts;
    sprintf(ts,"%-30.30s",adr_dom); OemToChar(ts,ts); aDom=ts;
    sprintf(ts,"%-30.30s",adr_kor); OemToChar(ts,ts); aKor=ts;
    sprintf(ts,"%-30.30s",adr_kva); OemToChar(ts,ts); aKva=ts;
    sprintf(ts,"%-25.25s",Tel);     OemToChar(ts,ts); aTel=ts; if (ORG==1) aTel=" ";

    sprintf(ts,"%c",adf_ind[0]);                      afi0=ts;
    sprintf(ts,"%c",adf_ind[1]);                      afi1=ts;                         
    sprintf(ts,"%c",adf_ind[2]);                      afi2=ts;                         
    sprintf(ts,"%c",adf_ind[3]);                      afi3=ts;                         
    sprintf(ts,"%c",adf_ind[4]);                      afi4=ts;                         
    sprintf(ts,"%c",adf_ind[5]);                      afi5=ts;   
    sprintf(ts,"%-22.22s",adf_reg); OemToChar(ts,ts); afReg=ts;
    sprintf(ts,"%c",fKodReg[0]);                      afKodReg0=ts;
    sprintf(ts,"%c",fKodReg[1]);                      afKodReg1=ts;
    sprintf(ts,"%-30.30s",adf_rai); OemToChar(ts,ts); afRai=ts;
    sprintf(ts,"%-30.30s",adf_gor); OemToChar(ts,ts); afGor=ts;
    sprintf(ts,"%-30.30s",adf_nas); OemToChar(ts,ts); afNas=ts;
    sprintf(ts,"%-30.30s",adf_str); OemToChar(ts,ts); afStr=ts;
    sprintf(ts,"%-30.30s",adf_dom); OemToChar(ts,ts); afDom=ts;
    sprintf(ts,"%-30.30s",adf_kor); OemToChar(ts,ts); afKor=ts;
    sprintf(ts,"%-30.30s",adf_kva); OemToChar(ts,ts); afKva=ts;

    if (ORG==0 || ORG==1)
    {
    xls.Workbooks.Item(name).Worksheets.Item(2).Range("U11").Value =ai0;
    xls.Workbooks.Item(name).Worksheets.Item(2).Range("X11").Value =ai1;
    xls.Workbooks.Item(name).Worksheets.Item(2).Range("Y11").Value =ai2;
    xls.Workbooks.Item(name).Worksheets.Item(2).Range("Z11").Value =ai3;
    xls.Workbooks.Item(name).Worksheets.Item(2).Range("AA11").Value=ai4;
    xls.Workbooks.Item(name).Worksheets.Item(2).Range("AB11").Value=ai5;
    xls.Workbooks.Item(name).Worksheets.Item(2).Range("U12").Value=aReg;
    xls.Workbooks.Item(name).Worksheets.Item(2).Range("AT12").Value=aKodReg0;
    xls.Workbooks.Item(name).Worksheets.Item(2).Range("AU12").Value=aKodReg1;
    xls.Workbooks.Item(name).Worksheets.Item(2).Range("U13").Value=aRai;
    xls.Workbooks.Item(name).Worksheets.Item(2).Range("U14").Value=aGor;
    xls.Workbooks.Item(name).Worksheets.Item(2).Range("U15").Value=aNas;
    xls.Workbooks.Item(name).Worksheets.Item(2).Range("U16").Value=aStr;
    xls.Workbooks.Item(name).Worksheets.Item(2).Range("U17").Value=aDom;
    xls.Workbooks.Item(name).Worksheets.Item(2).Range("U18").Value=aKor;
    xls.Workbooks.Item(name).Worksheets.Item(2).Range("U19").Value=aKva;
    xls.Workbooks.Item(name).Worksheets.Item(2).Range("L21").Value=aTel;
    }

    tString="V";
    if ((ORG==0 || ORG==1) && ADR==0)
    xls.Workbooks.Item(name).Worksheets.Item(2).Range("AA24").Value=tString;

    if ((ORG==0 || ORG==1) && ADR==1) 
    {
    xls.Workbooks.Item(name).Worksheets.Item(2).Range("AP24").Value=tString;
    xls.Workbooks.Item(name).Worksheets.Item(2).Range("U28").Value =afi0;
    xls.Workbooks.Item(name).Worksheets.Item(2).Range("X28").Value =afi1;
    xls.Workbooks.Item(name).Worksheets.Item(2).Range("Y28").Value =afi2;
    xls.Workbooks.Item(name).Worksheets.Item(2).Range("Z28").Value =afi3;
    xls.Workbooks.Item(name).Worksheets.Item(2).Range("AA28").Value=afi4;
    xls.Workbooks.Item(name).Worksheets.Item(2).Range("AB28").Value=afi5;
    xls.Workbooks.Item(name).Worksheets.Item(2).Range("U29").Value=afReg;
    xls.Workbooks.Item(name).Worksheets.Item(2).Range("AT29").Value=afKodReg0;
    xls.Workbooks.Item(name).Worksheets.Item(2).Range("AU29").Value=afKodReg1;
    xls.Workbooks.Item(name).Worksheets.Item(2).Range("U30").Value=afRai;
    xls.Workbooks.Item(name).Worksheets.Item(2).Range("U31").Value=afGor;
    xls.Workbooks.Item(name).Worksheets.Item(2).Range("U32").Value=afNas;
    xls.Workbooks.Item(name).Worksheets.Item(2).Range("U33").Value=afStr;
    xls.Workbooks.Item(name).Worksheets.Item(2).Range("U34").Value=afDom;
    xls.Workbooks.Item(name).Worksheets.Item(2).Range("U35").Value=afKor;
    xls.Workbooks.Item(name).Worksheets.Item(2).Range("U36").Value=afKva;
    }

    if (ORG==1)
    {

    sprintf(ts,"%c",ado_ind[0]);                      ai0=ts;
    sprintf(ts,"%c",ado_ind[1]);                      ai1=ts;                         
    sprintf(ts,"%c",ado_ind[2]);                      ai2=ts;                         
    sprintf(ts,"%c",ado_ind[3]);                      ai3=ts;                         
    sprintf(ts,"%c",ado_ind[4]);                      ai4=ts;                         
    sprintf(ts,"%c",ado_ind[5]);                      ai5=ts;   
    sprintf(ts,"%-22.22s",ado_reg); OemToChar(ts,ts); aReg=ts;
    sprintf(ts,"%c",oKodReg[0]);                      aKodReg0=ts;
    sprintf(ts,"%c",oKodReg[1]);                      aKodReg1=ts;
    sprintf(ts,"%-30.30s",ado_rai); OemToChar(ts,ts); aRai=ts;
    sprintf(ts,"%-30.30s",ado_gor); OemToChar(ts,ts); aGor=ts;
    sprintf(ts,"%-30.30s",ado_nas); OemToChar(ts,ts); aNas=ts;
    sprintf(ts,"%-30.30s",ado_str); OemToChar(ts,ts); aStr=ts;
    sprintf(ts,"%-30.30s",ado_dom); OemToChar(ts,ts); aDom=ts;
    sprintf(ts,"%-30.30s",ado_kor); OemToChar(ts,ts); aKor=ts;
    sprintf(ts,"%-30.30s",ado_kva); OemToChar(ts,ts); aKva=ts;
    sprintf(ts,"%-25.25s",Tel);     OemToChar(ts,ts); aTel=ts;

    xls.Workbooks.Item(name).Worksheets.Item(2).Range("U41").Value =ai0;
    xls.Workbooks.Item(name).Worksheets.Item(2).Range("X41").Value =ai1;
    xls.Workbooks.Item(name).Worksheets.Item(2).Range("Y41").Value =ai2;
    xls.Workbooks.Item(name).Worksheets.Item(2).Range("Z41").Value =ai3;
    xls.Workbooks.Item(name).Worksheets.Item(2).Range("AA41").Value=ai4;
    xls.Workbooks.Item(name).Worksheets.Item(2).Range("AB41").Value=ai5;
    xls.Workbooks.Item(name).Worksheets.Item(2).Range("U42").Value=aReg;
    xls.Workbooks.Item(name).Worksheets.Item(2).Range("AT42").Value=aKodReg0;
    xls.Workbooks.Item(name).Worksheets.Item(2).Range("AU42").Value=aKodReg1;
    xls.Workbooks.Item(name).Worksheets.Item(2).Range("U43").Value=aRai;
    xls.Workbooks.Item(name).Worksheets.Item(2).Range("U44").Value=aGor;
    xls.Workbooks.Item(name).Worksheets.Item(2).Range("U45").Value=aNas;
    xls.Workbooks.Item(name).Worksheets.Item(2).Range("U46").Value=aStr;
    xls.Workbooks.Item(name).Worksheets.Item(2).Range("U47").Value=aDom;
    xls.Workbooks.Item(name).Worksheets.Item(2).Range("U48").Value=aKor;
    xls.Workbooks.Item(name).Worksheets.Item(2).Range("U49").Value=aKva;
    xls.Workbooks.Item(name).Worksheets.Item(2).Range("L51").Value=aTel;
    }

    // 3-й лист
    if (ORG==2)
    {
    xls.Workbooks.Item(name).Worksheets.Item(3).Range("P8").Value=aTel;
    xls.Workbooks.Item(name).Worksheets.Item(3).Range("AL11").Value =ai0;
    xls.Workbooks.Item(name).Worksheets.Item(3).Range("AN11").Value =ai1;
    xls.Workbooks.Item(name).Worksheets.Item(3).Range("AQ11").Value =ai2;
    xls.Workbooks.Item(name).Worksheets.Item(3).Range("AT11").Value =ai3;
    xls.Workbooks.Item(name).Worksheets.Item(3).Range("AV11").Value=ai4;
    xls.Workbooks.Item(name).Worksheets.Item(3).Range("AY11").Value=ai5;
    xls.Workbooks.Item(name).Worksheets.Item(3).Range("AL12").Value=aReg;
    xls.Workbooks.Item(name).Worksheets.Item(3).Range("BV12").Value=aKodReg0;
    xls.Workbooks.Item(name).Worksheets.Item(3).Range("BX12").Value=aKodReg1;
    xls.Workbooks.Item(name).Worksheets.Item(3).Range("AL13").Value=aRai;
    xls.Workbooks.Item(name).Worksheets.Item(3).Range("AL14").Value=aGor;
    xls.Workbooks.Item(name).Worksheets.Item(3).Range("AL15").Value=aNas;
    xls.Workbooks.Item(name).Worksheets.Item(3).Range("AL16").Value=aStr;
    xls.Workbooks.Item(name).Worksheets.Item(3).Range("AL17").Value=aDom;
    xls.Workbooks.Item(name).Worksheets.Item(3).Range("AL18").Value=aKor;
    xls.Workbooks.Item(name).Worksheets.Item(3).Range("AL19").Value=aKva;
    xls.Workbooks.Item(name).Worksheets.Item(3).Range("V28").Value=static_cast_to_string(Rtrim(Org));
    }

    if (ORG==3)
    {
    xls.Workbooks.Item(name).Worksheets.Item(3).Range("U51").Value=aTel;
    xls.Workbooks.Item(name).Worksheets.Item(3).Range("AL64").Value =ai0;
    xls.Workbooks.Item(name).Worksheets.Item(3).Range("AN64").Value =ai1;
    xls.Workbooks.Item(name).Worksheets.Item(3).Range("AQ64").Value =ai2;
    xls.Workbooks.Item(name).Worksheets.Item(3).Range("AT64").Value =ai3;
    xls.Workbooks.Item(name).Worksheets.Item(3).Range("AV64").Value=ai4;
    xls.Workbooks.Item(name).Worksheets.Item(3).Range("AY64").Value=ai5;
    xls.Workbooks.Item(name).Worksheets.Item(3).Range("AL65").Value=aReg;
    xls.Workbooks.Item(name).Worksheets.Item(3).Range("BV65").Value=aKodReg0;
    xls.Workbooks.Item(name).Worksheets.Item(3).Range("BX65").Value=aKodReg1;
    xls.Workbooks.Item(name).Worksheets.Item(3).Range("AL66").Value=aRai;
    xls.Workbooks.Item(name).Worksheets.Item(3).Range("AL67").Value=aGor;
    xls.Workbooks.Item(name).Worksheets.Item(3).Range("AL68").Value=aNas;
    xls.Workbooks.Item(name).Worksheets.Item(3).Range("AL69").Value=aStr;
    xls.Workbooks.Item(name).Worksheets.Item(3).Range("AL70").Value=aDom;
    xls.Workbooks.Item(name).Worksheets.Item(3).Range("AL71").Value=aKor;
    xls.Workbooks.Item(name).Worksheets.Item(3).Range("AL72").Value=aKva;
    }

    // 4-й лист
    xls.Workbooks.Item(name).Worksheets.Item(4).Range("E13").Value=static_cast_to_string(s0100_3);
    xls.Workbooks.Item(name).Worksheets.Item(4).Range("H13").Value=static_cast_to_string(s0100_5);
    xls.Workbooks.Item(name).Worksheets.Item(4).Range("J13").Value=static_cast_to_string(s0100_7);
    xls.Workbooks.Item(name).Worksheets.Item(4).Range("L13").Value=static_cast_to_string(s0100_9);

    xls.Workbooks.Item(name).Worksheets.Item(4).Range("E15").Value=static_cast_to_string(s0110_3);
    xls.Workbooks.Item(name).Worksheets.Item(4).Range("H15").Value=static_cast_to_string(s0110_5);
    xls.Workbooks.Item(name).Worksheets.Item(4).Range("J15").Value=static_cast_to_string(s0110_7);
    xls.Workbooks.Item(name).Worksheets.Item(4).Range("L15").Value=static_cast_to_string(s0110_9);

    xls.Workbooks.Item(name).Worksheets.Item(4).Range("E17").Value=static_cast_to_string(s0120_3);
    xls.Workbooks.Item(name).Worksheets.Item(4).Range("H17").Value=static_cast_to_string(s0120_5);
    xls.Workbooks.Item(name).Worksheets.Item(4).Range("J17").Value=static_cast_to_string(s0120_7);
    xls.Workbooks.Item(name).Worksheets.Item(4).Range("L17").Value=static_cast_to_string(s0120_9);

    xls.Workbooks.Item(name).Worksheets.Item(4).Range("E18").Value=static_cast_to_string(s0130_3);
    xls.Workbooks.Item(name).Worksheets.Item(4).Range("H18").Value=static_cast_to_string(s0130_5);
    xls.Workbooks.Item(name).Worksheets.Item(4).Range("J18").Value=static_cast_to_string(s0130_7);
    xls.Workbooks.Item(name).Worksheets.Item(4).Range("L18").Value=static_cast_to_string(s0130_9);

    xls.Workbooks.Item(name).Worksheets.Item(4).Range("E19").Value=static_cast_to_string(s0140_3);
    xls.Workbooks.Item(name).Worksheets.Item(4).Range("H19").Value=static_cast_to_string(s0140_5);
    xls.Workbooks.Item(name).Worksheets.Item(4).Range("J19").Value=static_cast_to_string(s0140_7);
    xls.Workbooks.Item(name).Worksheets.Item(4).Range("L19").Value=static_cast_to_string(s0140_9);

    xls.Workbooks.Item(name).Worksheets.Item(4).Range("E20").Value=static_cast_to_string(s0200_3);
    xls.Workbooks.Item(name).Worksheets.Item(4).Range("H20").Value=static_cast_to_string(s0200_5);
    xls.Workbooks.Item(name).Worksheets.Item(4).Range("J20").Value=static_cast_to_string(s0200_7);
    xls.Workbooks.Item(name).Worksheets.Item(4).Range("L20").Value=static_cast_to_string(s0200_9);

    xls.Workbooks.Item(name).Worksheets.Item(4).Range("E24").Value=static_cast_to_string(s0210_3);
    xls.Workbooks.Item(name).Worksheets.Item(4).Range("H24").Value=static_cast_to_string(s0210_5);
    xls.Workbooks.Item(name).Worksheets.Item(4).Range("J24").Value=static_cast_to_string(s0210_7);
    xls.Workbooks.Item(name).Worksheets.Item(4).Range("L24").Value=static_cast_to_string(s0210_9);

    xls.Workbooks.Item(name).Worksheets.Item(4).Range("E26").Value=static_cast_to_string(s0220_3);
    xls.Workbooks.Item(name).Worksheets.Item(4).Range("H26").Value=static_cast_to_string(s0220_5);
    xls.Workbooks.Item(name).Worksheets.Item(4).Range("J26").Value=static_cast_to_string(s0220_7);
    xls.Workbooks.Item(name).Worksheets.Item(4).Range("L26").Value=static_cast_to_string(s0220_9);

    xls.Workbooks.Item(name).Worksheets.Item(4).Range("E27").Value=static_cast_to_string(s0230_3);
    xls.Workbooks.Item(name).Worksheets.Item(4).Range("H27").Value=static_cast_to_string(s0230_5);
    xls.Workbooks.Item(name).Worksheets.Item(4).Range("J27").Value=static_cast_to_string(s0230_7);
    xls.Workbooks.Item(name).Worksheets.Item(4).Range("L27").Value=static_cast_to_string(s0230_9);

    xls.Workbooks.Item(name).Worksheets.Item(4).Range("E28").Value=static_cast_to_string(s0240_3);
    xls.Workbooks.Item(name).Worksheets.Item(4).Range("H28").Value=static_cast_to_string(s0240_5);
    xls.Workbooks.Item(name).Worksheets.Item(4).Range("J28").Value=static_cast_to_string(s0240_7);
    xls.Workbooks.Item(name).Worksheets.Item(4).Range("L28").Value=static_cast_to_string(s0240_9);

    xls.Workbooks.Item(name).Worksheets.Item(4).Range("E29").Value=static_cast_to_string(s0300_3);
    xls.Workbooks.Item(name).Worksheets.Item(4).Range("H29").Value=static_cast_to_string(s0300_5);
    xls.Workbooks.Item(name).Worksheets.Item(4).Range("J29").Value=static_cast_to_string(s0300_7);
    xls.Workbooks.Item(name).Worksheets.Item(4).Range("L29").Value=static_cast_to_string(s0300_9);

    xls.Workbooks.Item(name).Worksheets.Item(4).Range("E33").Value=static_cast_to_string(s0310_3);
    xls.Workbooks.Item(name).Worksheets.Item(4).Range("H33").Value=static_cast_to_string(s0310_5);
    xls.Workbooks.Item(name).Worksheets.Item(4).Range("J33").Value=static_cast_to_string(s0310_7);
    xls.Workbooks.Item(name).Worksheets.Item(4).Range("L33").Value=static_cast_to_string(s0310_9);

    xls.Workbooks.Item(name).Worksheets.Item(4).Range("E33").Value=static_cast_to_string(s0310_3);
    xls.Workbooks.Item(name).Worksheets.Item(4).Range("H33").Value=static_cast_to_string(s0310_5);
    xls.Workbooks.Item(name).Worksheets.Item(4).Range("J33").Value=static_cast_to_string(s0310_7);
    xls.Workbooks.Item(name).Worksheets.Item(4).Range("L33").Value=static_cast_to_string(s0310_9);

    xls.Workbooks.Item(name).Worksheets.Item(4).Range("E35").Value=static_cast_to_string(s0320_3);
    xls.Workbooks.Item(name).Worksheets.Item(4).Range("H35").Value=static_cast_to_string(s0320_5);
    xls.Workbooks.Item(name).Worksheets.Item(4).Range("J35").Value=static_cast_to_string(s0320_7);
    xls.Workbooks.Item(name).Worksheets.Item(4).Range("L35").Value=static_cast_to_string(s0320_9);

    xls.Workbooks.Item(name).Worksheets.Item(4).Range("E36").Value=static_cast_to_string(s0330_3);
    xls.Workbooks.Item(name).Worksheets.Item(4).Range("H36").Value=static_cast_to_string(s0330_5);
    xls.Workbooks.Item(name).Worksheets.Item(4).Range("J36").Value=static_cast_to_string(s0330_7);
    xls.Workbooks.Item(name).Worksheets.Item(4).Range("L36").Value=static_cast_to_string(s0330_9);

    xls.Workbooks.Item(name).Worksheets.Item(4).Range("E37").Value=static_cast_to_string(s0340_3);
    xls.Workbooks.Item(name).Worksheets.Item(4).Range("H37").Value=static_cast_to_string(s0340_5);
    xls.Workbooks.Item(name).Worksheets.Item(4).Range("J37").Value=static_cast_to_string(s0340_7);
    xls.Workbooks.Item(name).Worksheets.Item(4).Range("L37").Value=static_cast_to_string(s0340_9);

    xls.Workbooks.Item(name).Worksheets.Item(4).Range("H38").Value=static_cast_to_string(s0400_5);
    xls.Workbooks.Item(name).Worksheets.Item(4).Range("J38").Value=static_cast_to_string(s0400_7);
    xls.Workbooks.Item(name).Worksheets.Item(4).Range("L38").Value=static_cast_to_string(s0400_9);

    xls.Workbooks.Item(name).Worksheets.Item(4).Range("H41").Value=static_cast_to_string(s0410_5);
    xls.Workbooks.Item(name).Worksheets.Item(4).Range("J41").Value=static_cast_to_string(s0410_7);
    xls.Workbooks.Item(name).Worksheets.Item(4).Range("L41").Value=static_cast_to_string(s0410_9);

    xls.Workbooks.Item(name).Worksheets.Item(4).Range("H43").Value=static_cast_to_string(s0420_5);
    xls.Workbooks.Item(name).Worksheets.Item(4).Range("J43").Value=static_cast_to_string(s0420_7);
    xls.Workbooks.Item(name).Worksheets.Item(4).Range("L43").Value=static_cast_to_string(s0420_9);

    xls.Workbooks.Item(name).Worksheets.Item(4).Range("H44").Value=static_cast_to_string(s0430_5);
    xls.Workbooks.Item(name).Worksheets.Item(4).Range("J44").Value=static_cast_to_string(s0430_7);
    xls.Workbooks.Item(name).Worksheets.Item(4).Range("L44").Value=static_cast_to_string(s0430_9);

    xls.Workbooks.Item(name).Worksheets.Item(4).Range("H45").Value=static_cast_to_string(s0440_5);
    xls.Workbooks.Item(name).Worksheets.Item(4).Range("J45").Value=static_cast_to_string(s0440_7);
    xls.Workbooks.Item(name).Worksheets.Item(4).Range("L45").Value=static_cast_to_string(s0440_9);

    if (RFLAG1==1)
    xls.Workbooks.Item(name).Worksheets.Item(4).Range("C48").Value=static_cast_to_string("--------");
    else    
    xls.Workbooks.Item(name).Worksheets.Item(4).Range("D48").Value=static_cast_to_string("--------");

    if (RFLAG2==1)
    xls.Workbooks.Item(name).Worksheets.Item(4).Range("C50").Value=static_cast_to_string("--------");
    else    
    xls.Workbooks.Item(name).Worksheets.Item(4).Range("D50").Value=static_cast_to_string("--------");

    if (RFLAG3==1)
    xls.Workbooks.Item(name).Worksheets.Item(4).Range("C52").Value=static_cast_to_string("--------");
    else    
    xls.Workbooks.Item(name).Worksheets.Item(4).Range("D52").Value=static_cast_to_string("--------");
   
    // 5-й лист
    xls.Workbooks.Item(name).Worksheets.Item(5).Range("AI13").Value=static_cast_to_string(s010_3);
    xls.Workbooks.Item(name).Worksheets.Item(5).Range("AS13").Value=static_cast_to_string(s010_4);
    xls.Workbooks.Item(name).Worksheets.Item(5).Range("BJ13").Value=static_cast_to_string(s010_5);

    xls.Workbooks.Item(name).Worksheets.Item(5).Range("AI15").Value=static_cast_to_string(s011_3);
    xls.Workbooks.Item(name).Worksheets.Item(5).Range("AS15").Value=static_cast_to_string(s011_4);
    xls.Workbooks.Item(name).Worksheets.Item(5).Range("BJ15").Value=static_cast_to_string(s011_5);

    xls.Workbooks.Item(name).Worksheets.Item(5).Range("AI16").Value=static_cast_to_string(s012_3);
    xls.Workbooks.Item(name).Worksheets.Item(5).Range("AS16").Value=static_cast_to_string(s012_4);
    xls.Workbooks.Item(name).Worksheets.Item(5).Range("BJ16").Value=static_cast_to_string(s012_5);

    xls.Workbooks.Item(name).Worksheets.Item(5).Range("AI17").Value=static_cast_to_string(s013_3);
    xls.Workbooks.Item(name).Worksheets.Item(5).Range("AS17").Value=static_cast_to_string(s013_4);
    xls.Workbooks.Item(name).Worksheets.Item(5).Range("BJ17").Value=static_cast_to_string(s013_5);

    xls.Workbooks.Item(name).Worksheets.Item(5).Range("AI18").Value=static_cast_to_string(s014_3);
    xls.Workbooks.Item(name).Worksheets.Item(5).Range("AS18").Value=static_cast_to_string(s014_4);
    xls.Workbooks.Item(name).Worksheets.Item(5).Range("BJ18").Value=static_cast_to_string(s014_5);

    xls.Workbooks.Item(name).Worksheets.Item(5).Range("AI19").Value=static_cast_to_string(s015_3);
    xls.Workbooks.Item(name).Worksheets.Item(5).Range("AS19").Value=static_cast_to_string(s015_4);
    xls.Workbooks.Item(name).Worksheets.Item(5).Range("BJ19").Value=static_cast_to_string(s015_5);

    xls.Workbooks.Item(name).Worksheets.Item(5).Range( "P37").Value=static_cast_to_string(s100_3);
    xls.Workbooks.Item(name).Worksheets.Item(5).Range( "T37").Value=static_cast_to_string(P1T5);
    xls.Workbooks.Item(name).Worksheets.Item(5).Range( "X37").Value=static_cast_to_string(s100_5);
    xls.Workbooks.Item(name).Worksheets.Item(5).Range("AB37").Value=static_cast_to_string(s100_6);
    xls.Workbooks.Item(name).Worksheets.Item(5).Range("AG37").Value=static_cast_to_string(s100_7);
    xls.Workbooks.Item(name).Worksheets.Item(5).Range("AK37").Value=static_cast_to_string(P1T71);
    xls.Workbooks.Item(name).Worksheets.Item(5).Range("AO37").Value=static_cast_to_string(s100_9);
    xls.Workbooks.Item(name).Worksheets.Item(5).Range("AS37").Value=static_cast_to_string(P1T72);
    xls.Workbooks.Item(name).Worksheets.Item(5).Range("AW37").Value=static_cast_to_string(s100_11);
    xls.Workbooks.Item(name).Worksheets.Item(5).Range("BA37").Value=static_cast_to_string(s100_12);
    xls.Workbooks.Item(name).Worksheets.Item(5).Range("BE37").Value=static_cast_to_string(s100_13); 
    xls.Workbooks.Item(name).Worksheets.Item(5).Range("BI37").Value=static_cast_to_string(P1T91);
    xls.Workbooks.Item(name).Worksheets.Item(5).Range("BM37").Value=static_cast_to_string(s100_15);
    xls.Workbooks.Item(name).Worksheets.Item(5).Range("BQ37").Value=static_cast_to_string(P1T92);
    xls.Workbooks.Item(name).Worksheets.Item(5).Range("BU37").Value=static_cast_to_string(s100_17);
    xls.Workbooks.Item(name).Worksheets.Item(5).Range("BZ37").Value=static_cast_to_string(s100_18);

    xls.Workbooks.Item(name).Worksheets.Item(5).Range( "P38").Value=static_cast_to_string(s200_3);
    xls.Workbooks.Item(name).Worksheets.Item(5).Range( "X38").Value=static_cast_to_string(s200_5);
    xls.Workbooks.Item(name).Worksheets.Item(5).Range("AB38").Value=static_cast_to_string(s200_6);
    xls.Workbooks.Item(name).Worksheets.Item(5).Range("AG38").Value=static_cast_to_string(s200_7);
    xls.Workbooks.Item(name).Worksheets.Item(5).Range("AO38").Value=static_cast_to_string(s200_9);
    xls.Workbooks.Item(name).Worksheets.Item(5).Range("AW38").Value=static_cast_to_string(s200_11);
    xls.Workbooks.Item(name).Worksheets.Item(5).Range("BA38").Value=static_cast_to_string(s200_12);
    xls.Workbooks.Item(name).Worksheets.Item(5).Range("BE38").Value=static_cast_to_string(s200_13); 
    xls.Workbooks.Item(name).Worksheets.Item(5).Range("BM38").Value=static_cast_to_string(s200_15);
    xls.Workbooks.Item(name).Worksheets.Item(5).Range("BU38").Value=static_cast_to_string(s200_17);
    xls.Workbooks.Item(name).Worksheets.Item(5).Range("BZ38").Value=static_cast_to_string(s200_18);

    xls.Workbooks.Item(name).Worksheets.Item(5).Range( "P40").Value=static_cast_to_string(s210_3);
    xls.Workbooks.Item(name).Worksheets.Item(5).Range( "T40").Value=static_cast_to_string(P3T5);
    xls.Workbooks.Item(name).Worksheets.Item(5).Range( "X40").Value=static_cast_to_string(s210_5);
    xls.Workbooks.Item(name).Worksheets.Item(5).Range("AG40").Value=static_cast_to_string(s210_7);
    xls.Workbooks.Item(name).Worksheets.Item(5).Range("AK40").Value=static_cast_to_string(P3T71);
    xls.Workbooks.Item(name).Worksheets.Item(5).Range("AO40").Value=static_cast_to_string(s210_9);
    xls.Workbooks.Item(name).Worksheets.Item(5).Range("AS40").Value=static_cast_to_string(P3T72);
    xls.Workbooks.Item(name).Worksheets.Item(5).Range("AW40").Value=static_cast_to_string(s210_11);
    xls.Workbooks.Item(name).Worksheets.Item(5).Range("BE40").Value=static_cast_to_string(s210_13); 
    xls.Workbooks.Item(name).Worksheets.Item(5).Range("BI40").Value=static_cast_to_string(P3T91);
    xls.Workbooks.Item(name).Worksheets.Item(5).Range("BM40").Value=static_cast_to_string(s210_15);
    xls.Workbooks.Item(name).Worksheets.Item(5).Range("BQ40").Value=static_cast_to_string(P3T92);
    xls.Workbooks.Item(name).Worksheets.Item(5).Range("BU40").Value=static_cast_to_string(s210_17);

    xls.Workbooks.Item(name).Worksheets.Item(5).Range( "P41").Value=static_cast_to_string(s220_3);
    xls.Workbooks.Item(name).Worksheets.Item(5).Range( "T41").Value=static_cast_to_string(P4T5);
    xls.Workbooks.Item(name).Worksheets.Item(5).Range( "X41").Value=static_cast_to_string(s220_5);
    xls.Workbooks.Item(name).Worksheets.Item(5).Range("AG41").Value=static_cast_to_string(s220_7);
    xls.Workbooks.Item(name).Worksheets.Item(5).Range("AK41").Value=static_cast_to_string(P4T71);
    xls.Workbooks.Item(name).Worksheets.Item(5).Range("AO41").Value=static_cast_to_string(s220_9);
    xls.Workbooks.Item(name).Worksheets.Item(5).Range("AS41").Value=static_cast_to_string(P4T72);
    xls.Workbooks.Item(name).Worksheets.Item(5).Range("AW41").Value=static_cast_to_string(s220_11);
    xls.Workbooks.Item(name).Worksheets.Item(5).Range("BE41").Value=static_cast_to_string(s220_13); 
    xls.Workbooks.Item(name).Worksheets.Item(5).Range("BI41").Value=static_cast_to_string(P4T91);
    xls.Workbooks.Item(name).Worksheets.Item(5).Range("BM41").Value=static_cast_to_string(s220_15);
    xls.Workbooks.Item(name).Worksheets.Item(5).Range("BQ41").Value=static_cast_to_string(P4T92);
    xls.Workbooks.Item(name).Worksheets.Item(5).Range("BU41").Value=static_cast_to_string(s220_17);

    xls.Workbooks.Item(name).Worksheets.Item(5).Range( "P42").Value=static_cast_to_string(s300_3);
    xls.Workbooks.Item(name).Worksheets.Item(5).Range( "X42").Value=static_cast_to_string(s300_5);
    xls.Workbooks.Item(name).Worksheets.Item(5).Range("AB42").Value=static_cast_to_string(s300_6);
    xls.Workbooks.Item(name).Worksheets.Item(5).Range("AG42").Value=static_cast_to_string(s300_7);
    xls.Workbooks.Item(name).Worksheets.Item(5).Range("AO42").Value=static_cast_to_string(s300_9);
    xls.Workbooks.Item(name).Worksheets.Item(5).Range("AW42").Value=static_cast_to_string(s300_11);
    xls.Workbooks.Item(name).Worksheets.Item(5).Range("BA42").Value=static_cast_to_string(s300_12);
    xls.Workbooks.Item(name).Worksheets.Item(5).Range("BE42").Value=static_cast_to_string(s300_13); 
    xls.Workbooks.Item(name).Worksheets.Item(5).Range("BM42").Value=static_cast_to_string(s300_15);
    xls.Workbooks.Item(name).Worksheets.Item(5).Range("BU42").Value=static_cast_to_string(s300_17);
    xls.Workbooks.Item(name).Worksheets.Item(5).Range("BZ42").Value=static_cast_to_string(s300_18);

    xls.Workbooks.Item(name).Worksheets.Item(5).Range( "P44").Value=static_cast_to_string(s310_3);
    xls.Workbooks.Item(name).Worksheets.Item(5).Range( "T44").Value=static_cast_to_string(P6T5);
    xls.Workbooks.Item(name).Worksheets.Item(5).Range( "X44").Value=static_cast_to_string(s310_5);
    xls.Workbooks.Item(name).Worksheets.Item(5).Range("AG44").Value=static_cast_to_string(s310_7);
    xls.Workbooks.Item(name).Worksheets.Item(5).Range("AK44").Value=static_cast_to_string(P6T71);
    xls.Workbooks.Item(name).Worksheets.Item(5).Range("AO44").Value=static_cast_to_string(s310_9);
    xls.Workbooks.Item(name).Worksheets.Item(5).Range("AS44").Value=static_cast_to_string(P6T72);
    xls.Workbooks.Item(name).Worksheets.Item(5).Range("AW44").Value=static_cast_to_string(s310_11);
    xls.Workbooks.Item(name).Worksheets.Item(5).Range("BE44").Value=static_cast_to_string(s310_13); 
    xls.Workbooks.Item(name).Worksheets.Item(5).Range("BI44").Value=static_cast_to_string(P6T91);
    xls.Workbooks.Item(name).Worksheets.Item(5).Range("BM44").Value=static_cast_to_string(s310_15);
    xls.Workbooks.Item(name).Worksheets.Item(5).Range("BQ44").Value=static_cast_to_string(P6T92);
    xls.Workbooks.Item(name).Worksheets.Item(5).Range("BU44").Value=static_cast_to_string(s310_17);

    xls.Workbooks.Item(name).Worksheets.Item(5).Range( "P45").Value=static_cast_to_string(s320_3);
    xls.Workbooks.Item(name).Worksheets.Item(5).Range( "T45").Value=static_cast_to_string(P7T5);
    xls.Workbooks.Item(name).Worksheets.Item(5).Range( "X45").Value=static_cast_to_string(s320_5);
    xls.Workbooks.Item(name).Worksheets.Item(5).Range("AG45").Value=static_cast_to_string(s320_7);
    xls.Workbooks.Item(name).Worksheets.Item(5).Range("AK45").Value=static_cast_to_string(P7T71);
    xls.Workbooks.Item(name).Worksheets.Item(5).Range("AO45").Value=static_cast_to_string(s320_9);
    xls.Workbooks.Item(name).Worksheets.Item(5).Range("AS45").Value=static_cast_to_string(P7T72);
    xls.Workbooks.Item(name).Worksheets.Item(5).Range("AW45").Value=static_cast_to_string(s320_11);
    xls.Workbooks.Item(name).Worksheets.Item(5).Range("BE45").Value=static_cast_to_string(s320_13); 
    xls.Workbooks.Item(name).Worksheets.Item(5).Range("BI45").Value=static_cast_to_string(P7T91);
    xls.Workbooks.Item(name).Worksheets.Item(5).Range("BM45").Value=static_cast_to_string(s320_15);
    xls.Workbooks.Item(name).Worksheets.Item(5).Range("BQ45").Value=static_cast_to_string(P7T92);
    xls.Workbooks.Item(name).Worksheets.Item(5).Range("BU45").Value=static_cast_to_string(s320_17);

    xls.Workbooks.Item(name).Worksheets.Item(5).Range( "P46").Value=static_cast_to_string(s400_3);
    xls.Workbooks.Item(name).Worksheets.Item(5).Range( "T46").Value=static_cast_to_string(P0T5);
    xls.Workbooks.Item(name).Worksheets.Item(5).Range( "X46").Value=static_cast_to_string(s400_5);
    xls.Workbooks.Item(name).Worksheets.Item(5).Range("AB46").Value=static_cast_to_string(s400_6);
    xls.Workbooks.Item(name).Worksheets.Item(5).Range("AG46").Value=static_cast_to_string(s400_7);
    xls.Workbooks.Item(name).Worksheets.Item(5).Range("AK46").Value=static_cast_to_string(P0T71);
    xls.Workbooks.Item(name).Worksheets.Item(5).Range("AO46").Value=static_cast_to_string(s400_9);
    xls.Workbooks.Item(name).Worksheets.Item(5).Range("AS46").Value=static_cast_to_string(P0T72);
    xls.Workbooks.Item(name).Worksheets.Item(5).Range("AW46").Value=static_cast_to_string(s400_11);
    xls.Workbooks.Item(name).Worksheets.Item(5).Range("BA46").Value=static_cast_to_string(s400_12);
    xls.Workbooks.Item(name).Worksheets.Item(5).Range("BE46").Value=static_cast_to_string(s400_13); 
    xls.Workbooks.Item(name).Worksheets.Item(5).Range("BI46").Value=static_cast_to_string(P0T91);
    xls.Workbooks.Item(name).Worksheets.Item(5).Range("BM46").Value=static_cast_to_string(s400_15);
    xls.Workbooks.Item(name).Worksheets.Item(5).Range("BU46").Value=static_cast_to_string(s400_17);
    xls.Workbooks.Item(name).Worksheets.Item(5).Range("BZ46").Value=static_cast_to_string(s400_18);

    xls.Workbooks.Item(name).Worksheets.Item(5).Range( "P47").Value=static_cast_to_string(s500_3);
    xls.Workbooks.Item(name).Worksheets.Item(5).Range( "X47").Value=static_cast_to_string(s500_5);
    xls.Workbooks.Item(name).Worksheets.Item(5).Range("AB47").Value=static_cast_to_string(s500_6);
    xls.Workbooks.Item(name).Worksheets.Item(5).Range("AG47").Value=static_cast_to_string(s500_7);
    xls.Workbooks.Item(name).Worksheets.Item(5).Range("AO47").Value=static_cast_to_string(s500_9);
    xls.Workbooks.Item(name).Worksheets.Item(5).Range("AW47").Value=static_cast_to_string(s500_11);
    xls.Workbooks.Item(name).Worksheets.Item(5).Range("BA47").Value=static_cast_to_string(s500_12);
    xls.Workbooks.Item(name).Worksheets.Item(5).Range("BE47").Value=static_cast_to_string(s500_13); 
    xls.Workbooks.Item(name).Worksheets.Item(5).Range("BM47").Value=static_cast_to_string(s500_15);
    xls.Workbooks.Item(name).Worksheets.Item(5).Range("BU47").Value=static_cast_to_string(s500_17);
    xls.Workbooks.Item(name).Worksheets.Item(5).Range("BZ47").Value=static_cast_to_string(s500_18);

    xls.Visible=true;

   }
   catch(object err)
   {
      SayError(err);
   }
   catch(...)
   {
      ;
   }

  } // end if EXCEL==1

  // TRANSFER {
  if (FlgTrans==0)  
  {
    sprintf(Buffer,"###\r\n"); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0);
    sprintf(Buffer,"@@@\r\n"); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0);
    sprintf(Buffer,"===\r\n"); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0);

//    int digit=0;
//    double x=KolPokFOtch;
//
//    for (int i=0; i<10; i++)
//    {
//      x=x/10.;
//      digit++; 
//      if ( !static_cast_to_int(x) ) 
//      { 
//        break; 
//      }
//    }

    char RootPathName[20];
    double FileSize=SetFilePointer(hf,0,0,1);
    unsigned long SectorsPerCluster=0;
    unsigned long BytesPerSector=0;
    unsigned long NumberOfFreeClusters=0;
    unsigned long TotalNumberOfClusters=0;

    sprintf(RootPathName,"%s",PathStr);

//    SetFilePointer(hf,PointKolPok-(digit+2),0,0);
//    sprintf(Buffer,"%d",KolPokFOtch); WriteFile(hf,Buffer,strlen(Buffer),dwBytes,0);
    // <файл отчетности> end

    CloseHandle(hf);

///////////////////////////////////////////////////////////////////////////////

    char strBuff[250]; for (int i=0; i<250; i++) strBuff[i]=0;
    char mBuffer[100]; 
    sprintf(mBuffer,"КолПокФОтч:%d\r\n",KolPokFOtch);

    // читаем файл
    char rBuff[250]; rBuff[1]='\0';
    unsigned long lpNumberOfBytesRead=0;

    // открываем сформированный файл для чтения
    if ((hf=CreateFile(TmpFileName,-2147483648,1,0,3,128,0))==-1)
    {
      MessageBox(0,"эхтючьюцэю юЄъЁ√Є№ Їрщы 1","ю°шсър",0);
    }

    int hf1=0; // хэндл второго временного файла
    char TmpFileName1[250]; sprintf(TmpFileName1,"RasEsn1.tmp");

    // создаем второй временный файл (открываем для записи)
    if ((hf1=CreateFile(TmpFileName1,1073741824,1,0,1,128,0))==-1)
    {
      MessageBox(0,"эхтючьюцэю ёючфрЄ№ Їрщы 2","ю°шсър",0);
    }

    // идем по файлу
    while (1)
    {
      ReadFile(hf,rBuff,1,lpNumberOfBytesRead,0);
      sprintf(strBuff,"%s%s",strBuff,rBuff);
    
      if (rBuff[0]=='\n')
      {
        // запись во временный файл
        {
          if (strBuff=="КолПокФОтч:\r\n")
          {
            sprintf(Buffer,"%s",mBuffer); WriteFile(hf1,Buffer,strlen(Buffer),dwBytes,0);
          }
          else
          {
            sprintf(Buffer,"%s",strBuff); WriteFile(hf1,Buffer,strlen(Buffer),dwBytes,0);
          }
        }
        for (int i=0; i<250; i++) strBuff[i]=0;
      }
    
      long FilePointer=SetFilePointer(hf,0,0,1);
      if (FilePointer>=static_cast_to_long(FileSize)) break;
    }
    CloseHandle(hf);
    CloseHandle(hf1);

///////////////////////////////////////////////////////////////////////////////

    int iDisk=GetDiskFreeSpace(RootPathName,SectorsPerCluster,BytesPerSector,
                               NumberOfFreeClusters,TotalNumberOfClusters);

    double FreeSpace=static_cast_to_double(NumberOfFreeClusters) *
                     static_cast_to_double(SectorsPerCluster) *
                     static_cast_to_double(BytesPerSector);

    if (iDisk==0)
    {
      MessageBox(0,"єёЄЁющёЄтю эх уюЄютю\nЇрщы эх сєфхЄ ёючфрэ","ю°шсър",0);
      DeleteFile(TmpFileName);
      DeleteFile(TmpFileName1);
    }
    else
    {
      if (FreeSpace<FileSize)
      {
        MessageBox(0,"эр фшёъх эхфюёЄрЄюўэю ьхёЄр\nЇрщы эх сєфхЄ ёючфрэ","ю°шсър",0);
        DeleteFile(TmpFileName);
        DeleteFile(TmpFileName1);
      }
      else
      {
        DeleteFile(NameStr);
        CopyFile(TmpFileName1,NameStr,0);
        DeleteFile(TmpFileName);
        DeleteFile(TmpFileName1);
      }
    }
  }
  // TRANSFER }

  return 0;
}


prntPF_DL( &Str, Tip, Dop )
// назначение: печать строки 
// параметры:  Str - строка для печати
//             Tip - действия перед печатью строки
//             Dop - действия после печати строки
{                       
  int CountLine;        
  // если тип бумаги - рулон, то никаких действий не выполняем
  if (KindPaper_DL)     
  {                     
    CountLine=CFile_DL.GetLineCounter();
    switch (Tip)        
    {                   
      case 1:           
        if (CountLine>=SizePage_DL)
        {               
          // CFile_DL.ListFeed();
        }               
        break;
    }                   
  }                     
                        
  print(Str);           
                        
  // если тип бумаги - рулон, то никаких действий не выполняем
  if (KindPaper_DL)     
  {                     
    CountLine=CFile_DL.GetLineCounter();
    switch (Dop)
    {
      case 1:
        break;

      case 2:
        break;

    }
  }                     
                        
  return 0;             
}                       


dTransPF_DL(str1,&str2)
// преобразлвание значения double для передачи в файл
{
  double fdTmp=atof(str1); 
  if (nabs(fdTmp)>0.001) 
  { 
    sprintf(str2,"%15.2f",fdTmp); 
    FreeSpaceString(str2,3,""); 
  } 
  else sprintf(str2,"0.00");
  return 0;
}

iTransPF_DL(str1,&str2)
// преобразлвание значения int для передачи в файл
{
  int fiTmp=atoi(str1); 
  if (nabs(fiTmp)>0) 
  { 
    sprintf(str2,"%d",fiTmp); 
    FreeSpaceString(str2,3,""); 
  } 
  else sprintf(str2,"0");
  return 0;
}

// Формат расчета по авансовым платежам по страховым взносам:
//
// <форма отчетности>::=<описание формы><конец блока>
//                      <содержание формы>
// 
// <содержание формы>::=<Раздел 0(Таблица 2)><конец блока>
//                      <Раздел 1(Таблица 3)><конец блока>
//                      <Раздел 2(Таблица 4)><конец блока>
//                      <Раздел 3(Таблица 5)><конец блока>
