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 for Programming
 LabTalk Forum
 Thread handling in Origin
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

smith.panther

4 Posts

Posted - 03/31/2013 :  08:01:09 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Ver. and Service Release (Select Help-->About Origin): 8.6.0G Sr3 b99
Operating System: Win 7

Hi,

I have a strange problem with my script and I hope somebody can help me to solve it or tell me a workaround. In principle, I want to import files, copy some of the imported columns to a template (.otw file) which performs some calcualtions and access the processed data for further calcualtions.
Here is an excerpt of my script:

string path;
path$ = "d:\Test\testsheet\";
findFiles e:="*.dat";
impfile location:=data fi:="d:\test\testsheet\templates\import.oif";

win -t wks "d:\Test\testsheet\templates\mobility_sat.otw" "MobilitySat";
colcopy irng:=[Book7]1!Col(1:2) orng:=[mobilitysat]1!Col(1:2);
csetvalue col:=[mobilitysat]1!Col(4) formula:=die*1e-7;
csetvalue col:=[mobilitysat]1!Col(5) formula:=eps;
csetvalue col:=[mobilitysat]1!Col(3) formula:=1/wl;

range r1 = [mobilitysat]1!Col(9);
win -t wks "d:\test\testsheet\templates\mobility.otw" "Mobility";
csetvalue col:=[mobility]1!Col(11)[1:1] formula:="r1[51]";

The script finds and imports the files as intended. It also copies the specified columns to "mobility_sat.otw" but afterwards it opens the next template "mobility.otw" without processing the pending calculations in the "mobility_sat.otw". Only after it has opened "mobility.otw" it starts to calculate the column operations in "mobility_sat.otw". But "mobility.otw" already tries to access the data by range variable from "mobilitysat" book when it opens and of course it is not defined at this moment because the calculations were not performed yet.
I thought that Labtalk executes the script line by line but obviously this is not the case. Is there any thread handling or priorisation within Origin script execution? E.g. it tries to execute the less computation-intensive operations first and the calculations last?

I have also tried to use sections within the script but it does not change anything. It waits e.g. 10 seconds than opens the "mobility.otw" and once again calculates the "mobility_sat.otw" as the last operation.

[main]
run.section( , section1);
run.section( , section2);
sec -p 10;
run.section( , section3);

[section1]
string path;
path$ = "d:\Test\testsheet\";
findFiles e:="*.dat";
impfile location:=data fi:="d:\test\testsheet\templates\import.oif";

[section2]
win -t wks "d:\Test\testsheet\templates\mobility_sat.otw" "MobilitySat";
colcopy irng:=[Book7]1!Col(1:2) orng:=[mobilitysat]1!Col(1:2);
csetvalue col:=[mobilitysat]1!Col(4) formula:=die*1e-7;
csetvalue col:=[mobilitysat]1!Col(5) formula:=eps;
csetvalue col:=[mobilitysat]1!Col(3) formula:=1/wl;

[section3]
range r1 = [mobilitysat]1!Col(9);
win -t wks "d:\test\testsheet\templates\mobility.otw" "Mobility";
csetvalue col:=[mobility]1!Col(11)[1:1] formula:="r1[51]";

Can somebody help me and tell me what I am doing wrong? How I can access and handle the data, which is first to be calculated by a template? Thank you very much in advance!

Smith.Panther

Edited by - smith.panther on 03/31/2013 08:01:37 AM

Kathy_Wang

China
159 Posts

Posted - 04/01/2013 :  04:49:01 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi,

Not sure what your workbook template looks like, but according to your description, you may try the command run -p au; which will update all pending operations including operations with Recalculate set to Manual before executing the next line.

So parts of your script may be modified to:

win -t wks "d:\Test\testsheet\templates\mobility_sat.otw" "MobilitySat";
colcopy irng:=[Book7]1!Col(1:2) orng:=[mobilitysat]1!Col(1:2);
csetvalue col:=[mobilitysat]1!Col(4) formula:=die*1e-7;
csetvalue col:=[mobilitysat]1!Col(5) formula:=eps;
csetvalue col:=[mobilitysat]1!Col(3) formula:=1/wl;
run -p au;
range r1 = [mobilitysat]1!Col(9);
win -t wks "d:\test\testsheet\templates\mobility.otw" "Mobility";
csetvalue col:=[mobility]1!Col(11)[1:1] formula:="r1[51]";


BTW, it's also important to make sure the recalculation mode of all operations are set to "Auto" instead of "Manual".

If this doesn't solve your problem, perhaps it's better to share your template with us, so that we could further investigate. To do this, click the Send Files to Tech support link at the right-top corner of the forum main page.

Kathy
Originlab
Go to Top of Page

smith.panther

4 Posts

Posted - 04/02/2013 :  07:04:10 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Thank you very much! The command "run -p au" does exactly what I was looking for. Now it seems to work perfectly and calculates the pending operations before openening the next template.
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