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
 Swapping multiple columns
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

Biotec12

Armenia
8 Posts

Posted - 02/26/2015 :  11:35:26 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Ver. OriginPro 8.6.0 (64-bit) Sr3
serial number: SF8T5-3089-7902432

Dear all,

I am trying to swap several columns using

for (ii = 1; ii < 326; ii=ii+2)
{colswap (ii, ii+1); }

However it is replying

#User Abort!

anyone know why?
In addition how to change all x columns to y and all ys to x?

Thanks in advance

Edited by - Biotec12 on 02/26/2015 11:44:39 AM

Hideo Fujii

USA
1582 Posts

Posted - 02/26/2015 :  1:12:52 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Biotec12,

This should work:
for (ii = 1; ii < 326; ii=ii+2)
 {colswap (%(ii), %(ii+1)); }
%(...) is needed to let the LabTalk interpreter resolve the variable as the argument in the command.

--Hideo Fujii
OriginLab
Go to Top of Page

meili_yang

103 Posts

Posted - 02/26/2015 :  1:19:10 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi,

Maybe try this to swap between every two columns:
for( ii = 1 ; ii <= wks.ncols-1; ii+=2)
{worksheet -s ii 0 ii+1 0;
colswap;
}

And this to change for example all x columns to y.
for( ii = 1 ; ii <= wks.ncols ; ii+=0)
{if (wks.col$(ii).type == 4)
wks.col$(ii).type = 1;
else ii+1;
}
Column type: 1 = Y, 2 = disregard, 3 = Y Error, 4 = X, 5 = Label, 6 = Z, and 7 = X Error

Meili

Meili
OriginLab Tech Support
Go to Top of Page

Biotec12

Armenia
8 Posts

Posted - 02/26/2015 :  2:20:02 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Dear Hideo Fujii dear Meili thanks for answers.

This code by Meili solved the issue
for( ii = 1 ; ii <= wks.ncols-1; ii+=2)
{worksheet -s ii 0 ii+1 0;
colswap;
}
Go to Top of Page

Biotec12

Armenia
8 Posts

Posted - 03/05/2015 :  03:53:30 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply

I modified your script to rename all x to y and all y to x

for( ii = 1 ; ii <= wks.ncols ; ii=ii+1)
{if (wks.col$(ii).type == 4)
wks.col$(ii).type = 1;
else wks.col$(ii).type = 4;
}

Edited by - Biotec12 on 03/05/2015 04:02:49 AM
Go to Top of Page

lic24

India
1 Posts

Posted - 03/07/2015 :  03:30:43 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Is swapping is possible for multiple rows

[URL=http://www.lic24.in]my personal blog[/URL]
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