know an array

know an array

Postby Silvio.Falconi » Mon Jul 16, 2018 7:29 pm

I have a dbf and save the records on a array with conditions saving only the number of invoice (n)

if I created an array type

AaDd(aSilvio, {n})

if I would like to know if a number (n) has been inserted into that array more than once, how should I know?
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7076
Joined: Thu Oct 18, 2012 7:17 pm

Re: know an array

Postby darioflores » Tue Jul 17, 2018 10:30 am

Hello, you could try something like this:

Code: Select all  Expand view  RUN


   nIterations := 0
   
   nPos := aScan(aArray, {|x| x[1]==nFac})
   do while nPos>0
      nIterations++
      nPos := aScan(aArray, {|x| x[1]==nFac}, nPos+1)
   enddo

 
darioflores
 
Posts: 17
Joined: Tue Oct 06, 2015 7:06 am

Re: know an array

Postby Silvio.Falconi » Tue Jul 17, 2018 11:28 am

thanks
I wish search on rooms
the room number 13 have two bookings
I made


Code: Select all  Expand view  RUN
Function ControlloMulti(aMultiplePre,nNumero,nStatus,cGuest ,cTypeDay)
   Local t
   Local lReturn :=.f.
   Local nTimes:= 0
   Local nIterations:=0
   Local   nPos := aScan(aMultiplePre, {|x| x[1]==nNumero})

   do while nPos>0
      nIterations++
      nPos := aScan(aMultiplePre, {|x| x[1]==nNumero}, nPos+1)
   enddo

   IF  nIterations >1
      AaDd(aPreMulti,{nNumero,nStatus,cGuest ,cTypeDay } )
     lReturn :=.t.
  endif

return  lReturn
 


the problem is I see only one booking and not all for a room sample on room 13 I have two bookings but the function show me this

Image
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7076
Joined: Thu Oct 18, 2012 7:17 pm

Re: know an array

Postby Silvio.Falconi » Tue Jul 17, 2018 11:40 am

Now I correct with
Code: Select all  Expand view  RUN
Function ControlloMulti(aMultiplePre,nNumero,nStatus,cGuest ,cTypeDay)
   Local t
   Local lReturn :=.f.
   Local nTimes:= 0
   Local nIterations:=0
   Local   nPos := aScan(aMultiplePre, {|x| x[1]==nNumero})


   do while nPos>0
      nIterations++
      nPos := aScan(aMultiplePre, {|x| x[1]==nNumero}, nPos+1)
   enddo

   IF  nIterations >=2
      For n= 1 to Len(aMultiplePre)
         IF  aMultiplePre[n][1] = nNumero
             AaDd(aPreMulti,{nNumero,nStatus,cGuest ,cTypeDay } )
             lReturn :=.t.
   Endif
   next
  endif

   return lReturn



and it show now the two bookings for room 13

Image

but it is correct ?
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7076
Joined: Thu Oct 18, 2012 7:17 pm


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 66 guests