function splithalfcon(filename,filepath,parts,anzahlat);
%  

%   This software is protected by german copyright and international treaties.             
%   Copyright 2004 Markus Junghöfer & Peter Peyk. All Rights Reserved.                     
%                                                                                          
%   THIS SOFTWARE AND DOCUMENTATION IS PROVIDED "AS IS," AND COPYRIGHT HOLDERS MAKE        
%   NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO,    
%   WARRANTIES OF MERCHANTABILITY OR FITNESS FOR ANY PARTICULAR PURPOSE OR THAT THE USE    
%   OF THE SOFTWARE OR DOCUMENTATION WILL NOT INFRINGE ANY THIRD PARTY PATENTS, COPYRIGHTS,
%   TRADEMARKS OR OTHER RIGHTS. COPYRIGHT HOLDERS WILL NOT BE LIABLE FOR ANY DIRECT,       
%   INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF ANY USE OF THE SOFTWARE      
%   OR DOCUMENTATION.                                                                      

if nargin<3
    parts=2;
if nargin<2
    filepath=[]; end;
end

if ~isempty(filepath)
    file=[filepath,filename];
else file=filename;
end
[convec,supfile,suppath,supfilepath,sizedata] =readascii(file);
ats=cell(anzahlat,1);
convec=convec';
zaehler = 1;
convectmp = convec;
for j=2:length(convec)
    if convec(j)==convec(j-1)
        convectmp(j-1)=str2num([num2str(convec(j-1)) num2str(zaehler)]);
        zaehler = zaehler +1;    
    end
    if zaehler == parts
        convectmp(j)=str2num([num2str(convec(j)) num2str(zaehler)]);
        zaehler = 1;
    end

end;

convec = convectmp;
confilehandle=fopen(file,'rt');
savefile=strrep(file,'.CON','.CON_sh');
convec=convec';
savefilehandle=fopen(savefile,'wt');
fprintf(savefilehandle,[fgetl(confilehandle),'\n']);
line=fgets(confilehandle);
fprintf(savefilehandle,[num2str(convec'),'\n']);

while 1
    line=fgets(confilehandle);
    if ~isstr(line)
        break
    end
    fprintf(savefilehandle,line);
end

fclose(confilehandle);
delete(file);
fclose(savefilehandle);
savefilehandle=fopen(savefile,'rt');
helpvar=fscanf(savefilehandle,'%c');
savefilehandle2=fopen(strrep(savefile,'.CON_sh','.CON'),'wt');
fprintf(savefilehandle2,helpvar);
fclose(savefilehandle);
fclose(savefilehandle2);
delete(savefile);