next up previous contents
Next: The save Command Up: Standard Files Previous: The ReadProgram Command

The ReadLibrary command

When Darwin was installed on your computer, a special directory was created which contains the Darwin libraries (see § [*] and Appendix [*] - Installation Instructions). The Darwin system can be perceived as consisting of two parts: the kernel and the libraries. The kernel is responsible for executing statements, performing simple mathematical operations, and managing memory. Instructions for more complicated computations, those built from the basic primitives of the language, are stored in the Darwin library.

The power of a general purpose programming language comes from the user's ability to expand these libraries. When tackling a new problem, programmers typically build a set of routines and structures and store them in a local file which they can then load in to Darwin. When the code is perfected and they would like to make it publicly available to other users on the system, they place their file in the library where all can now access it.

To read a file from the library, Darwin offers the ReadLibrary command.

> ReadLibrary(DrawPackage);              # load the library DrawPackage
This statement loads the entire contents of the file DrawPackage in the Darwin library. Note that we do not specify the path to where the library resides. The locatation of the library is set by a flag (the -b option) when the Darwin session is initiated. The system variable libname contains the library path. Appendix [*] - Installation Instructions contains further information about these and related Darwin flags.

If we include a procedure, structured type or variable name as a second argument to ReadLibrary command, only that object is read from the file.

> ReadLibrary(DrawPackage, DrawTree);     
>                                # only load function 'DrawTree'
>                                # located in library file 'DrawPackage'
proc (t:Tree, title:Text, ColorNames:list, Species:list, SpeciesColor:list
) local t2, rgb, xpts, maxmin, ypts, dt, lab, i; description 
   ColorNames:   optional list of colors, e.g. [re ..(800).. uitites etc; if 
length(t) < 5 and 2 < nargs then print(Use CT_Color to color the tree first!); 
print(CT_Color); RETURN(0) else t2 := t fi; if length(t2) < 8 and 4 < nargs
 then t2
...


next up previous contents
Next: The save Command Up: Standard Files Previous: The ReadProgram Command
Gaston Gonnet
1998-09-15