Tech Tip!

The LOCATE function is the most commonly used function in a multi-value system when searching for a specific string expression.

But there is a minimal issue when using LOCATE with sequence option in an array with precession (decimal) element.

array=''
list.array = 4.5 :@VM: 21 :@VM: 8.1 :@VM: 32 :@VM: 70
FOR v = 1 TO 5
LOCATE(list.array<1,v>,array,1;position;'ar') THEN NULL
array = INSERT(array,1,position;list.array<1,v>)
NEXT v
FOR a = 1 TO 5
PRINT array<1,a> :"-":
NEXT a


OUTPUT
21-32-4.5-70-8.1

Notice that the decimal is ignore by the LOCATE function.  In order to address this, you must always place your numbers in an internal format with an ICONV or multiplying by a number that will remove the decimal.

The original post for this tip can be found at:
http://greatxam.wordpress.com/2010/06/15/d3-locate-function/

 

 

menu
menu