Hi Stefan,
The reordering procedure suitable even for earlier Origin versions (8.6SR3) can be implemented as follows:
dataset dtTr={...};
// A loose dataset containing new column order - each value
// represents column number in the actual worksheet,
// for instance {3,5,1,4,2}, that is the third column
// should be moved to the first position, etc.
loop(ii,1,dtTr.GetSize()){
colmove r:=col($(dtTr[ii])) o:=last;
//Worksheet to reorder is assumed active, if not you should modify
// the "rng" parameter (r:=...)
loop(jj,ii+1,dtTr.GetSize()) {
if (dtTr[jj]>dtTr[ii]) dtTr[jj]-=1;
// modifying the "new order" dataset
// taking into account the changes after column moving
}
}
I just tried to simplify the code disregarding the performance. However this solution is not optimal - the number of X-function calls can be significantly reduced if the "colmove" X-function supports "pos" operation (requires more recent Origin versions). If the performance matters (that is very unlikely in this particular case) a bit more sophisticated solution can be suggested.
Regards,
Alexei