Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Behavior of a Object into a Collection
Message
De
21/02/2006 11:51:20
Moacyr Zalcman
Independent Consultant
São Paulo, Brésil
 
 
À
Tous
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Titre:
Behavior of a Object into a Collection
Versions des environnements
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Database:
MS SQL Server
Divers
Thread ID:
01097766
Message ID:
01097766
Vues:
54
Hi, everybody

I need to put in an array the properties of an object using [amembers], but the result is inconsistent. I put some code in a program just to demonstrate:

LOCAL nlines

ColItensRomaneio=NEWOBJECT("Collection")
objItemRomaneio1=CREATEOBJECT("empty")

ADDPROPERTY(objItemRomaneio1,'EANCODE')
ADDPROPERTY(objItemRomaneio1,'Produto')
ADDPROPERTY(objItemRomaneio1,'qtd')
ADDPROPERTY(objItemRomaneio1,'preco')
ADDPROPERTY(objItemRomaneio1,'total')
ADDPROPERTY(objItemRomaneio1,'prodID')
ADDPROPERTY(objItemRomaneio1,'romaneioID')

produtoID="37745"
eancode="9990000377459"
preco=10.20
qtd=1
Produto="CAPRI ELEN"
romaneioID='109871'


ObjItemRomaneio1.EANCODE= eancode
ObjItemRomaneio1.Produto= produto
ObjItemRomaneio1.qtd= qtd
ObjItemRomaneio1.preco= preco
ObjItemRomaneio1.total=ObjItemRomaneio1.qtd*ObjItemRomaneio1.preco
ObjItemRomaneio1.prodID=produtoid
ObjItemRomaneio1.romaneioID=romaneioID
ColItensRomaneio.Add(ObjItemRomaneio1,ObjItemRomaneio1.prodID)

SET STEP ON
nlines=ColItensRomaneio.Count

FOR EACH loItem IN ColItensRomaneio
n = amembers(aTeste,loItem,1)
=MESSAGEBOX(n)
NEXT

FOR EACH loItem IN ColItensRomaneio
=MESSAGEBOX(loItem.EANCODE)
n = amembers(aTeste,loItem,1)
=MESSAGEBOX(n)
NEXT

In the first FOR..EACH LOOP the value I get was 0(zero). In the next was 1(One). The difference is only a messagebox.The correct value I expect is 7(seven)
If I use ObjItemRomaneio1 directly the result is 7(OK).

Aren't loItem and ObjItemRomaneio1 references to the same thing?

Could someone run this piece of code to give me the answers one gets?

TIA
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform