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

Community Tip - Have a PTC product question you need answered fast? Chances are someone has asked it before. Learn about the community search. X

SGML as Read-Only in 5.4?

ptc-3050150
1-Visitor

SGML as Read-Only in 5.4?

We use 4.3 for SGML and 5.4 for XML. Since you can't run 4.3 and 5.4 at the same time, we often open an SGML file in 5.4 and cut and paste into an XML doc. The SGML book is still being revised so these are live documents and if saved from 5.4 crash the EMS-2 SGML compile.

Using ACL, will it be possible to set up a hook to catch that a doc being opened is SGML and lock it from editing? Open it as read-only in other words?

Guess I'm asking that, if they double-click a filename and Editor starts to open it, is it already too late to open as read only?

A nice second function would be to open it as free-form and skip the pop-up to recompile the DTD for 5.4.

I could do it by doctype as well as the five SGML doctypes are different from the XML doctype.

Thanks,

John T. Jarrett CDT
Sr. Tech Writer, Tech Pubs, ILS, Land & Armaments/Global Tactical Systems
2 REPLIES 2

ACL has a doc_type_xml() function, which returns 1 if the document was compiled as an XML application, or 0 otherwise. Based upon this return, you should be able to use doc_read_only() to set the document to read-only, or not. (Caveat: as I have said before, I am not an ACL expert, nor do I play one on TV.)

Thanks, Ed!

This part works:

function sgml_as_readonly(doc = current_doc()) {
$this_kind = (doc_kind());
if ( $this_kind == "sgml") {
ret = doc_read_only(doc,1);
# response("$this_kind file opened");
}
}
add_hook('doccreatehook','sgml_as_readonly','PREPEND');

I have this in custom\init and it works fine.

My main concern was that it was too late by the time this actually runs, and it is the way I was thinking earlier - but doc_read_only changes it to read only after it is opened so it works anyway. Doc_open as read only does not work - too late in the chain.

I tried it with doc_open -- $fid = doc_open(doc, 0x421); -- with various things set, but it still asks for the DTD or freeform on the first open when you double-click the file...and the file is already open and not read only...

This will go a long way to protecting our source code from inadvertent saves in the wrong format.

Thanks again,

John T. Jarrett CDT
Sr. Tech Writer, Tech Pubs, ILS, Land & Armaments/Global Tactical Systems

T 832.673.2147 | ext 1147 | -<">mailto:->
BAE Systems, 5000 I-10 West, Sealy, Texas USA 77474
www.baesystems.com
Announcements

Top Tags