Tinderbox v10 Icon

String.expectNumber()


Operator Type: 

Operator Scope of Action: 

Operator Purpose: 

Operator First Added: 

Operator in Current Baseline: 

Operator Last Altered: 

 Function  [other Function type actions]

 Item  [operators of similar scope]

 Stream parsing  [other Stream parsing operators]

 v9.1.0

 Baseline

 As at baseline


Syntax note: Operators without any defined mandatory arguments may omit their empty closing parentheses


String.expectNumber()

String.expectNumber

If the string begins with one or more contiguous character(s) that could be interpreted as a number, the String stream cursor skips to the end of that number sequence and parsing continues.

For example:

vText = $Text.expectNumber(); 

Tests that the next characters in the stream read from $Text is a sequence of digits, and advances the stream past a continuous runs of digits. Otherwise, it fails and the cursor does not advance. Either way, variable vText receives the resulting text stream as would any operator chained to .expectNumber() unless a failure occurs in which case chained operators are not processed.

If the input stream passes in "1234 items" the cursor advances past '1234' such that the remaining stream is " items".

If the input stream passes in "1,234 items" the cursor advances past '1' such that the remaining stream is "234 items". Notice how number formatting delimiters like a comma (or other locale-specific delimiters) used in string representations of numbers may confuse this operator is used without care.

The presumption for use of this operator is as an assist to help ensure to-be-captured content is correctly detected. Essentially, this is a 'if' style test: if the test is correct proceed, else the cursor remains where it is for any possible chained stream parsing operators.