XLISP save

Nyquist / XLISP 2.0 - Contents | Tutorials | Examples | Reference

# save

Type: | - | function (subr)
Source: | - | xldmem.c, xlimage.c

## Syntax

(save file)
  file - a string or symbol for the name of the file
  returns - T if workspace was written, NIL otherwise

## Description

The 'save' function saves the current XLISP workspace [system state] to the specified file. The 'file' may be a string or a symbol. If the 'file' does not include a '.wks' suffix, it will be extended to be called 'file.wks'. The function returns T if the workspace was properly created and saved, NIL is returned otherwise. There can be several saved workspaces. These workspaces can be restored as often as desired.

## Examples

    (setq myvar 5)       ; set MYVAR to value 5
    myvar                ; returns 5

    (save 'farp)         ; save workspace in FARP.wks

    (setq myvar "garp")  ; change MYVAR to "garp"
    myvar                ; returns "garp"

    (restore 'farp)      ; restore workspace
    myvar                ; returns 5

Bug: The 'save' function generates a system error if the 'file' being created already exists. This 'file' will be modified and will not be restorable after restarting XLISP. [I still haven't tested this with Nyquist.]

Note: The saved workspace size is implementation dependent, but can be fairly large.

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:

This will create a file named FOO-FILE in UNIX, because XLISP uppercases its symbols:

    (open 'foo-file :direction :output)

This will create a file named 'foo-file' because UNIX doesn't uppercase its file names:

    (open "foo-file" :direction :output)

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: The XLISP 'save' function is similar in use to the 'save-world' function in Common Lisp. The primarily difference is that 'save-world' allows you to restart everything since it creates an executable file. The 'save' function requires you to start XLISP up first and then do a restore. Depending on the operating system that you are using, it is possible to write a 'save-world' equivalent using 'save', restore and system.htm functions.

See the save function in the XLISP 2.0 manual.

Back to Top

Nyquist / XLISP 2.0 - Contents | Tutorials | Examples | Reference