PAT |
pat used to check compliance of a string with a pattern.
pat( expr_c, pattern )
|
Element |
Description |
Restrictions |
|
expr_c |
Alphanumeric expression defining the string whose compliance is to be tested with the pattern given. |
None. |
|
pattern |
Alphanumeric expression defining the compliance pattern. |
None. |
# Does the string CH1 contain ADONIX?If pat(CH1, "*ADONIX*")
Infbox "The string CH1 contains ADONIX!" Endif# Check that CH1 contains a letter first, a figure at
# the end of the string, and precisely 3 characters in between the twoIf pat(CH1, "!???#") : # Test verified
Endif
pat is used to check compliance of a character string with a given pattern. This compliance uses the following conventions for the patterns:
· the character '*' represents any number of characters, even null,
· the character '?' represents precisely one character,
· the character '#' represents a digit,
· the character '!' represents a letter,
All the other characters in a pattern must exist in the character string to be checked so that compliance may be recognised.
pat returns an Integer type result: when the string is compliant, pat returns 1, otherwise a 0.
In some more sophisticated cases of compliance, the format$ function may be used. This actually formats a string from a given format, truncating it if necessary; if the format cannot be reproduced for lack of compliance, the string returned will be empty. For example, in order to check that CH1 consists of 3 digits followed by 5 characters in the set +, -, *, / and any number of characters, an input type may be defined (c for example) that only includes the following characters, and the test written:
If
format$("K:3#5c", CH1) <> " " : # (eight spaces)
# Compliance is correct
Endif
|
Error |
Description |
|
ERMODE (10) |
The arguments are not alphanumeric. |
|
|