Navigation:  Reference > Functions >

StringLoc()

Print this Topic Previous pageReturn to chapter overviewNext page

 

LOC(1,2,3,4,5)

 

PURPOSE

This is an instring function.  It will return the location of a string of characters (A type field) within another A type field.

 

PARTS

1 f/c/eRequired - Field to check for, must be A type.

 

2 f/c/eRequired - Field to check within, must be A type.

 

3 f/c/eThe character position where the function will start checking.  The first position (far left) is 1.  If this value isn't provided the default value is 1.

 

4 f/c/eThe number of characters to check.  If this value isn't provided the function will check the entire field (part 2).

 

5 f/c/eIf this is set to Y, the function will ignore differences in case (upper or lower).  Default is N.

 

RETURN TYPE - I

The first character position of the matched field.  If no match is found the return is 0.

 

COMMENTS

If you are using a field as the search for value (part 1) make sure that you TRIM() the value first.  This can be done within the LOC().  If you don't, the function will try to match all trailing spaces.  Obviously, if you are looking for the exact match, spaces and all, don't TRIM() it.

 

SEE ALSO

ELOC()

 

EXAMPLE

define x type i

define s type a size 20

s = 'ABCDEFGHCDIJ'

x = LOC('CD',s)

// x = 3

 

x = LOC('CD',s,4,5)

// x = 0

 

define srch_fld type a size 10

srch_fld = 'CD'

// make sure you trim srch_fld since the # of chars

// you're looking for is less than the size of the field.

x = LOC(trim(srch_fld,'t'),s)

// x = 3

 

 


Page url: http://www.cassoftware.com/tas/manual/stringloc().htm