$Substr

From m204wiki
Revision as of 13:18, 20 April 2013 by Alex (talk | contribs) (Automatically generated page update)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

The $SUBSTR function returns a substring of a string. $SUBSTR is identical to $DEBLANK except that $DEBLANK strips the resulting string of leading and trailing blanks, and $SUBSTR does not.

Syntax

The format of the $SUBSTR function is:

$SUBSTR(string, position, length)

where:

  • string is the string from which the substring is derived.
  • position is the position in the string at which the substring is to begin.
  • length is the maximum length of the substring. If this argument is omitted, a default value of 255 is used.

The position and length arguments are rounded to positive integers.

Example 1

$SUBSTR('KITTREDGE', 4,3) equals 'TRE' $SUBSTR('ANTELOPE', 7) equals 'PE' $SUBSTR('TOO', 19, 2) equals " (null string) $SUBSTR('ACCOUNT', -3, 5) equals 'ACCOU'

Example 2

This request searches the FIRST NAME field of all the Smiths and creates a list of names that begin with A, B, C, or D.

BEGIN FIND.RECS: FIND ALL RECORDS FOR WHICH LAST NAME = SMITH END FIND FOR EACH RECORD IN FIND.RECS IF $ONEOF($SUBSTR(FIRSTNAME, 1, 1),- 'A/B/C/D','/') THEN PLACE RECORD ON NAME . . .