<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html;charset=UTF-8" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Dear all, <br>
<br>
I am using the batch Processing script but I am encountering a problem
due to a type mismatch.<br>
I want to fit several files, then report in a table all the wanted
parameters as well as which original data they correspond to (ie name
of the table). To do that, I first use the Batch Processing Applescript
which calls my program "SingleFit" (see below).<br>
<br>
The error comes from the line :<br>
<b> data[globalData[0],1] := WindowName;<br>
</b>Where I suspect the program wants a real number instead of a string.<br>
I tried to define the first column as a string with:<br>
SetColumnProperties(col 1, name 'Exp', type textColumn);)<br>
but it did not do the trick.<br>
<br>
Is there any way to declare <b> data[globalData[0],1]  </b>as a
string in the applescript or in the program itself?<br>
<br>
Thank you for your help,<br>
<br>
Ludovic<br>
<br>
<br>
---------------------------------------------------------------------------------------------------<br>
<br>
Applescript:<br>
-- bring up a dialog for selecting the folder<br>
set myFolder to choose folder with prompt "Choose a folder with data
files:"<br>
<br>
-- create a list with all files in the folder<br>
set myFiles to list folder myFolder -- a list of files in myFolder<br>
set myFileCount to count myFiles -- the number of files in myFolder<br>
<br>
-- now start fitting with pro Fit<br>
tell application "pro Fit 6.1.11"<br>
    activate -- bring pro Fit to front<br>
    set error alerts to false -- disable error reports within pro Fit<br>
    make new table -- open a data window for storing our results<br>
    set name of front window to "Result data" -- and set its name<br>
    set nrCols of front window to 15 -- set ncol to 15<br>
    set globalData 0 to 0 -- this is our window counter<br>
    repeat with i from 1 to myFileCount<br>
        set theFile to item i of myFiles -- get the i-th file<br>
        try<br>
            set foldName to ((myFolder as string) &amp; theFile)<br>
            open foldName as data window -- open file<br>
            write line "processing: " &amp; theFile<br>
            run program "SingleFit" -- run the program in pro Fit<br>
            close window theFile saving no -- close without saving<br>
        on error errText<br>
            write line "cannot process: " &amp; theFile &amp; " ("
&amp; errText &amp; ")"<br>
        end try<br>
    end repeat<br>
    set error alerts to true -- enable error reports within pro Fit<br>
end tell<br>
<br>
<br>
---------------------------------------------------------------------------------------------------<br>
<br>
<br>
Profit program:<br>
<br>
function ExpAssoc3;<br>
    description<br>
        'y := y0+A1*(1-exp(-R1*x)) + A2*(1-exp(-R2*x))+
A3*(1-exp(-R3*x))';<br>
parameters 7;<br>
inputs<br>
a[1]:=0, active, 'y0', 0, inf;<br>
a[2]:=100, active, 'A1', 0, inf;
a[3]:=1e-1, active, 'R1', 0, inf;<br>
a[4]:=50, active, 'A2', 0, inf;
a[5]:=1e-2, active, 'R2', 0, inf;<br>
a[6]:=25, active, 'A3', 0, inf;
a[7]:=1e-3, active, 'R3', 0, inf;<br>
begin
y := a[1]+ a[2]*(1-exp(-a[3]*x)) + a[4]*(1-exp(-a[5]*x)) +
a[6]*(1-exp(-a[7]*x))
end;<br>
<br>
program SingleFit;<br>
var<br>
WindowName:string;<br>
begin<br>
  globalData[0] := globalData[0]+1;           {increase window counter}<br>
  SetCurrentWindow(FrontWindow);     {use data of front window for fit}<br>
  <b>WindowName:=GetWindowProperty(FrontWindow, name);</b><br>
  Statistics(column 2, withBasic False);<br>
  SetFunctionParam('ExpAssoc3', 1,0);              {set starting
parameters}<br>
  SetFunctionParam('ExpAssoc3',
2,GetResult(statMaximum));               {these values depend on}<br>
  SetFunctionParam('ExpAssoc3', 3,0.1);                  {your model
and data}<br>
  SetFunctionParam('ExpAssoc3', 4,GetResult(statMaximum));<br>
  SetFunctionParam('ExpAssoc3', 5,0.1);<br>
  SetFunctionParam('ExpAssoc3', 6,GetResult(statMaximum));<br>
  SetFunctionParam('ExpAssoc3', 7,0.01);<br>
  Fit(function 'ExpAssoc3',algorithm robust, xColumn 1,yColumn 2,
printResults True); {run the fit}                     <br>
  SetCurrentWindow(GetWindowID('Result data'));    {window for results}<br>
  if NumFitParams &lt;&gt; 0 then                 {if the fit was
successful}<br>
  begin<br>
     SetColumnProperties(col 1, name 'Exp', type textColumn);<br>
     SetColumnProperties(col 2, name 'y0');<br>
     SetColumnProperties(col 3, name 'A1');<br>
     SetColumnProperties(col 4, name 'R1');<br>
     SetColumnProperties(col 5, name 'A2');<br>
     SetColumnProperties(col 6, name 'R2');<br>
     SetColumnProperties(col 7, name 'A3');<br>
     SetColumnProperties(col 8, name 'R3');<br>
     SetColumnProperties(col 9, name 'Chi2');<br>
     SetColumnProperties(col 10, name 'DoF');<br>
     SetColumnProperties(col 11, name 'Chi2/DoF');<br>
     <br>
    <b> data[globalData[0],1] := WindowName; </b>  <b>Here is the
