cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

"Self" closing a file

"Self" closing a file

Hi,

I have a question about closing/opening documents.

We have 2 documents:
1) DOCU_A with doctype DT_A
2) DOCU_B with doctype DT_B

The end user needs to edit DOCU_B but does not know where to find it.
DOCU_A can be opened by the end user and contains the information to
retrieve DOCU_B.

Here is how it must work:

1) From IE, the user click on link. This link generates a file with a
special extension. This is DOCU_A. It's a very simple XML file.
2) In Win XP, this special extension is associtated to Epic. Therefore when
the user click on the link, Epic is opened and loads DOCU_A.
3) In DOCU_A, I can find the necessary info to find DOCU_B.
4) DOCU_B is opened (with doc_open and on the basis of the info found in
DocA)
5) The user can edit DOCU_B

The user can not view or edit DOCU_A.

Therefore, what I would like to to is:

1) Open DOCU_A
2) Read DOCU_A
3) Based on the info in DOCU_A, load DOCU_B
4) Close DOCU_A

My question is: how can I close DOCU_A?

Here is the code I use in the instance.acl of DT_A (the doctype of DOCU_A):

--------------

function close_docu(doc){

if (doc_type(doc) == "DT_A"){
window_destroy(doc_window(doc));
}

}

doc_add_callback(0,'create','close_docu');

###Here comes to code to find the ref of DOCU_B based on the contents of
DOCU_A
###...
###...

$new_doc = doc_open(DOCU_B);
$window =
window_create("edit",0x00001+0x00002+0x00004+0x00010+0x00020+0x00080+0x00100
+0x00800+0x04000,$new_doc);
window_show($window,1);

--------------

When I click on the link in IE, DOCU_A is opened and then DOCU_B is opened
and than I get the folloing error: segment violation (signal 11). I thought
this code could work because, based on what I read in the doc, the create
callback is called when all the startup files are executed.

Any idea?

Thanks,
Benoît
Tags (2)
3 REPLIES 3

Re: "Self" closing a file

Epic will get into trouble if a document is closed before it is fully loaded.

A workaround is to close the DOCU_A when DOCU_B is closed. Something like this:

function close_docu(doc){
doc_close(doc_data(doc, 'alsoclose'));
}

### find the ref of DOCU_B based on the contents of DOCU_A

$new_doc = doc_open(DOCU_B);
doc_set_data($new_doc, 'alsoclose', current_doc());
doc_add_callback($new_doc,'destroy','close_docu');
doc_show($new_doc, current_window());
window_reset_docmap(current_window());

Tung

Re: "Self" closing a file

I am doing exactly the same thing you are. I've noticed that you don't really need to close DOCU_A. Just execute a doc_open/doc_show on the DOCU_A after reading from DOCU_B. I can send you code if you like, but it's not very polished and it's in .NET.

I have the same problem you have in that I'm trying to account for the possiblity that the user may click on the link more than once. I would like to close the window after notifying the user that the document is already open. I'll study Tung's method below and try it out.


-Gerald.

Re: "Self" closing a file

Hi Tung,

Thanks for this info. We will perhaps use it if we do not manage to close
DOCU_A right after the opening of DOCU_B.

Rgds,
Benoît
Announcements