*--------------------------------- *+ *PURPOSE: * To return the row of where the expression is found in the array * being passed in (m.pt_aname). *SYNTAX: * m.pt_acol = ar_seek(m.pt_aname, m.pt_s_str, m.pt_acol) *PARAMETERS: * pt_aname -(A) Array name to be searched through. * m.pt_s_str -(N)|(C)|(D)|(L) The expression to search for. * m.pt_acol -(N) What column in the array to search. * *RETURNS: * m.pt_rvalue -(N) Check to see if the found element * is in the correct column. If it is, * return the row number. If it is not * returns 0. *REMARKS: * If the expression is found, this means the expression exist in array * pt_aname in row m.pt_rvalue and column m.pt_acol. *SEE ALSO: *- FUNCTION ar_seek PARAMETERS pt_aname, pt_s_str, pt_acol PRIVATE pt_element, pt_rvalue *** note: array name is passed by reference *** ar_seek(@arrayname, search str, [column]) m.pt_acol = IIF(PARAMETERS() < 3, 1, m.pt_acol) IF TYPE('pt_aname[1,1]') # 'U' .and. ; TYPE('m.pt_acol') = 'N' .and. ; ((ALEN(pt_aname,2) = 0 .and. ; m.pt_acol <= 1) .or. ; ALEN(pt_aname,2) >= m.pt_acol) m.pt_element = 1 && starting element number DO WHILE .t. m.pt_rvalue = ASCAN(pt_aname, m.pt_s_str, ; m.pt_element) IF m.pt_rvalue = 0 && not found EXIT ELSE *** Check to see if the found element is in the *** correct column. If it is, return the row *** number. If it is not keep on checking *** starting at the next element. IF ALEN(pt_aname,2) > 1 && two-dim array IF ASUBSCRIPT(pt_aname, m.pt_rvalue,2) = ; m.pt_acol m.pt_rvalue = ASUBSCRIPT(pt_aname, ; m.pt_rvalue, 1) EXIT ELSE m.pt_element = m.pt_rvalue + 1 ENDIF ELSE EXIT ENDIF ENDIF ENDDO ELSE m.pt_rvalue = -1 ENDIF RETURN(m.pt_rvalue)