Tinderbox v9 Icon

Functional control structure operators

Functional control structure

Two control structures are used with functional string processing.

Stream.eachLine(x[:condition]){action}

The .eachLine(){} operator allows iteration through each line of a string, performing an action on each. For attributes like $Text, a line equates to a paragraph as the delimiter is a line break character.

Stream.try{action}[.thenTry{action}]

Saves the value of an attribute and attempts an action. If the action fails because one of its operators fails or the fail() operator is performed, the value of the attribute used as a stream source

A .try{} may be followed by one or more .thenTry{} clauses. If the original .try{} succeeded, all subsequent .thenTry{} clauses are ignored. If the original .try{} failed, then each .thenTry{} is attempted in turn. Once a .thenTry{} clause succeeds, subsequent .thenTry{} clauses are ignored.



A Tinderbox Reference File : Actions & Rules : Stream Processing and parsing : Functional control structure operators