$syntax

Convert a string to a syntax string.

$syntax(String {,SyntaxMode) }

Example: if (NAME1 = $syntax("D&G","CaseInsensitive")) ...

Parameters

Parameters
Parameter Data Type Description
String String String to convert to a syntax string
SyntaxMode String Syntax string mode to apply; one of:
  • Classic (default)
  • CaseInsensitiveor CI
  • CaseSensitiveor CS
  • NlsLocale

Return Values

Returns the syntax string if successful, or an empty string if an error occurred. In this case, $procerror contains a negative value that identifies the exact error.

Values of $procerror Commonly Returned Following $syntax
Value Error constant Meaning
-1013 UPROCERR_SYNTAXSTRING Not a valid syntax string.

Use

Allowed in all component types.

Description

A syntax string is a group of characters and syntax codes enclosed in single quotation marks (') that can be used to match a string with the particular syntax pattern. For more information, see Syntax Strings for Pattern Matching.

$syntax converts String to a syntax string. Typically, the syntax string is then used in logical expressions (such as if, repeat, or while statements) to check whether a string matches the particular syntax pattern.

Note:  In a logical expression, the pattern specified by the syntax string must occur within the first 256 characters of the string with which it is being compared.

$syntax can also be used to perform case-insensitive scans and comparisons when the string contains diacritics (for example, an umlaut).

Syntax Modes

Syntax modes determine how characters and syntax codes are treated when performing a pattern-matching search.

Syntax String Modes
Syntax String Mode Meaning Example Resulting Syntax String Matches
Classic The following characters in String are treated as syntax codes for pattern-matching: # * & @ ~ ? ( ) % ^

This is the default, and corresponds to behavior prior to Uniface 9.4.01

$syntax("D&G") '%[X]D&G' DOG, DIG, etc.
CaseSensitive Match only characters with the same case and treat syntax code characters as literals, not codes

$syntax("D&G", "CS")

'%[CS]D%&G%[X]' D&G
CaseInSensitive Match all characters irrespective of case, and treat syntax code characters as literals, not codes

Treat the characters that follow as case-insensitive.

$syntax("D&G", "CI")

'%[CI]D%&G%[X]' D&G, d&g, D&g, d&G
NlsLocale Match all characters irrespective of case according to the locale, and treat syntax code characters as literals, not codes

$syntax("i#B", "NlsLocale")

'%[NLS]i%#B%[X]' Depends on locale.

If $NlsLocale= tr_TR, matches: i#B and İ#b, but not I#B

You can combine search modes in a syntax string. For example:

$syntax("[CI]D%&%[CS]G%[X]") returns D&G and d&G.

Matching Text Strings

The following example matches all text entered in the current field that starts with "New":

vString = "New*"
if (@$fieldname = $syntax(vString))
...
endif

Matching Case

The following example matches all text that contains one or more uppercase or lowercase letters:

vMatch = "&&*"
if (NAME1 = $syntax(vMatch))
...
endif
History
Version Change
9.4.01 Added second parameter: SyntaxMode

Related Topics