Arbortext Command Language > Using the Arbortext Command Language > Example: Test the Location of a Document
  
Example: Test the Location of a Document
These commands modify the running headers for any memo documents in a particular directory:
$workingdir=`pwd`
if (index($workingdir,'conf')!=0 && \
$doctype=="memo") {modify_tag -global document \
scilevel=secret;}
pwd is used to print the complete path for the working directory. The path is then used as the value of the newly defined variable $workingdir. Statements of the format $xxx = are used to assign values to variables or to create variables and assign them values. The name of the variable appears to the left of the = sign and the value of variable appears to the right. pwd is a command that prints the complete path for the working directory. You can pass commands from Arbortext Editor to the operating system by enclosing them in left quotes.
The condition for this if command consists of a complex expression made of two smaller expressions.
The first of the smaller expressions:
index($workingdir,'conf')!=0
uses the index function to test whether the path for the working directory includes the string “conf” for confidential (presumably, any memos in the directory conf or a subdirectory of that directory should have the special header). The != (NOT) operator compares the result of the index function with 0. If the value is not 0 (that is, the string “confidential” appears in the path) then the first expression is true. If it is 0, the expression is false.
The second of the smaller expressions:
$doctype==”memo”
tests to see whether the value of the variable $doctype is “memo”. In this case, if the value is 0 (the value for $doctype was “memo”), the expression is true. If the value is not 0, the test is false.
Finally, the AND operator, &&, compares the results of the two tests. For the Arbortext Editormodify_tag command to be executed, both expressions must be true. (The modify_tag command changes the security level, or “scilevel”, to “secret”) If the document is not a memo or is not in the directory conf, the security level is not affected.