Ax51 User's Guide

MATCH Function

The MATCH MPL function searches a character string for a delimiter character and assigns the substrings on either side of the delimiter to specified identifiers. The syntax for the MATCH function is:

%MATCH (id1 delimiter id2) (balanced-text)

Where

id1is a valid identifier that is assigned text in balanced-text left of delimiter.
delimiteris the first character to follow id1. Any non-macro character may be used (like a space or a comma).
id2is a valid identifier that is assigned text in balanced-text right of delimiter.
balanced-textspecifies the text the MATCH function searches. It may contain macro calls.

The MATCH function searches balanced-text for the specified delimiter. When the delimiter is found, all characters to the left are assigned to id1 and all characters to the right are assigned to id2. If the delimiter is not found, the entire balanced-text string is assigned to id1 and the null string is assigned to id2.

Source Text

%DEFINE (text) (-1,-2,-3,-4,-5)
%MATCH (next,list) (%text)
%WHILE (%LEN (%next) NE 0)
(      MOV  A,#%next
       MOV  @R1,A %MATCH
       INC  R1
(next,list)(%list)
)

Output Text

MOV    A,#-1
MOV    @R1,A
INC    R1
MOV    A,#-2
MOV    @R1,A
INC    R1
MOV    A,#-3
MOV    @R1,A
INC    R1
MOV    A,#-4
MOV    @R1,A
INC    R1
MOV    A,#-5
MOV    @R1,A
INC    R1