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
 Origin Forum
 Plotting ASCII file from startup
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

OliverW

Switzerland
Posts

Posted - 10/21/2006 :  07:59:46 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Hey All,
I use Origin for quite a while but never used its programming etc possibilties. I want to do something very simple, namely to start Origin with an ASCII data file and to have it plotting the data without any further user action. How would one do that?

Thanks for any suggestions,
Oliver

Mike Buess

USA
3037 Posts

Posted - 10/21/2006 :  12:20:23 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Oliver,

In Origin 6.1 or higher you can use the script file dofile.ogs which already exists in Origin's program folder. Open dofile.ogs in Notepad and insert the following text at the top. (For convenience sake I've assumed that your data file's extension is DAT. Substitute your extension for DAT in the script below.)

[OnOpenDAT]
%Z="%1"; // save file name
win -t data; // open worksheet
open -w %Z; // import file
wo -s 0 0 0 0; // select all columns
wo -p 200; // plot as lines
return 0;

Save and test by dragging a DAT file from Windows Explorer and dropping it on Origin's desktop to produce a graph of your data. Then close Origin and drop the same DAT file on Origin's startup icon on Windows' desktop. That will start Origin and then import and plot.

Mike Buess
Origin WebRing Member

Edited by - Mike Buess on 10/21/2006 12:22:31 PM
Go to Top of Page

OliverW

Switzerland
Posts

Posted - 10/21/2006 :  6:27:03 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Dear Mike,

thanks a lot, that´s already a very good start. However, it´s not exactly what I wished for, since it requires to modify the origin files. You see, the thing I have in mind is the following. I have written some software to do some simulations, which produces various output files. Now I thought it would be nice to have a button, which displays the file in origin. Your suggestions is doing this. However, every user of the software would have to modify their dofile.ogs on every computer (and I really don´t like to write into their files during installation). Hence I am looking for something, which works by only providing origin some arguments (or file names) at startup. I tried e.g. osg files, but these are just loaded into the LabTalk editor but not executed. Etc..

It sounded such a simple task initially...

Thanks,
Oliver


Go to Top of Page

zachary_origin

China
Posts

Posted - 10/21/2006 :  10:31:44 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Oliver,

How about things like in the picture? Save it in a project (.opj file), everytime user open this project, they need click the button to start. If this is what you needed, you can start with a graph page, delete all the objects in the page, then add the texts and the button. LabTalk scripts can be associated with the button to run your applications. you can learn from here about how to create the button.



Zachary
OriginLab Technical Services.

Edited by - zachary_origin on 10/21/2006 10:37:16 PM
Go to Top of Page

Mike Buess

USA
3037 Posts

Posted - 10/22/2006 :  07:28:49 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
quote:
However, every user of the software would have to modify their dofile.ogs on every computer (and I really don´t like to write into their files during installation).
Origin has well-established methods for distributing scripts. See the Sharing your Origin files chapter of the Origin Reference (Help > Origin) and the Programming Guide > Sharing Custom Applications chapter of the Programming Guide (Help > Programming). In Origin 7.5 your script files would be copied to the User path which would not overwrite the system files. Furthermore, some system files (like dofile.ogs and custom.ogs) are meant to be customized.

Mike Buess
Origin WebRing Member
Go to Top of Page

OliverW

Switzerland
Posts

Posted - 10/22/2006 :  09:39:22 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hey Mike and Zachary,

first let me thank you for your willingness to look at my problem. I really appreciate this very much.:-) (and in fact I am surprised, in a positive sense, that I get such kind response on this forum)

I have the feeling that I want to do something which is much simpler than what you imagine. I have figured out from the help that you can create your own interface, with your own buttons, etc, and that you can transfer this application to others, etc., but I have not found really what I was looking for ...

