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
 "Set Column Values"-Script and Multiple Import
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

robertg16

Germany
1 Posts

Posted - 11/30/2012 :  06:05:54 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Ver. 8G.0.63.988 SR6 (v8.0988)
Operating System: WinXP

I created a template workbook with 3 extra coloums and inserted a script in "Set Coloumn Values" and "Before Formula Script", respectiviley (see below). I set "Recalculate Option" to "Auto" and it works fine for ONE Workbook.

If I use this saved template with the ImportWizard dialogue and import multiple files the following problem occur:

All Workbooks are imported correctly one by one.
After the last is imported, the "Auto Update" runs active and recalculates all the 3 coloums of each Workbook one by one.
The big Problem is, that this script from "Before Formula Script" is only referring to the "Active Workbook" which is the last imported Workbook.
So in each Recalculated Coloumn stands the values of the last imported Workbook instead of the values from each workbook itself (from where the script is called).
After doing a "manual Recalculation" everything is fine, but is not the sense of scripting.

I see a way to a solution as follows, but need the commands:
in the "Before Formula Scripts" a command is needed in LabTalk to set this Workbook-Window as active, frow where the script is started.
How can I manage this?
I was not succsessfull with win -o page.name${script};, or win -b page.name$; because the page.name$ everytime reffers to the last imported Workbook, and not to the book from where the script is executed.

ANY HINTS, how I can manage this problem?
Isn't it possible forcing the Recalculation of the script directly after importing of each file and not after importing of all?
How can I make the window active from where the script is started?

Thanks for any help.

Here the script from the "Set Coloumn Values" in the Template:
Col(resistanceOhm)-(Ra-Re)/(Ta-Te)*(Col(time)-Col(time)[fixed])

and the corresponding "Before Formula Script":
int first=1;
int last=wks.maxRows; // max. Rows of the current workbook
double Ra=Col(resistanceOhm)[first]; //defining some variables from current workbook
double Re=Col(resistanceOhm)[last];
double Ta=Col(time)[first];
double Te=Col(time)[last];

//defining variable "fixed" case sensitive
if (Col(fieldmT)[1] < Col(fieldmT)[2]) fixed=last;
if (Col(fieldmT)[1] > Col(fieldmT)[2]) fixed=first;

//add Sparklines for col 10-12 and change LName
sparklines sel:=0 c1:=10 c2:=12;
Col(10)[L]$ = resistance (\g(W));
type -b "page.name$ = " + page.name$;
//Messagebox for controlling the page.name$-variable





LaurP

Estonia
16 Posts

Posted - 11/30/2012 :  06:44:54 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Probably the samrter ones will answer you also but:
I use something like this:

Before creating a new sheet/column I save the name of active sheet to a string.

string sheetname$=%(wks.Name$);

// Now i create a new sheet if it is not already created/ or column aso.
if(exist("[ScriptFitData]%(name2$)!")==0){
newsheet name:="%(name$)_2P" labels:="Wavenumber|Standard Error|Area|Standard Error|Width|Standard Error|Book name / Sheet name|Temp|FitPeakNum";
};

After I have created it I change the active sheet back to the original sheet:

page.active$=sheetname$;
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