POSDIFF()

POSDIFF()

The left-most position there two string differ

Syntax

       POSDIFF( <cString1>, <cString2>, [<nIgnore>] ) 
                -> nPosition

Arguments

<cString1> and <cString2> Designate the two character strings that are compared.

<nIgnore> Designates how many characters at the beginning of the character strings are excluded from the search. The default value excludes none (0).

Returns

POSDIFF() returns the first position where <cString1> and <cString2> differ. If both character strings are equal, then the function returns 0.

Description

POSDIFF() compares two strings and determines from which position the first difference occurs. The <nIgnore> parameter allows you to exclude a particular number of characters from the beginning of both character strings from the search.

Note

. Character strings of different lengths can be compared with each other (see examples).

Examples

       .  This example compares two strings of the same length:
              cString1  :=  "X23AB\/A"
              cString2  :=  "X23A8\/A"
              ? POSDIFF(cString1, cString2)           // Result: 5
           .  Two strings of different lengths can also be compared:
              ? POSDIFF("AB", "ABC")                  // Result: 3

Compliance

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

Platforms

All

Files

Source is posdiff.c, library is libct.

Seealso

POSEQUAL()

Advertisements

2 responses to “POSDIFF()

  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