Tinderbox v9 Icon


Operator Type: 

Operator Scope of Action: 

Operator Purpose: 

Operator First Added: 

Operator Last Altered: 

Operator Has Optional Arguments: 

 Function  [other Function type actions]

 Item  [operators of similar scope]

 Stream parsing  [other Stream parsing operators]


 As at baseline

 [More on optional operator arguments]

Stream.try{ action(s) }[.thenTry{ action(s) }]

If the first test action fails, they restore the string and allow you to process it a different way. The current success/failure state can be tested using the .failed() operator.

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

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

For example:

   fail(); //signal an explicit failure and return a 'false' value to an enclosing expression

looks for strings such as "To:John Doe"

If the string "To:" is not found, $MyString will be unchanged. If found, $MyString's value is set to the word that follows, up to the next whitespace character or the end of the string, i.e. "John".