3.5.7.31 NumBreak

Description

This function takes a mixed string "str$", looks the type of the first character, if it is a numeric character, the function will return the index of the first non-numeric character, and vice versa. The optional parameter "offset" specifies the index offset from where the function looks for the "break" position of the first numeric and text character change.

Syntax

 int NumBreak(string str$[, int offset, int decimal])

Parameters

str$

is a string in which to look for the index of the first numeric and text character change.

offset

Optional parameter. offset is an index offset starting from which to look for the beak position. Default is 1, which means find from the beginning of the string "str$".

decimal

Optional parameter. decimal determines whether to use the decimal separator in the text string opposite to current system used. If text str$ uses comma "," as the decimal separator and the current system uses period ".", set decimal to 1 to treat comma as decimal separator. Vice versa.

Return

Returns the index at which the first number and non-number change is found in "str$", starting at "offset" (default 1).

If a break, either number or non-number, is not found (i.e. the entire string has no number mixed), it returns 0.

Example

Numbreak("Jan-12")=; //should return 5

Numbreak("Club45North")=; //should returns 5
Numbreak("Club45North", 5)=; //should returns 7 since find starting from "4"
Numbreak("Club45North", 3)=; //should returns 5 since find starting from "u"
Numbreak("Club45North", 7)=; //should returns 0, starting from "N" and thus no non-digit to digit change found to the end

//should returns 7, starting from "1", compare with next script
NumBreak("abcd12,3", 5)=; 
//should returns -1, starting from "1" and "12,343" is treated as number "12.343", 
//no digit to non-digit change found to the end
NumBreak("abcd12,343", 5, 1)=;

See Also

NumExtract