Help for a Cicle on array
Posted: 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 :
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
the string must be made up of the Total of products + the third column product code
example :
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