Author |
Topic |
|
JokerOne
Germany
58 Posts |
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
|
|
Chris D
428 Posts |
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
|
|
|
JokerOne
Germany
58 Posts |
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.
|
|
|
|
Topic |
|
|
|