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
 All Forums
 Origin Forum for Programming
 LabTalk Forum
 script divide columns

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

Screensize:
UserName:
Password:
Anti-Spam Code:
Format Mode:
Format: BoldItalicizedUnderlineStrikethrough Align LeftCenteredAlign Right Horizontal Rule Insert HyperlinkUpload FileInsert Image Insert CodeInsert QuoteInsert List
   
Message:

* HTML is OFF
* Forum Code is ON
Smilies
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Clown [:o)]
Black Eye [B)] Eight Ball [8] Frown [:(] Shy [8)]
Shocked [:0] Angry [:(!] Dead [xx(] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
It251 Posted - 01/14/2020 : 08:23:50 AM
I'm new to the forum and to scripting.

I would like to divide all Y columns (in a worksheet containing 100+ columns) by a specific one. How can I do this?

Thanks

It251
3   L A T E S T    R E P L I E S    (Newest First)
It251 Posted - 01/15/2020 : 11:54:11 AM
I solved it this way:

for (ii=2; ii<40; ii+2)
{Col($(ii))=Col($(ii))/Col(AN); }

for (ii=42; ii<=wks.ncols; ii+2)
{Col($(ii))=Col($(ii))/Col(AN); }

it's not very elegant... but works.

It251
It251 Posted - 01/15/2020 : 10:48:31 AM
Thank you very much Yuki.

I got to:

for (ii=2; ii<=wks.ncols; ii+2)
{Col($(ii))=Col($(ii))/Col(AN); }

The problem I got now is that when the script reaches column AN it does AN/AN=1 ... so all the subsequent columns get divided by 1. Is there any way of create an exception so the above operation doesn't apply to Col(AN)?


Regards

It251
yuki_wu Posted - 01/14/2020 : 9:17:56 PM
Hi It251,

To loop over columns in the worksheet:

//assume source data in [book1]sheet1!
int ncols = wks.ncols;
//add new worksheet for the results
newsheet name:=sheet2 cols:=ncols;
//activate the source data worksheet
page.active = 1;
//loop over columns in worksheet, and put the result in the corresponding column of new worksheet [book1]sheet2!
for(int ii = 1; ii <= ncols; ii++) {
	range ss = [book1]sheet1!col($(ii));
	range dd = [book1]sheet2!col($(ii));
	dd = ss/100;;
}

Hope it helps.

Regards, Yuki
OriginLab

The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000