Arbortext Command Language > Callbacks > doc_add_callback > saveas Callback Type
  
saveas Callback Type
Function prototype:
function funcname (doc, filename, ro, savetype, encoding, op)
saveas is called when a save_as command is performed before the document is saved. The Save As dialog box issues a save_as command when the user selects OK after choosing a new path name for the document.
Arguments
doc is the identifier of the current document.
filename is the path name entered from the command line or selected by the user from the Save As dialog box.
ro is 1 if the -readonly option was specified on the save_as command or if Read Only was checked on the Save As dialog box.
savetype is an integer that indicates any change in file type.
0 — No change.
1 — Saving the SGML document as an XML document.
2 — Saving the XML document as an SGML document.
encoding is a string. It is a null string if the operating system's encoding is used to save the file. Otherwise, it is a encoding name. Refer to the table below for a list of available encoding names.
Adobe-Standard-Encoding
ISO-8859-9
ISO-8859-1
EUC-JP
ISO-8859-1-Windows-3.1-Latin-1**
Shift_JIS
ISO-8859-2
Big5
ISO-8859-3
GB_2312-80
ISO-8859-4
KSC_5601
ISO-8859-5
UTF-8
ISO-8859-7
US-ASCII
ISO-8859-8
ISO-10646-UCS-2
op is the function callback operation. Callbacks are called twice in succession with op specifying the stage of callback operation.
1. op == 1 first call — The returned argument specifies whether the execution should continue or be stopped:
0 — Continue callback processing.
-1 — Stop further callback processing.
2. op == 2 second call — Occurs unless the processing was stopped during the first call. The returned argument allows or prevents basic Arbortext Editor processing after all callbacks have been called:
0 — Basic Arbortext Editor processing allowed.
-1 — Basic Arbortext Editor processing prevented.
If saveas needs to perform some action after the document is saved, it must execute the save_as command and then return -1 to indicate that the command completed.
Example
function saveashook(doc, path, ro, savetype, encoding, op) {
if (op == 1) {
return 0; # proceed
}
if (ro) {
save_as -readonly $path
} else {
save_as $path
}
if (status != 0) {
# command failed
}
# do extra code here ...
return -1; # we did the save
}