UniBasic Commands Reference - Rocket Software

UniBasic Commands Reference - Rocket Software UniBasic Commands Reference - Rocket Software

rocketsoftware.com
from rocketsoftware.com More from this publisher
11.04.2013 Views

MATCHFIELD Syntax MATCHFIELD(str.expr,"[~] {len [X | ,A | ,N]} [text]", field.expr) Description The UniBasic MATCHFIELD function returns a substring that matches a pattern or literal. If no match is made, UniData returns an empty string. MATCHFIELD supports multibyte languages. You can mix the codes and a text string to search for specific patterns separated by characters. With null value handling on, if a function encounters the null value in a parameter when a number is expected (field.expr), a warning message displays and UniBasic uses 0. Parameters The following table describes each parameter of the syntax. Paramete r Description 1-444 UniBasic Commands Reference str.expr Specifies the variable to compare with the MATCH expression. ~ Inverses the pattern. To match 4N, a string must contain four numeric characters. To match ~4N, a string must contain four characters that are not numeric. len Specifies the number of characters to match. X Specifies that characters can be of any data type. A Specifies that only alphabetic characters match the pattern. MATCHFIELD Parameters

Paramete r Description N Specifies that only numbers match the pattern. text Specifies a literal string to search for. field.expr Specifies a portion of the str.expr to return. Each code segment is considered to be a field for the purposes of field.expr. Examples MATCHFIELD Parameters (continued) In the following example, the program segment returns the value 56 because the entire string matches the specified criteria, and the third field contains the number 56: SSN = "534-56-5565" MID = MATCHFIELD(SSN,"3N'-'2N'-'4N",3) In the next example, the program segment searches the string and returns the second and fourth fields and prints “99922”: STRING = "ALL999WERE22ABSENT" NUM1 = MATCHFIELD(STRING,'3A3N4A2N6A',2) NUM2 = MATCHFIELD(STRING,'3A3N4A2N6A',4) PRINT NUM1:NUM2 MATCHFIELD 1-445

MATCHFIELD<br />

Syntax<br />

MATCHFIELD(str.expr,"[~] {len [X | ,A | ,N]} [text]", field.expr)<br />

Description<br />

The <strong>UniBasic</strong> MATCHFIELD function returns a substring that matches a pattern or<br />

literal. If no match is made, UniData returns an empty string. MATCHFIELD<br />

supports multibyte languages.<br />

You can mix the codes and a text string to search for specific patterns separated by<br />

characters.<br />

With null value handling on, if a function encounters the null value in a parameter<br />

when a number is expected (field.expr), a warning message displays and <strong>UniBasic</strong><br />

uses 0.<br />

Parameters<br />

The following table describes each parameter of the syntax.<br />

Paramete<br />

r Description<br />

1-444 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />

str.expr Specifies the variable to compare with the MATCH expression.<br />

~ Inverses the pattern. To match 4N, a string must contain four numeric<br />

characters. To match ~4N, a string must contain four characters that are not<br />

numeric.<br />

len Specifies the number of characters to match.<br />

X Specifies that characters can be of any data type.<br />

A Specifies that only alphabetic characters match the pattern.<br />

MATCHFIELD Parameters

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!