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
 colcopy in for loop yields empty cols

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
JokerOne Posted - 09/06/2016 : 05:35:44 AM
Origin Ver. 9.1 and Service Release 3 (Select Help-->About Origin):
Operating System:Win 7

Hello everybody,

I found a strange behavior in the following code.
I am trying to copy a worksheet colum-wise (in a particular) manner to a second worksheet.
The colum order in the second worksheet is suppose to be
1 2 1 3 1 4 1 5,... where number indicate the colum numbers of the original worksheet.

newbook name:=Book2;

// newbook name:= Book2 sheet:=0; // using these two line, the script works as intended
// newsheet col :=0;

win - o Book1
{
int tmp_n_cols = wks.ncols;
for (loop_id=2; loop_id<=tmp_n_cols; loop_id++)
{

int target_col_first = (loop_id-1)*2-1;
int target_col_second = (loop_id-1)*2;
type $(target_col_first);
type $(target_col_second);

colcopy irng:=[Book1]Sheet1!Col(1) orng:=[Book2]Sheet1!Col($(tartget_col_first));
colcopy irng:=[Book1]Sheet1!Col($(loop_id)) orng:=[Book2]Sheet1!Col($(tartget_col_second));

};
}

The script basically works ok, however in the resulting workbook (Book2) the first two colums remain empty, which I cannot really tell why, as the variables
type $(target_col_first);
type $(target_col_second);
are clerly given out as 1 and 2?

When I start with a workbook without any colums (see commented code), I do not have this issue.

What is the reason behind this behaviour? Is this intended to be so or it is a bug potentially?

Thanks

2   L A T E S T    R E P L I E S    (Newest First)
JokerOne Posted - 09/06/2016 : 09:34:19 AM
I see.

And if the adressed orng is not existing, the next availabe col is automatically selected, I guess.

Ok, my bad, sorry.
However, you definately have to get used to Origin way of handling errors like that. Sometimes, it "almost" does what you want, even if you have typo, sometimes, the whole script crashes without any feedback.

Thank for pointing my error.
Chris D Posted - 09/06/2016 : 08:55:12 AM
Hi Joker,

In your two calls to colcopy you misspelled target_col_first and target_col_second. Opps- it happens all the time though.

It took me a while to find it, so don't feel bad since it is easily overlooked :)

Thanks,
Chris Drozdowski
Originlab Technical Support

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