error's origin</b><br>
     data[globalData[0],2] := FittedParams(1);            {get results}<br>
     data[globalData[0],3] := FittedParams(2);<br>
     data[globalData[0],4] := FittedParams(3);<br>
     data[globalData[0],5] := FittedParams(4);<br>
     data[globalData[0],6] := FittedParams(5);<br>
     data[globalData[0],7] := FittedParams(6);<br>
     data[globalData[0],8] := FittedParams(7);<br>
     data[globalData[0],9] := GetResult(chiSquared);<br>
     data[globalData[0],10] :=
GetResult(nrDataPoints)-GetResult(nrFittedParameters);<br>
     data[globalData[0],11] :=
GetResult(chiSquared)/(GetResult(nrDataPoints)-GetResult(nrFittedParameters));<br>
     <br>
     Tabulate(function 'ExpAssoc3', from 0, to 550,step pointsStep,
fittedParams True);<br>
     <br>
     SetDataPointStyle (0,1,0);<br>
     PlotData(window GetCurrentWindow(dataType),plotType scatterPlot,
xAxisColumn 1, yAxisColumn 3,xFirst 0, xLast 550, autoY True,<br>
              newWindow True, newGraph True, xScaling linScaling,<br>
                yScaling linScaling, xAxis 1, yAxis 1, xLabel 'Time
(s)', yLabel 'F505',<br>
                pointType 0, pointsRed 0, pointsGreen 0, pointsBlue 0);<br>
     MakeTicks (xAxis, 0,50,4);<br>
     PlotData(window GetCurrentWindow(dataType),plotType scatterPlot,
xAxisColumn 1, yAxisColumn 2,xFirst 0, xLast 550, autoY True,<br>
                newWindow False, newGraph False,<br>
              drawPoints False, connected True, curveRed 65535,
curveThickness 2);<br>
     MakeTicks (xAxis, 0,50,4);<br>
     PlotData(window GetCurrentWindow(dataType),plotType scatterPlot,
xAxisColumn 1, yAxisColumn 4,xFirst 0, xLast 550, autoY True,<br>
              newWindow False, newGraph False, xScaling linScaling,<br>
                yScaling linScaling, xAxis 1, yAxis 1, xLabel 'Time
(s)', yLabel 'F505',<br>
                pointType 0, pointsRed 0, pointsGreen 0, pointsBlue 0);<br>
     MakeTicks (xAxis, 0,50,4);<br>
     CloseWindow(window WindowName, saveOption dontSave); {close
initial data window}<br>
  end;<br>
end;<br>
<pre class="moz-signature" cols="72">-- 
*****************************************************************
Dr. Ludovic Pecqueur
CNRS
LEBS UPR3082
Rue de la terrasse - Bât 34
91198 Gif sur Yvette
</pre>
</body>
</html>