void clicked()
{
int64 i;
int64 Line;
int64 LineMax;
int MaxLen;
str LabelId;
str LabelFr;
str DescriptionFr;
str LabelEn;
str DescriptionEn;
str LabelEnUs;
str DescriptionEnUs;
str LabelDe;
str DescriptionDe;
container c;
Label SysLabelfr;
Label SysLabelen;
Label SysLabelenus;
Label SysLabelen_us;
Label SysLabelde;
#File
TextIo FileToWriteFr;
TextIo FileToWriteEn;
TextIo FileToWriteEnUs;
TextIo FileToWriteDe;
TextIo FileToRead;
TextIo FileToReadNumberLine;
boolean Write = false;
Str ModuleId = Group_ModuleId_Import.text();
FilePath Directory = Directory_Of_File_Imported.text();
SysLabelfr = new Label("fr");
SysLabelen = new Label("en");
SysLabelenus = new Label("en-us");
SysLabelen_us = new Label("en_us");
SysLabelde = new Label("de");
super();
Write = WriteFile.value();
if(Group_FileName_To_Import.text() =="")
{
checkFailed("@SYS661");
return;
}
if(Directory =="")
{
checkFailed("@SYS660");
return;
}
FileToReadNumberLine = new TextIo(Group_FileName_To_Import.text(), #io_read);//#io_read lecture par defaut,#io_read write par defaut;
if (!FileToReadNumberLine)
{
throw error("@SYS658");
}
FileToReadNumberLine.inFieldDelimiter(";");//Si on ne parametre pas le ";" dans macro ->
FileToReadNumberLine.inRecordDelimiter(#delimiterCRLF); //CRLF = Carriage Return Line Feed
c = FileToReadNumberLine.read();
while (FileToReadNumberLine.status() == IO_Status::Ok )
{
LineMax++;
c = FileToReadNumberLine.read();
}
FileToRead = new TextIo(Group_FileName_To_Import.text(), #io_read);//#io_read lecture par defaut,#io_read write par defaut;
if (!FileToRead)
{
throw error("@SYS658");
}
if(Write)
{
FileToWriteFr = new TextIo(Directory+"\\Ax"+ModuleId+"fr.ald", #io_write,0);//#io_read lecture par defaut,#io_read write par defaut;
if (!FileToWriteFr)
{
throw error("@SYS577");
}
}
if(CheckBoxImportEn.value()==1 && write)
{
FileToWriteEn = new TextIo(Directory+"\\Ax"+ModuleId+"en.ald", #io_write,0);//#io_read lecture par defaut,#io_read write par defaut;
if (!FileToWriteEn)
{
throw error("@SYS577");
}
}
if(CheckBoxImportEnUs.value()==1 && write)
{
FileToWriteEnUs = new TextIo(Directory+"\\Ax"+ModuleId+"en-us.ald", #io_write,0);//#io_read lecture par defaut,#io_read write par defaut;
if (!FileToWriteEnUs)
{
throw error("@SYS577");
}
}
if(CheckBoxImportDe.value()==1 && write)
{
FileToWriteDe = new TextIo(Directory+"\\Ax"+ModuleId+"de.ald", #io_write,0);//#io_read lecture par defaut,#io_read write par defaut;
if (!FileToWriteDe)
{
throw error("@SYS577");
}
}
FileToRead.inFieldDelimiter(";");//Si on ne parametre pas le ";" dans macro ->
FileToRead.inRecordDelimiter(#delimiterCRLF); //CRLF = Carriage Return Line Feed
startLengthyOperation();
c = FileToRead.read();
Progress.step(6);
//Box::info(int2str(conLen(c)));
MaxLen = conLen(c);//Max colonne
while (FileToRead.status() == IO_Status::Ok )
{
Line++;
LabelId = conPeek(c, 1);
LabelFr = conPeek(c, 2);
DescriptionFr = conPeek(c, 3);
DescriptionFr = element.format(DescriptionFr);
/*if(subStr(LabelId,2,7) == "SYS511")
{
beep();
}*/
if(Line!=1)//conLen(c) Nombre d'élément de la ligne
{
Progress.pos(Line*100/LineMax);
/*element.Progress.visible(true);
element.Progress.setText(strfmt("Step %1", Line*100/LineMax));
Progress.incCount();*/
if(LabelFr != "")
{
if(Write) FileToWriteFr.write(LabelId+" "+LabelFr);
SysLabelfr.delete(LabelId);
SysLabelfr.modify(LabelId,LabelFr,DescriptionFr);
}
if(DescriptionFr != "") if(Write) FileToWriteFr.write(DescriptionFr);
if(CheckBoxImportEn.value()==1 && conLen(c)>=4)
{
LabelEn = conPeek(c, 4);
DescriptionEn = conPeek(c, 5);
DescriptionEn = element.format(DescriptionEn);
if(LabelEn != "")
{
if(Write) FileToWriteEn.write(LabelId+" "+LabelEn);
}
SysLabelen.delete(LabelId);
SysLabelen.modify(LabelId,Labelen,Descriptionen);
if(DescriptionEn != "") if(Write) FileToWriteEn.write(DescriptionEn);
}
if(CheckBoxImportEnUs.value()==1 && conLen(c)>=4+CheckBoxImporten.value()*2)
{
LabelEnUs = conPeek(c, 4+CheckBoxImporten.value()*2);
DescriptionEnUs = conPeek(c, 5+CheckBoxImporten.value()*2);
DescriptionEnUs = element.format(DescriptionEnUs);
if(LabelEnUs != "")
{
if(Write) FileToWriteEnUs.write(LabelId+" "+LabelEnUs);
}
//if(subStr(LabelId,2,7) == "SYS57")
// Box::info(DescriptionEnUs,LabelEnUs);
SysLabelenus.delete(LabelId);
SysLabelEn_Us.delete(LabelId);
SysLabelenus.modify(LabelId,LabelEnUs,DescriptionEnUs);
SysLabelEn_Us.modify(LabelId,LabelEnUs,DescriptionEnUs);
if(DescriptionEnUs != "") if(Write) FileToWriteEnUs.write(DescriptionEnUs);
}
if(CheckBoxImportDe.value()==1 && conLen(c)>=4+CheckBoxImporten.value()*2+CheckBoxImportenus.value()*2)
{
LabelDe = conPeek(c, 4+CheckBoxImporten.value()*2+CheckBoxImportenus.value()*2);
DescriptionDe = conPeek(c, 5+CheckBoxImporten.value()*2+CheckBoxImportenus.value()*2);
//if(DescriptionDe == " " || DescriptionDe == " " || DescriptionDe == " ") DescriptionDe = "";
DescriptionDe = element.format(DescriptionDe);
if(LabelDe != "")
{
if(Write) FileToWriteDe.write(LabelId+" "+LabelDe);
}
SysLabelde.delete(LabelId);
SysLabelde.modify(LabelId,Labelde,Descriptionde);
if(DescriptionDe != "") if(Write) FileToWriteEn.write(DescriptionDe);
}
}
c = FileToRead.read();
}
Progress.pos(0);
endLengthyOperation();
Box::info("@SYS657");
}
Aucun commentaire:
Enregistrer un commentaire