The Origin Forum
File Exchange
Try Origin for Free
The Origin Forum
Home | Profile | Register | Active Topics | Members | Search | FAQ | Send File to Tech support
Username:
Password:
Save Password
Forgot your Password? | Admin Options

 All Forums
 Origin Forum
 Origin Forum
 unzip, truncate, rezip
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

juannim

USA
Posts

Posted - 04/26/2007 :  12:33:08 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Version (Select Help-->About Origin): 7.5
Operating System:xp
I need to sort the first six (of ten) values of each column in the worksheet. The values are actually "zipped" (apparently as in the FFT output). I want to sort according to the odd rows, maintaining the association, and only shuffling the first six rows in the column. I can't get my values to copy back after sorting. What am I doing wrong? I would love to just "zip" back with the copy -z command, but can't figure out how to delete the blank data. Please help. Jonathan
[sort]
worksheet -c tsorta;
worksheet -c tsortb;//make space to sort
loop(i, 1, wks.ncols-3) {
copy -u wcol(i) col(tsorta) col(tsortb);//unzip the ten values of column i
mark -m %h_tsorta -b 4 -e 5;
mark -m %h_tsortb -b 4 -e 5;//eliminate last two cells in each of the unzipped-to columns
alpha=wks.ncols-1
beta=wks.ncols
sort -cd alpha beta %h_tsorta; //sort data
loop(ii,1,3) {
wcol(i)[2*ii-1]=col(tsorta)[ii];
wcol(i)[2*ii]=col(tsortb)[ii];//re-zip the sorted, non-blank values back to original columns
};
};

Mike Buess

USA
3037 Posts

Posted - 04/26/2007 :  2:11:12 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Jonathan,

Use the sort object instead of command because you can sort a range of rows for easier rezipping.

%W=%H; // save name of active wks
win -t D; /create new wks
%P=%H; // save its name
loop(ii,1,%W!wks.ncols) {
copy -u %(%W,ii) %(%P,1) %(%P,2); // unzip to %P
sort.wksName$=%P; // wks name
sort.c1=0; // sort all columns
sort.r1=1; // start with row 1
sort.r2=3; // stop with row 3
sort.cname1$=D: A; // sort descending w.r.t. col A
sort.wks(); // perform the sort
copy -z %(%P,1) %(%P,2) %(%W,ii); // rezip to %W
};
win -cd %P; // close sorting wks

Mike Buess
Origin WebRing Member
Go to Top of Page

juannim

USA
Posts

Posted - 04/30/2007 :  2:04:26 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Mike,
I finally made my script work (rigth after I got your reply). It seems that I only had to manipulate the lengths of the columns for it to work. Jonathan
worksheet -c tsorta;
worksheet -c tsortb;//make space to sort
loop(i, 1, wks.ncols-3) {
copy -u wcol(i) col(tsorta) col(tsortb);//unzip the ten values of column i
set col(tsorta) -es 3;
set col(tsortb) -es 3;
sort -cd (wks.ncols-1) (wks.ncols) %h_tsorta;//sort data
set col(tsorta) -es 5;
set col(tsortb) -es 5;
copy -z col(tsorta) col(tsortb) wcol(i);
//loop(ii,1,3) {
// cell(2*ii-1,i)=col(tsorta)[ii];
// cell(2*ii,i)=col(tsortb)[ii];//re-zip the sorted, non-blank values back to original columns
};
};
Go to Top of Page
  Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000