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

REBOL 3 Functions: load

load  source  /header  /next  /all  /unbound

Loads a file, URL, or string.

Arguments:

source [file! url! string! binary! block!] - Source or block of sources

Refinements:

/header - Includes REBOL header object if present. Preempts /all.

/next - Load the next value only. Return block with value and new position.

/all - Load all values. Does not evaluate REBOL header.

/unbound - Do not bind the block.

See also:

save   read   do   import   bind  

Description

Reads and converts external data, including programs, data structures, images, and sounds into memory storage objects that can be directly accessed and manipulated by programs.

The argument to LOAD can be a file, URL, string, or binary value. When a file name or URL is provided, the data is read from disk or network first, then it is loaded. In the case of a string or binary value, it is loaded directly from memory.

Here are a few examples of using LOAD:

script: load %dict-notes.r
image: load %image.png
sound: load %whoosh.wav

;data: load http://www.rebol.com/example.r
;data: load ftp://ftp.rebol.com/example.r

data: load "1 2 luke fred@example.com"
code: load {loop 10 [print "hello"]}

LOAD is often called for a text file that contains REBOL code or data that needs to be brought into memory. The text is first searched for a REBOL header, and if a header is found, it is evaluated first. (However, unlike the DO function, LOAD does not require that there be a header.)

If the load results in a single value, it will be returned. If it results in a block, the block will be returned. No evaluation of the block will be done; however, words in the block will be bound to the global context.

If the header object is desired, use the /HEADER option to return it as the first element in the block.

The /ALL refinement is used to load an entire script as a block. The header is not evaluated.

The /NEXT refinement was removed - use TRANSCODE/NEXT instead


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