UniBasic Commands Reference - Rocket Software
UniBasic Commands Reference - Rocket Software UniBasic Commands Reference - Rocket Software
MATCH Syntax var MATCH "[~] len [X, A, N] [text]" Synonym MATCHES Description The UniBasic MATCH or MATCHES function determines if a variable matches a specific pattern of characters, numbers, or a literal string. If var matches the pattern, MATCH or MATCHES returns 1. If var does not match the pattern, MATCH or MATCHES returns 0. Tip: You can mix codes and literal strings. To differentiate between the two, enclose the literal in single quotation marks within the larger pattern, which is enclosed in double quotation marks. Parameters The following table describes each parameter of the syntax. Parameter Description 1-442 UniBasic Commands Reference var Specifies the variable to compare with the MATCH expression. ~ Reverses the pattern. To match 4N, a string must contain four numeric characters. To match ~4N, a string must contain four characters that are not all numeric. len Specifies the number of characters to match. X Specifies that characters can be of any type. MATCH Parameters
Parameter Description A Specifies that only alphabetic characters match the pattern. N Specifies that only numbers match the pattern. text Specifies a literal string to search for. Enclose this literal text within single quotation marks if combined with a pattern (made up of X, A, and N). Examples MATCH Parameters (continued) In the following example, the program segment determines if the variable SSN is a valid social security number: SSN = "522-13-5124" SSNTEST = SSN MATCH "3N'-'2N'-'4N" The following program accepts as input a pattern to match and a string to search: PRINT "This program tests the MATCH function" PRINT "Enter pattern ": INPUT pattern PRINT "Enter string to match": INPUT string1 answer = string1 MATCH pattern PRINT \"\ : answer : \"\ In the following test executions of the preceding program, the user tests for a string that consists of three alphabetic characters followed by the literal “3A”. The literal (3A) is enclosed in quotation marks to differentiate it from the pattern 3A. :RUN BP match.test This program tests the MATCH function Enter pattern ?3A'3A' Enter string to match?AAA3A "1" :RUN BP match.test This program tests the MATCH function Enter pattern ?3A'3A' Enter string to match?3AAAA "0" MATCH 1-443
- Page 432 and 433: INPUTIF Syntax INPUTIF var [THEN st
- Page 434 and 435: INPUTTRAP Syntax INPUTTRAP string.e
- Page 436 and 437: INS Syntax INS expr BEFORE dyn.arra
- Page 438 and 439: INSERT Syntax INSERT(dyn.array.expr
- Page 440 and 441: INT Syntax INT(num.expr) Descriptio
- Page 442 and 443: ISNV Syntax ISNV(expr) Description
- Page 444 and 445: ISNVS Syntax ISNVS(dynamic.array) D
- Page 446 and 447: ITYPE Syntax ITYPE(itype.expr) Desc
- Page 448 and 449: LE Syntax expr1 LE expr2 Synonyms #
- Page 450 and 451: LEN Syntax LEN(str.expr) Descriptio
- Page 452 and 453: LENS Syntax LENS(dyn.array) Descrip
- Page 454 and 455: LISTUSER Syntax LISTUSER() Descript
- Page 456 and 457: LN Syntax LN(num.expr) Description
- Page 458 and 459: The following table describes the s
- Page 460 and 461: Parameters The following table desc
- Page 462 and 463: LOCATE in BASICTYPEs U, P, and M Th
- Page 464 and 465: However, in the following array, th
- Page 466 and 467: Parameters The following table desc
- Page 468 and 469: LOOP/REPEAT Syntax LOOP [statements
- Page 470 and 471: Examples The following example is t
- Page 472 and 473: LOWER Syntax LOWER(dyn.array.expr)
- Page 474 and 475: Related Command UniBasic LTS 1-434
- Page 476 and 477: MAT Syntax MAT dim.array = expr MAT
- Page 478 and 479: the values assigned to FEE1 would b
- Page 480 and 481: Parameter Description Examples In t
- Page 484 and 485: MATCHFIELD Syntax MATCHFIELD(str.ex
- Page 486 and 487: MATPARSE Syntax MATPARSE dim.array
- Page 488 and 489: The preceding program segment produ
- Page 490 and 491: Parameter Description INMAT Functio
- Page 492 and 493: MATREADL Syntax MATREADL dim.array
- Page 494 and 495: Example In the following example, t
- Page 496 and 497: Parameters The following table desc
- Page 498 and 499: Related Commands UniBasic DIM, INMA
- Page 500 and 501: Parameter Description STATUS Functi
- Page 502 and 503: MATWRITEU Syntax MATWRITEU dim.arra
- Page 504 and 505: MAXIMUM Syntax MAXIMUM(dyn.array.va
- Page 506 and 507: MDPERFORM Syntax MDPERFORM str.expr
- Page 508 and 509: Parameter Description Examples In t
- Page 510 and 511: MINIMUM Syntax MINIMUM(dyn.array.va
- Page 512 and 513: NE Syntax expr1 NE expr2 Synonyms #
- Page 514 and 515: NEG Syntax NEG(expr) Description Th
- Page 516 and 517: NFAUSER Syntax NFAUSER(“username
- Page 518 and 519: DCOUNT INDEX LEN SEQ SWAP 1-480
- Page 520 and 521: NOTS Syntax NOTS(dyn.array) Descrip
- Page 522 and 523: NUM Syntax NUM(expr) Description Th
- Page 524 and 525: NUMS Syntax NUMS(dyn.array) Descrip
- Page 526 and 527: OCONV Syntax OCONV(expr, conv.code.
- Page 528 and 529: OCONV Date (D) Syntax OCONV(integer
- Page 530 and 531: Note: Following SMA standards, Mond
MATCH<br />
Syntax<br />
var MATCH "[~] len [X, A, N] [text]"<br />
Synonym<br />
MATCHES<br />
Description<br />
The <strong>UniBasic</strong> MATCH or MATCHES function determines if a variable matches a<br />
specific pattern of characters, numbers, or a literal string. If var matches the pattern,<br />
MATCH or MATCHES returns 1. If var does not match the pattern, MATCH or<br />
MATCHES returns 0.<br />
Tip: You can mix codes and literal strings. To differentiate between the two, enclose<br />
the literal in single quotation marks within the larger pattern, which is enclosed in<br />
double quotation marks.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
1-442 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
var Specifies the variable to compare with the MATCH expression.<br />
~ Reverses 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 />
all numeric.<br />
len Specifies the number of characters to match.<br />
X Specifies that characters can be of any type.<br />
MATCH Parameters