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

REBOL 3 Functions: new-line

new-line  block  value  /all  /skip  size

Sets or clears the new-line marker within a block. (Modifies)

Arguments:

block [block!] - Position in block to change marker

value - Set TRUE for newline

Refinements:

/all - Set/clear marker to end of block

/skip - Set/clear marker periodically to the end of the block

size [integer!]

See also:

new-line?  

Description

Where the NEW-LINE? function queries the status of the a block for markers, the NEW-LINE function inserts or removes them. You can use it to generate formatted blocks.

Given a block at a specified offset, new-line? will return true if there is a marker at that position.

dent-block: func [
    "Indent the contents of a block"
    block
][
    head new-line tail new-line block on on
]

b: [1 2 3 4 5 6]
probe dent-block b
[
1 2 3 4 5 6

]

If you want to put each item in a block on a new line, you can insert markers in bulk, using the /all refinement.

b: [1 2 3 4 5 6]
probe new-line/all b on
[
1
2
3
4
5
6

]

If you don't know whether a block contains markers, you may want to remove all markers before formatting the data.

b: [
    1 2 
    3 4
]
probe new-line/all b off
[1 2 3 4]

Another common need is formatting blocks into lines of fixed size groups of items; that's what the /skip refinement is for.

b: [1 2 3 4 5 6]
probe new-line/skip b on 2
[
1 2
3 4
5 6

]


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