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
 Copy cell to a different workbook

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
ds755 Posted - 01/20/2017 : 09:02:44 AM
Origin Ver. and Service Release (Select Help-->About Origin): Origin 2015 Sr2
Operating System: Windows 7 Professional Service Pack 1

Hello everyone,

I have a lot of workbooks, whose filename contains the elapsed time. Inside each workbook there is a cell (row 31, column 5) with an electric current value.

I am trying to write a script that processes all the workbooks within the folder and:

1. Creates a new workbook with 2 columns
2. Appends the time value from the filename to column A
3. Appends the current value to column B

The script works but has two issues:

1. It crashes (even though it works), producing the error message:

Undefined variable: MAX(
sheetname.GetToken(8,"_")$ string expression error!
TIME:failed to add variable to local stack!

2. It does not process the workbooks in the right order, and as a result, the data point for t=1 is between t=31 and t=32.



The script I have written is the following:


// Set up a summary workbook, name will be stored in bkname$ by default
newbook name:="Ion_vs_time" option:=lsname;
wks.colwidth = 8;// set all col width to 8

Col(A)[L]$="Time";
Col(A)[U]$="Minutes";
Col(B)[L]$="Ion";
Col(B)[U]$="A";
int i = 1;

doc -ef LB { // loop over all workbooks in folder
//double Ion = max(col(E));
sheetname$=wks.longname$; //get the name of worksheet
string time$=sheetname.GetToken(8,"_")$; // get the string No8, which shows the time in minutes
int t = %(time$); // convert string to integer

range rap = [%H];

range r = %(rap)!Col(E); // origin range for Ion values

range dest1=[Ionvstime]1!wcol(1); // destination range for time values
range dest2=[Ionvstime]1!wcol(2); // destination range for Ion values

dest1[i]=t;
dest2[i]=r[31];

i=i+1;
}


I would appreciate any help in resolving these issues.
8   L A T E S T    R E P L I E S    (Newest First)
ds755 Posted - 01/30/2017 : 06:08:56 AM
quote:
Originally posted by cpyang

So you need to use sheet longname? Why not just sheet name which is wks.name$

CP




Hi cpyang,

If I use wks.name$ the GetToken function fails, as there is no field No8.
cpyang Posted - 01/27/2017 : 9:07:00 PM
So you need to use sheet longname? Why not just sheet name which is wks.name$

CP
ds755 Posted - 01/24/2017 : 11:25:43 AM
OK, I think I know why the program is crashing.

The newly created workbook Ion_vs_time is processed by the loop doc -ef LB. Since it does not have a longname, the command sheetname$=wks.longname$; assigns a blank entry to sheetname$, and the following command time$=sheetname.GetToken(8,"_")$; crashes, finding no 8th field to assign to time$.

Now, of course, I don't know how to solve this issue.

That also doesn't explain the second issue. Why does the program not process the workbooks in order? How does doc -ef LB choose which workbook to process first?
ds755 Posted - 01/24/2017 : 08:51:00 AM
Hi Hideo,

Yes, I actually want the long name of the worksheet, not the sheet label. The sheet label is a truncated version of the long name.

In any case, the problem is somewhere else.
Hideo Fujii Posted - 01/23/2017 : 5:09:38 PM
Hi ds755、

By the following sentence, are you sure that you actually want the long name of the worksheet instead of the
sheet label which is in the tab in the workbook? The longname of the sheet is only shown when you put the
cursor on the tab (or in Name and Comments dialog):
sheetname$=wks.longname$; //get the name of worksheet

If you want to obtain the sheet name in the tab, you should use the following, istead:
sheetname$=layer.name$; //get the worksheet name in the tab

Could you please check?

--Hideo Fujii
OriginLab
ds755 Posted - 01/23/2017 : 10:34:35 AM
Any ideas anyone?
ds755 Posted - 01/21/2017 : 01:00:23 AM
Hi Hideo,

I wanted to write:

range r=[%H]!Col(E);
Hideo Fujii Posted - 01/20/2017 : 4:34:03 PM
Hi ds755,

Sorry for just replying only after glancing your code... Your following two lines have nested ranges:
range rap = [%H];
range r = %(rap)!Col(E);
Did you simply want to write:
range r=[%H]!Col(E);
or
string raps=%H;
range r=[%(raps$)]!col(E);
??

--Hideo Fujii
OriginLab

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