Let me first clarify this: When I was talking about this button, I meant a button in my program, not in Origin. I thought to implement the task such, that a click on the button simply executs origin with some arguments (e.g. filenames), such that origin opens and displays the data file of interest. It would be no problem to generate any kind of file beforehand (only I don't like to overwrite user files).

Looking at your comments, I think the real question I have (sorry if I just was to stupid to find the answer in the help) is simply, how to get origin executing a script automatically. Your example, Zachary, looks almost perfect, only that the user has to press a button. Would it be possible to have everything the same, just with origin executing the script behind the button automatically, that is to add th e sought after special command to the script which does it (so that if one starts origin with the .opj file one gets the data plot in one step)?

By the way, would you mind to provide the script which produced the graphic in your example, Zachary? This would be a great help to me.

Thank you both again very much for your efforts,
Oliver
Go to Top of Page

Mike Buess

USA
3037 Posts

Posted - 10/22/2006 :  11:49:36 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Origin 7.5 has Automation Server Support that will do what you want if your program can use it. See the Calling Origin from Other Applications chapter in your Programming Guide. All versions of Origin will act as a DDE server. You can also send commands to Origin from the command line using a startup switch. See this tip for details. Other options might be available if we knew your Origin version.

Mike Buess
Origin WebRing Member
Go to Top of Page

zachary_origin

China
Posts

Posted - 10/22/2006 :  1:18:54 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Oliver,

I think you have understood something wrong, what I showed in the picture is not as perfect as you thinked. The graph is not created automatically by scripts at the startup of Origin. It is manually created and then saved as a .opj file. Can you get what I mean now?

Also I have misunderstood your intention. I have supposed you want to do this without any other program calling Origin. Now the problem is much easier. As Mike has mentioned, you can see Calling Origin from Other Applications in the help. Here I still want to mention two functions you need use: one is the BSTR LTStr(BSTR name) property, you need this to get the ASCII file name. The other one is boolean Execute(BSTR script, [optional] VARIANT name) method, which can be used to pass the LabTalk scripts to Origin and run them, you need this to open the data file and plot it out (Mike has written this in his first reply).

BTW. Mike, I can not open the hyperlink you provided.

Zachary
OriginLab Technical Services.
Go to Top of Page

Mike Buess

USA
3037 Posts

Posted - 10/22/2006 :  3:19:45 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Zachary,

Hmmm, the link works fine for me. However, the topic is short and can be reproduced here...

##################################################################
Running scripts at startup. (Origin 5.0 and above)

You can use the -a command line switch to run a script when Origin starts. Short scripts can be placed in a file called Startup.cnf. Scripts that are sectioned should be placed in Startup.ogs and run from Startup.cnf with the LabTalk command run.section(Startup,section_name). In either case, start Origin with the following command line:

Path\Origin61.exe -a Startup

You should be aware of potential timing problems when writing your startup scripts. Some LabTalk commands that operate on worksheets or plots will crash Origin if there are no worksheet or plot windows open. When the startup scripts run there will be no Origin child windows open, so your scripts will have to create any worksheets or plots that are needed.
##################################################################

Mike Buess
Origin WebRing Member
Go to Top of Page

OliverW

Switzerland
Posts

Posted - 10/22/2006 :  4:25:26 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hey Mike, Zachary,

that's really already very close. The option -a is exactly what I looked for. One just has to generate a XXX.cnf file, copy it into the Origin folder und start as path\origin.exe -a XXX .

Only one "problem" remains. If I use the script Mike suggested in his first response, this works fine, only that Origin additionally creates a Data2 worksheet. I tried to get rid of it by adding win -c Data2; to the script. If I execute this from the sript window it nicely removes the worksheet, but if I add it to XXX.cnf (I inserted it before the return 0; statement) it does not seem to do anything. Is this because at the execution time of the script the Data2 worksheet is not yet existing? How could one suppress the generation of the Data2 worksheet?

Cool.

Ciao,
Oliver
Go to Top of Page

Mike Buess

USA
3037 Posts

Posted - 10/22/2006 :  8:40:46 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Oliver,
quote:
Is this because at the execution time of the script the Data2 worksheet is not yet existing?
Exactly, it's one of the "timing problems" discussed above. Select Tools > Options and the Open/Close tab. The Start New Project option is probably set to Origin Worksheet which means that a worksheet opens whenever you start Origin. However, your CNF script runs before that worksheet is created so it can't be deleted from the script. You can avoid the extra worksheet by changing the Start New Project option to None. That can even be done from your CNF script with the command system.project.startup = 6; but that is contrary to your philosophy of not touching other user's files or settings. So I don't see a way to suppress the extra worksheet for all users.

Mike Buess
Origin WebRing Member

Edited by - Mike Buess on 10/22/2006 8:47:49 PM
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