Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Ascan() ...... I Give UP !!!!
Message
From
24/09/1998 13:45:41
 
 
To
24/09/1998 07:39:01
Joao Godinho
Fredesenvolv, Lda
Lisbon, Portugal
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00140287
Message ID:
00140475
Views:
30
>dimension my_array(3,2)
>my_array[1,1] = 1
>my_array[1,2] = 3.00
>my_array[2,1] = 2
>my_array[2,2] = 450.00
>my_array[3,1] = 3
>my_array[3,2] = 2.00
>
>I want the see if value 3 exist in the 1st column
>
>if i do
>pos = ascan(my_array, 3) then pos will be = 2
>
>what to do ????
>
>Thank you ALL
*---------------------------------
*+
*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)
Fred
Microsoft Visual FoxPro MVP

foxcentral.net
Previous
Reply
Map
View

Click here to load this message in the networking platform