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
2
print length? values/4/2
2

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

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

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
two
probe values/4/2/2
%file2.txt

To get the lengths of the values:

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

To see what datatype the values are:

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

To modify the values:

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

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 > REBOL.com - WIP Wiki Feedback Admin