char *first,*last,*Ext,*dot,*Name,*Fil;
Fil = new char[Filter.Length()+1];
Fil = Filter.c_str();
//strcpy2(Fil,Filter.c_str());
Name= new char[FileName.Length()+1];
strcpy2(Name,FileName.c_str());
dot=strrchr2(Name,'.');
while(dot){
Name[dot-Name]='\0';
FileName = Name;
dot=strrchr2(Name,'.');
}
if(FileExt.Length()!=0){
if(FileExt == ".txt")
this->SaveDialog1->FilterIndex = 2;
if(FileExt == ".rtf")
this->SaveDialog1->FilterIndex = 3;
Ext = new char[FileExt.Length()+1];
Ext = FileExt.c_str();
goto continu;
}
switch(this->SaveDialog1->FilterIndex){
case 1: first=strchr2(Fil,'|');
last=strchr2(first+1,'|');
Ext = new char[last-first];
strncpy2(Ext,first+2,(last-first)-2);
FileExt = Ext;
break;
case 2: first=strchr2(Fil,'|');
last=strchr2(first+1,'|');
first=strchr2(last+1,'|'); last=strchr2(first+1,'|');
Ext = new char[last-first];
strncpy2(Ext,first+2,(last-first)-2);
FileExt = Ext;
break;
case 3: first=strchr2(Fil,'|');
last=strchr2(first+1,'|');
first=strchr2(last+1,'|'); last=strchr2(first+1,'|');
first=strchr2(last+1,'|'); //last=strchr2(first+1,'|');
Ext = new char[StrLen(first)+1];
strcpy2(Ext,first+2);
FileExt = Ext;
default:;
}
continu:
delete[] Fil; //first et last pointent sur Fil.
if(FileExt != ".*"){
strcat2(Name,Ext);
FileName = Name; //function ChangeFileExt(const FileName: string;
const Extension: string): string;
this->SaveDialog1->FileName = FileName;
}
delete[] Ext;
delete[] Name;
}