时间: 2021-07-31 作者:daque
hotmetal中运用javascript 5.还好吗编写脚从来查看上回窜改的日子这个on_document_activate宏是查看磁盘上的文献能否有与运用hotmetal编纂的暂时文书档案沟通的上回窜改的日子。它提醒用户该做什么以防日子不配合。以次是这个宏的简直代码:<macro name="on_document_activate" lang="jscript" id="44" tooltip="hide_on_document_activate" desc="runs macro: hide_on_document_activate"><![cdata[// do this for local documents onlyif (activedocument.fullname == activedocument.localfullname) {var name = activedocument.localfullname;if (application.readablefileexists(name)) { // if document has never been saved, do nothingvar fso = new activexobject("scripting.filesystemobject");var f = fso.getfile(name);var newmod = date.parse(f.datelastmodified);var props = activedocument.customdocumentproperties;if (props.count != 0) {oldmod = props.item("lastmod").value;if (oldmod != newmod) {var yes = 6;var no = 7;var msg = "the disk version of this document has changed from the\n";msg += "version in memory. do you want to re-open the document?";var ret = application.messagebox(msg, 36, "document changed");if (ret == yes) {activedocument.reload();}// reset the timestamp regardless of the user's response// this will prevent the dialog from always showingapplication.run("on_document_open_complete");}}}}]]></macro>咱们再查看文献能否承载了: activedocument.fullname == activedocument.localfullname。而后咱们考证一下文献能否被生存到磁盘中: application.readablefileexists(name). 一致于前方的on_document_open_complete 宏,咱们创造一个activex控件而且索取出文献的上回窜改的日子,代码如次:var fso = new activexobject("scripting.filesystemobject");var f = fso.getfile(name);var newmod = date.parse(f.datelastmodified);