Structural Informatics Group (SIG) logo
Home | Projects | Demos | Downloads | Publications | Local Info | About Us | New site
Go to the first, previous, next, last section, table of contents.

load

load

type: function (subr) 
location: built-in
source file: xlsys.c  and  xlread.c
Common LISP compatible: similar
supported on: all machines

SYNTAX

(load  <file>  [ :verbose <v-flag> ] [ :print <p-flag> ] ))
        <file>          -       a string expression or symbol 
        <v-flag>        -       an optional key-word expression - default is T
        <p-flag>        -       an optional key-word expression - default is NIL

DESCRIPTION

The LOAD function opens the <file>, reads and evaluates all the forms within the <file>. <file> may be a string expression or a symbol. When <file> is a string, you may specify a complete file location or extensions (like "/usr/local/bin/myfile.lsp" or "A:\LISP\TIM.LSP"). If <file> is a string and includes a file type or an extension (like ".lsp"), then LOAD accesses the specified file. If there is no extension on <file>, it will add ".lsp". If the :VERBOSE keyword is present and <v-flag> is non-NIL, a load message of the form ; loading "xxxx.lsp" will be printed to *STANDARD-OUTPUT*. If the :PRINT keyword is present and <p-flag> is non-NIL, the resulting value of each top-level form in <file> will be printed to *STANDARD-OUTPUT*. If the file load was successful, then T is returned as the result. If the file load was not successful, a NIL is returned.

EXAMPLES

(load 'gloop)                           ; prints  ; loading "GLOOP.lsp"
                                        ; returns NIL   there is no file
                                        ;
(defun foo (x) (print x))               ; create a function 
(savefun foo)                           ; create a file FOO.lsp
(load 'foo)                             ; prints  ; loading "FOO.lsp"
                                        ; returns T
(load 'foo :verbose NIL)                ; no printing   returns T
(load 'foo :print T)                    ; prints  FOO   returns T
(load 'save :verbose T :print T)        ; prints  ; loading "FOO.lsp"
                                        ; prints  FOO   returns T
(load "foo")                            ; prints  ; loading "foo.lsp"
                                        ; returns NIL   didn't work
                                        ; because the file is "FOO.lsp"
(load "FOO")                            ; prints  ; loading "FOO.lsp"
                                        ; returns T     did work
(load "FOO.lsp")                        ; prints  ; loading "FOO.lsp"
                                        ; returns T     did work

FILE NAMES: In the PC and DOS world, all file names and extensions ("FOO.BAT") are automatically made uppercase. In using XLISP, this means you don't have to worry about whether the name is "foo.bat", "FOO.BAT" or even "FoO.bAt" - they will all work. However, in other file systems (UNIX in particular), uppercase and lowercase do make a difference. So, in UNIX if you do a (open 'foo-file :direction :output), this will create a file named FOO-FILE because XLISP uppercases its symbols. If you do a (open "foo-file" :direction :output), this will create a file named "foo-file" because UNIX doesn't uppercase its file names. Another case is if you do (savefun mydefun), this will create the file "MYDEFUN.lsp". So, if you are having trouble with opening and accessing files, check to make sure the file name is in the proper case.

COMMON LISP COMPATIBILITY: Common LISP has a LOAD function that is similar to XLISP's LOAD. The only difference is that Common LISP uses an optional keyword parameter :IF-DOES-NOT-EXIST which XLISP does not support.

NOTE: In XLISP, the keyword parameters are order sensitive. If both :VERBOSE and :PRINT keywords are used, :VERBOSE must come first.

KEYSTROKE EQUIVALENT: In the Macintosh version of XLISP, a COMMAND-l brings up a dialog box for loading a file. COMMAND-n operates similarly, except that the load is done with :VERBOSE and :PRINT flags set. These can also be accomplished by a pull-down menu selection.


Go to the first, previous, next, last section, table of contents.