Help for a Cicle on array

Help for a Cicle on array

Postby Silvio.Falconi » Tue Apr 21, 2020 7:27 pm

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  Expand view


#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

 
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: 7033
Joined: Thu Oct 18, 2012 7:17 pm

Re: Help for a Cicle on array

Postby Silvio.Falconi » Wed Apr 22, 2020 9:44 pm

any solution please ?
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: 7033
Joined: Thu Oct 18, 2012 7:17 pm


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 40 guests