Page 1 of 1

help with please - Ayuda por favor

Posted: Sun Nov 20, 2022 11:15 am
by Jose Marte2
Greetings to all I hope you are well as well as your families

Friends, I need your help.

I have in my billing program, in the image that I attached I need to see how you can add the quantities of the items that
codes are the same, that is, they are repeated in the array

thanks in advance

A sample I have the arrangement

FOR J=1 To Len(aArreglo)
cCodArt := aArreglo[J][1]
cDesArt := aArreglo[J][2]
nCantid := aArreglo[J][3]
NEXT

Saludos para todos espero que esten bien al igual que sus familias

Amigos, necesito de su ayuda

tengo en mi programa de facturación, en la imagen que le adjunto necesito ver como puede sumar las cantidades de los articulos que los
códigos sean iguales es decir que están repetido en el arreglo

las gracias anticipadas

Una Muestra tengo el arreglo

FOR J=1 To Len(aArreglo)
cCodArt := aArreglo[J][1]
cDesArt := aArreglo[J][2]
nCantid := aArreglo[J][3]
NEXT

Re: help with please - Ayuda por favor

Posted: Mon Nov 21, 2022 12:08 am
by Wolfgang Ciriack
Hello Jose,
make a new array for display:

Code: Select all

FOR J=1 To Len(aArreglo)
   if (p := AScan(aNew, {|a| a[1] == aArreglo[J][1]}) == 0
      ** not in aNew
      AAdd(aNew, aArreglo[J])
   else
      ** add quantity to existing item
      aNew[p][3] += aArreglo[J][3]
   endif
NEXT
Then display aNew.