REBOL 3 Docs Guide Concepts Functions Datatypes Errors
  TOC < Back Next >   Updated: 6-Feb-2009 Edit History  

REBOL 3 Concepts: Blocks: Paths for Nested Blocks

Pending Revision

This document was written for R2 and has yet to be revised for R3.

The path notation is useful for nested blocks.

The fourth value in values is a block containing another block. The following examples use a path to get information about this value.

To look at nested values, type:

probe values/4
["one" ["two" %file2.txt]]
probe values/4/2
["two" %file2.txt]

To get the lengths of nested values, type:

print length? values/4
print length? values/4/2

To see what the datatype of a nested value, type:

print type? values/4
print type? values/4/2

The two series values in the fourth value's block can also be accessed.

To look at the values, type:

probe values/4/2/1
probe values/4/2/2

To get the lengths of the values:

print length? values/4/2/1
print length? values/4/2/2

To see what datatype the values are:

print type? values/4/2/1
print type? values/4/2/2

To modify the values:

change (next values/4/2/1) "o"
probe values/4/2/1
change/part (next find values/4/2/2 ".") "r" 3
probe values/4/2/2

The above examples illustrate REBOL's ability to operate on values nested inside blocks. Note that in the last series of examples, change is used to modify a string and file series three layers deep in values. Printing out the values block produces:

probe values
["new" [1 2] %file1.txt ["one" ["too" %file2.r]]]

  TOC < Back Next > - WIP Wiki Feedback Admin