Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Question about ASORT()
Message
De
10/04/2002 04:04:08
Lazar Sorin-Voicu
Azur S.A. Subsidiary of Icc Ind. Newyork
Timisoara, Roumanie
 
 
À
08/04/2002 13:36:55
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
00641310
Message ID:
00643038
Vues:
30
This code is a part of a program (form) that resolves orders, production flow, distribution, invoices, raw materials stock, parts of general accounting, various reports, archives etc.
The problem appears in the orders/invoices section.
So I have two lists – first list contains the products – the second is empty (or not) regarding the order history of the consumer
By clicking on the first list the products are added on the order list.
By clicking on the second list the products are removed from de order list
The product record looks like:
Product code – codp – basic code (primary index - not important in this matter the index not the field)
Product type – varp - (depends on the way that the product is saled ex. no. of pieces etc.)
The rest of the data are general information about the product price, vat, etc.
All of the data is stored in a array (smartarea(20,11)
Now the problem:
When I sort the array after adding and removing product in the order the way that the products are displayed in the second list is not the same with the way that the products are stored in the array. So when I have the following situation Ex:
In the list
Product basic code Product type
123 1
123 2
123 3
In the array after asort(smartarea)
Product basic code Product type
123 1
123 3
123 2
So If the operator want’s to remove the second “record” 123;2 he removes the 123;3

I resolved that by inserting a column in the array (column 3 Step4) witch adds basic code and type in a single code and sorting after that but I don’t think that is the correct solution.
***
Step1 First list
***
THISFORM.formcom.ENABLED=.T.
IF THIS.PARENT.lis2.LISTCOUNT > 19
WAIT WINDOW "Maximum number of products 20!"
RETURN 0
ELSE
THIS.VALUE=STR(codp,3)+' '+STR(varp,2)+' '+STR(nrbuc,3)+' '+denupro+' '+denuvar+' '+STR(pret,6)+' '+atribut
THIS.PARENT.lis2.ADDITEM (THIS.VALUE)
ENDIF
nel=THIS.PARENT.lis2.LISTCOUNT
STORE produse.codp TO smartarea(nel,1)
STORE produse.varp TO smartarea(nel,2)
STORE produse.nrbuc TO smartarea(nel,4)
STORE produse.denupro TO smartarea(nel,5)
STORE produse.denuvar TO smartarea(nel,6)
STORE produse.pret TO smartarea(nel,7)
STORE produse.tva TO smartarea(nel,8)
STORE produse.atribut TO smartarea(nel,9)
STORE 0 TO smartarea(nel,10)
STORE 0 TO smartarea(nel,11)
ASORT (smartarea)
***
Step 2 Second list
***
THISFORM.formcom.ENABLED=.T.
THISFORM.REFRESH
nes=THIS.LISTINDEX
THIS.REMOVEITEM (THIS.LISTINDEX)
ASORT (smartarea)
STORE 1000 TO smartarea(nes,1)
STORE 0 TO smartarea(nes,2)
STORE 0 TO smartarea(nes,3)
STORE "" TO smartarea(nes,4)
STORE "" TO smartarea(nes,5)
STORE 0 TO smartarea(nes,6)
STORE 0 TO smartarea(nes,7)
STORE "" TO smartarea(nes,8)
ASORT (smartarea)
****
Step 3 Storing the order (With the problem)
****
FOR N=1 TO 20
STORE 1000 TO smartarea(N,1)
ENDFOR
THIS.VISIBLE=.F.
THISFORM.termcli.VISIBLE=.F.
THISFORM.formcom.VISIBLE=.T.
THISFORM.aficom1.VISIBLE=.F.
THISFORM.afilista1.VISIBLE=.T.
SELECT comenzi
N=1
SET FILTER TO cod=ariecli(1)
GO TOP
DO WHILE !EOF()
STORE codp TO smartarea(N,1)
STORE varp TO smartarea(N,2)
STORE nrbuc TO smartarea(N,4)
STORE denupro TO smartarea(N,5)
STORE denuvar TO smartarea(N,6)
STORE pret TO smartarea(N,7)
STORE tva TO smartarea(N,8)
STORE atribut TO smartarea(N,9)
STORE c1 TO smartarea(N,10)
STORE c2 TO smartarea(N,11)
ael=STR(codp,3)+' '+STR(varp,2)+' '+STR(nrbuc,3)+' '+smartarea(N,5)+' '+smartarea(N,6)+' '+STR(pret,6)+' '+atribut
ThisForm.Afilista1.lis2.ADDLISTITEM (ael)
N=N+1
SKIP
ENDDO
SELECT produse
THISFORM.afilista1.lis1.ROWSOURCETYPE=6
THISFORM.afilista1.lis1.ROWSOURCE='codp,varp,nrbuc,denupro,denuvar,pret,atribut'
IF arievar(5)=2
THISFORM.formcom.ENABLED=.T.
ENDIF
arievar(5)=4
****
Step 4 Storing the order (Problem resolved)
****
FOR N=1 TO 20
STORE 1000 TO smartarea(N,1)
STORE 9999 TO smartarea(N,3)
ENDFOR
THIS.VISIBLE=.F.
THISFORM.termcli.VISIBLE=.F.
THISFORM.formcom.VISIBLE=.T.
THISFORM.aficom1.VISIBLE=.F.
THISFORM.afilista1.VISIBLE=.T.
SELECT comenzi
N=1
SET FILTER TO cod=ariecli(1)
COUNT TO nrpoz
GO TOP
DO WHILE !EOF()
STORE codp TO smartarea(N,1)
STORE varp TO smartarea(N,2)
STORE ROUND(VAL(ALLTRIM(STR(codp))+ALLTRIM(STR(varp))),0) TO smartarea(N,3)
STORE nrbuc TO smartarea(N,4)
STORE denupro TO smartarea(N,5)
STORE denuvar TO smartarea(N,6)
STORE pret TO smartarea(N,7)
STORE tva TO smartarea(N,8)
STORE atribut TO smartarea(N,9)
STORE c1 TO smartarea(N,10)
STORE c2 TO smartarea(N,11)
N=N+1
SKIP
ENDDO
ASORT (smartarea,3)
FOR N=1 TO nrpoz
ael=STR(smartarea(N,1),3)+' '+STR(smartarea(N,2),2)+' '+STR(smartarea(N,4),3)+' '+smartarea(N,5)+' '+smartarea(N,6)+' '+STR(smartarea(N,7),6)+' '+smartarea(N,9)
THISFORM.afilista1.lis2.ADDLISTITEM (ael)
ENDFOR
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform