StringBuilder sb = new StringBuilder();
int len=list.length();
int index=0;
char last=0,c;
if(pos<1) throw new FunctionException(pc,"ListDeleteAt",2,"index","index must be greater than 0");
pos--;
int i=0;
// ignore all delimiter at start
if(!includeEmptyFields)for(;i<len;i++){
c=list.charAt(i);
if(!equal(del,c)) break;
sb.append(c);
}
// before
for(;i<len;i++){
c=list.charAt(i);
if(index==pos && !equal(del,c)) break;
if(equal(del,c)) {
if(includeEmptyFields || !equal(del,last))
index++;
}
sb.append(c);
last=c;
}
// suppress item
for(;i<len;i++){
if(equal(del,list.charAt(i))) break;
}
// ignore following delimiter
for(;i<len;i++){
if(!equal(del,list.charAt(i))) break;
}
if(i==len){
while(sb.length()>0 && equal(del,sb.charAt(sb.length()-1))) {
sb.delete(sb.length()-1, sb.length());
}
if(pos>index) throw new FunctionException(pc,"ListDeleteAt",2,"index","index must be a integer between 1 and "+index);
return sb.toString();
}