REBOL 3 Docs Guide Concepts Functions Datatypes Errors
  TOC < Back Next >   Updated: 3-Aug-2010 Edit History  

REBOL 3 Functions: save

save  where  value  /header  header-data  /all

Saves a value or a block to a file, URL, or into a string.

Arguments:

where [file! url! binary! string! none!] - Where to save (suffix determines encoding)

value - Value to save

Refinements:

/header - Save it with a header

header-data [block! object! logic!] - Header block, object, or take object from value

/all - Save in serialized format

See also:

load   mold   write  

Description

The save function is used to save REBOL code and data to a file, upload it to a URL, or store it into a local string.

When saving to a file or URL, the output of this function is always UTF-8 (an Unicode encoded format where ASCII is normal, but other characters are encoded.)

The format of the resulting output depends on what you need. The save function is designed to allow simple values to be easily saved to be loaded with load later:

save %date.r now
load %date.r
26-Feb-2009/13:06:15-8:00

But, it also allows complex more complex data to be saved:

save %data.r reduce ["Data" 1234 %filename now/time]
load %data.r
["Data" 1234 %filename 13:07:15]
save %options.r system/options
load %options.r
make object! [
    home: %/C/rebol/
    script: none
    path: %/C/rebol/
    boot: %/C/rebol/view.exe
    args: none
...

In general, save performs the appropriate conversion and formatting to preserve datatypes. For instance, if the value is a REBOL block, it will be saved as a REBOL script that, when loaded, will be identical.

Editor note: saving /all

Editor note: saving with headers

Note: Users must take care in how saved data is loaded. More on this below.


  TOC < Back Next > REBOL.com - WIP Wiki Feedback Admin