Hi again, thitchen,
For columns' short names, the following may do the better job.
Here, shorter names will come first, and the names are treated case insensitively. ///////////////////////////////////////
nc=wks.ncols;
for(ii=nc; ii>1; ii--) {
for(jj=1; jj<ii; jj++) {
//for SHORT NAMES
str1$=Upper(wks.col$(jj).name$)$; len1=Len(str1$);
str2$=Upper(wks.col$(jj+1).name$)$; len2=Len(str2$);
ff=str1.Compare(str2$); //Comparison between this and nrxt
if((len1==len2 && ff>0) || len1>len2) { //when str1>str2, Move Right
colmove r:=wcol(jj) operation:=right;
}
}
}
/////////////////////////////////////////
Then, you can rename all column short names in regular naming convention,
i.e., A, B, C, etc. by the next script://////////////////////////////////////////////
wks1$=%H;
nc=wks.ncols;
window -t wks;
wks2$=%H;
//////////// Stage 1/3 //////////////////////
Break -b Stage 1 / 3; Break -r 1 (nc-2);
loop (ii, 1, nc-2) {Break -p ii; worksheet -a 1};
Break -end;
//////////// Stage 2/3 //////////////////////
Break -b Stage 2 / 3; Break -r 1 nc;
for(ii=1; ii<=nc; ii++) { Break -p ii;
col2$="oo"+wks.col$(ii).name$;
%(wks1$)!wks.col$(ii).name$="oo"+%(wks2$)!wks.col$(ii).name$;
}
Break -end;
window -a %(wks1$);
//////////// Stage 3/3 //////////////////////
Break -b Stage 3 / 3; Break -r 1 nc;
for(ii=1; ii<=nc; ii++) { Break -p ii;
str1$=wks.col$(ii).name$;
wks.col$(ii).name$=Mid(str1$,3,Len(str1$))$;
}
Break -end;
type -b $(nc) columns have been renamed.;
window -cd %(wks2$);
//////////////////////////////////////////////
--Hideo Fujii
OriginLab