[proFit-list] opening a data window using Applecscript

pro Fit Support profit at quansoft.com
Wed Nov 23 22:40:59 CST 2011


Dear Jeremy

The "open" command will generate a new data window unless a window of that file is already open, in which case it just brings that window to front.

Hence the new window that you create with "make new table" (why do you have a "data window" appended to that -- it generates a syntax error for me) is ignored. The first time you run the script, a window named python_2_row_b.csv will be opened. The second time you run the script, the open command first checks if the file python_2_row_b.csv is already open as a window and, if yes, it just selects that window.

To do what you want, I see the following possibilities:

1. Do not open a window of your own at all. Just open the csv file using the open command, then plot it, then close the data window. Now you can e.g. modify the contents of the csv file and run the script again.

2. Alternatively, after opening the csv file, copy its contents to the data window you have opened, then close the csv window.

3. Alternatively, use a script within pro Fit to open a data window, read the csv file into that data window, and plot the data (using the csv module of Python).

BTW: pro Fit 6.2.4 (to be released soon) should fix the issues in the Apple Script Dictionary that we see in your script, such as "«class as  »:data window"

Best regards

Kurt Sutter
QuantumSoft


On 23 Nov 2011, at 5:36, Jeremy Harbinson wrote:

> Hi,
> I am trying to write an Applescript that will create a new data window, load a two column csv file into that window, and then plot these two columns. 
> 
> Using the record tool of the Applescript editor I was able to get a sequence of commands that do this, except that when run it creates a new data window (I will call this window 2) but then imports the data into the last used  data window and plots the first two columns of this older window (not good). If I rerun the script, it creates a new data window (window 3) and then imports the data into window 2 (created the first time the script was run) and plots that data - data window 3 remaining empty unless I run the script again. 
> 
> What I would like is to be able to create a data window, load data into that newly created widow (and not into another one), and plot data from it (and not from the other window). The script I have been using is (in its current form):
> 
> tell application "pro Fit 6.2.2"
> 	activate
> 	make new table  data window
> 	(*make new table*)
> 	data import options mode custom headerLines 0 title delimiter "," title length 0 delimiter "f," line length 0 terminator "\\R" date format "yyyy-MM-dd hh:mm:ss" with titles without copyInfo, useDoublequotes and dates
> 	open "/Users/jeremyharbinson1/IBM/Python files/temp_files/python_2_row_b.csv" with «class impo» given «class as  »:data window
> 	plot data xAxisColumn 1 yAxisColumn {2} zAxisColumn {} xScaling lin yScaling lin xAxis 1 yAxis 1 point opacity 1.0 curve opacity 1.0 fill opacity 1.0 with autoX, autoY, new window, new graph and connected without selected only and error bars
> end tell  
> 
> This script is not the same as the recorded version - I have been trying (I get the feeling more or less randomly) various combinations of 'make', 'new', 'data', 'table', 'window' etc in place of what is currently 'make new table data window' to create a window that will be the target window for the import and plot commands- nothing worked, resulting in either the same problem described above or an error message. I do not like Applescript.......
> 
> I would be grateful for any suggestions!
> all the best,
> Jeremy  
> _______________________________________________
> proFit-list mailing list
> proFit-list at quantum-soft.com
> http://quantum-soft.com/mailman/listinfo/profit-list_quantum-soft.com

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://quantum-soft.com/pipermail/profit-list_quantum-soft.com/attachments/20111124/87fb4204/attachment.html>


More information about the proFit-list mailing list