Arbortext Command Language > Using the Arbortext Command Language > Example: Edit Window Function
  
Example: Edit Window Function
Here is an example of a function that could be used to edit another document in a new window. This function is defined in the system _main.acl file. (Note: flags equals the sum of bits set.)
function edit_new_window(file, flags=0x3f, geom="") {
# if no special args, use builtin command
if (flags&0x3f == 0x3f && geom == "") {
edit -newwindow $file
return}
# open a new doc tree
local doc = doc_open(file);
if (doc < 0) {
# error message already displayed by doc_open
return}
# see if already in window; if so just expose it
local win = doc_window(doc);
if (win > 0) {
doc_close(doc);
# decrement reference count
window_open(win);
# uniconify maybe
window_raise(win);
return}
# make an edit class window for it with
# edit-style initialization flags |= 0x140
win = window_create("edit", flags, doc, geom);
if (win < 0) { message "Couldn't create
window to edit: $file";
# couldn't make a window so unload document
doc_close(doc);
return}
# make this doc be the current one for
# the set command
current_doc(doc)
# convert tagged tables to pictures according
# to global setting
if (option("tabletags") == "off") {
set tabletags=off}
window_show(win, 1);
# map the window now}