Help for a Cicle on array

Post Reply
User avatar
Silvio.Falconi
Posts: 4956
Joined: Thu Oct 18, 2012 7:17 pm

Help for a Cicle on array

Post by Silvio.Falconi »

I have to compose a string ("cStructure") by taking the products in an array and counting the same ones

the string must be made up of the Total of products + the third column product code
example :

Image

the string must be "4LETT+1REGI"

I tried a test but not run ok, but return me only 4LETT and not 4LETT1REGI
Any solution ?

test

Code: Select all


#include "fivewin.ch"

Function test()

local aselezionati:={ {  "01","Lettino","LETT",10,"images\servizi\lettino.png","",1,},;
         {  "01","Lettino","LETT",10,"images\servizi\lettino.png","",1,},;
         {  "01","Lettino","LETT",10,"images\servizi\lettino.png","",1,},;
         {  "01","Lettino","LETT",10,"images\servizi\lettino.png","",1,},;
         {  "03","Regista","REGI",10,"images\servizi\regista.png","",1,}    }

xbrowser aselezionati
        ?Compose(aselezionati)
return nil

//--------------------------------------------------------------------------------//

 Function Compose(aselezionati)
   local n
   local cCodice:= ""
   local nQuant:= 0
   local cStructure:="" // THE STRING IS OF SPACE(15)
   local  k := 1

   For n= 1 to Len(aselezionati)

                       IF !Empty(aselezionati[ n, 3 ])  .and.;
                                        aselezionati[ n, 3 ]!=cCodice

                     do while k < Len( aselezionati )

                         if aselezionati[ k, 3 ] == cCodice
                             nQuant+=1
                           else

                           endif
                           k++


                        enddo
                         *
                         cStructure+=ltrim(str(nQuant))+cCodice
                        endif

                      cCodice:= aselezionati[ k, 3 ]
                       nQuant:= 0


                     *n++
                  // ? cStructure

   Next n

  return   cStructure

 
I use : FiveWin for Harbour August 2020 (Revision) - Harbour 3.2.0dev (r1712141320) - Bcc7.30 - xMate ver. 1.15.3 - PellesC
User avatar
Silvio.Falconi
Posts: 4956
Joined: Thu Oct 18, 2012 7:17 pm

Re: Help for a Cicle on array

Post by Silvio.Falconi »

any solution please ?
I use : FiveWin for Harbour August 2020 (Revision) - Harbour 3.2.0dev (r1712141320) - Bcc7.30 - xMate ver. 1.15.3 - PellesC
Post Reply