PreviousNext

Reading Other Files as dcecp Scripts

The source command reads the contents of other files, executing them as dcecp scripts. This capability lets you construct higher level scripts by plugging lower level functions together - like building blocks. Because you reuse your scripts rather than duplicate them with potential variations, scripts are more consistent and easy to develop and maintain. The command syntax is:

source filename

The return value from source is the return value from the last command in filename.

As a practical example, imagine we have one script that lists entries in CDS subtrees, another script that deletes subtrees, and another script that moves subtrees. One common function needed by all these scripts might be to list every child directory under the root of the subtree. You could write a script that lists every child and name it something like children_list.dcp. (The .dcp extension is a dcecp convention for naming script files.) When any of your scripts need to list all the child directories, simply use the source command:

source children_list.dcp

Terminate a source command using the return command. The return command provides a way for commands like source and proc to exit in a controlled manner, even when expected or unexpected error conditions occur. Rather than allow error conditions to cause the whole script to exit and fail, the return command manages error information and allows the script to continue executing. We discuss the use of return with other error-handling techniques in String Manipulation.