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
1 L A T E S T R E P L I E S (Newest First)
LaurP
Posted - 11/30/2012 : 06:44:54 AM 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: