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
 Forum for Origin C
 OE_WIN_CLOSE
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

starman2049

USA
15 Posts

Posted - 01/29/2010 :  4:58:42 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
I am creating a chart that in the background creates a hidden worksheet. how do I set it up so when I close the chart it deletes the worksheet? Is there a property of the chart, or a way to hook the OE_WIN_CLOSE?

Origin Ver. and Service Release (Select Help-->About Origin): 8.1
Operating System: XP

cpyang

USA
1406 Posts

Posted - 01/29/2010 :  10:51:16 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Add a hidden text object, save the wks name into its .Text, set it to execute script on window close (GRCT_WINCLOSE) and run script like

%A=this.text$;
win -cd %A;

To add a text object, best to look at add_text function inside

#include <..\originlab\grobj_utils.h>

or just use those utility functions by adding grobj_utils.c.

To set the object to execute LT script, use

set_LT_script

or look at that function in <..\originlab\grobj_utils.c>

CP


Go to Top of Page

starman2049

USA
15 Posts

Posted - 02/01/2010 :  1:23:15 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Thanks - worked great! NB: in order to make "hidden" I set the .X property to -10000
Go to Top of Page

starman2049

USA
15 Posts

Posted - 04/02/2010 :  5:59:33 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
OK, so everything works just fine when I close the chart, it closes/deletes the worksheet/matrix behind the chart. The problem I am having is that if I have an open chart and I close *Origin* then there is something about the sequence of deleted that gives me this error:

"Error: Failed to execute script"

I tried changing it from:

GraphObject goHiddenText = gl.CreateGraphObject(GROT_TEXT);
goHiddenText.Text = ml.GetPage().GetName();
goHiddenText.X = -10000;
string script = "%A=this.text$; win -cd %A";
SetEventScript(goHiddenText, script, GRCT_WINCLOSE);


to:

string script = "%A=this.text$; if (exist(%A)>0) win -cd %A";


But that doesn't help. Any ideas?
Go to Top of Page

cpyang

USA
1406 Posts

Posted - 04/07/2010 :  09:53:32 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
I guess when it is executing, the window you are trying to close is still valid, but since it is in the middle of closing, explicit command to close it will trigger an error.

You can protect any script from generating an error by putting it inside { }, so try


"%A=this.text$; {win -cd %A}";


To be more precise, there is a system variable that tells you Origin is closing down, @CW. So the better code is


"if(@CW>0) {%A=this.text$;win -cd %A}";



CP

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