POSRANGE()

POSRANGE()

Left-most position of a character from a set in a string

Syntax

       POSRANGE( <cChar1>, <cChar2>, <cString>, [<lMode>],
                      [<nIgnore>] ) -> nPosition

Arguments

<cCharacter1> and <cCharacter2> Designate the first and the last character of the character range.

<cString> Designates the string within which to search for a character in the <cCharacter1> to <cCharacter2> range.

<lMode> Designates if the return value is within the specified range or outside of the range. The default value (.F.) searches for the first character within the range.

<nIgnore> Designates the number of characters at the beginning of the character string that are excluded from the search. The default value excludes none (zero).

Returns

The value returned corresponds to the position of the located character. If no character is found, the function returns 0.

Description

Beginning from the left, POSRANGE() searches for the first character in the range <cCharacter1> to <cCharacter2> within <cString>. If <lMode> is specified as .T., then the function searches for the first character that is not in the specified range. This way you could search for control characters within a string by specifying <cCharacter1> = CHR(0) and <cCharacter2> = CHR(31). The <nIgnore> parameter gives you the ability to exclude a particular number of characters at the beginning of the <cString> from the search.

Examples

       .  Search for the first character in the character string cInput
              that is not a control character:
              cInput  :=  COM_READ(1)
              ? POSRANGE(CHR(0), CHR(31), cInput, .T.)
           .  Ignore the first 10 characters:
              ? POSRANGE(CHR(0), CHR(31), cInput, .T., 10)

Compliance

POSRANGE() is compatible with CT3’s POSRANGE().

Platforms

All

Files

Source is pos1.c, library is libct.

Seealso

POSALPHA(), POSLOWER(), POSUPPER(), RANGEREPL()

Advertisements

2 responses to “POSRANGE()

  1. Pingback: Harbour String Functions | Viva Clipper !

  2. Pingback: Harbour All Functions – P | Viva Clipper !

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s