Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Is it possible to figure out this mess?
Message
 
 
À
Tous
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Titre:
Is it possible to figure out this mess?
Versions des environnements
Visual FoxPro:
VFP 8 SP1
OS:
Windows XP
Database:
Visual FoxPro
Divers
Thread ID:
01247190
Message ID:
01247190
Vues:
77
Hi everybody,

Ok, I guess the task is impossible.

Each object creates extra references to other objects and they create some other references and I think this chain doesn't have an end at all.

Say, there are two related tables Bill and BillDet. I want to get total amount for the bill.

Here is some code:
* Get the Bill Details.
		.oFile.open('Billdet')
		select SourceCode + CapCode, Ky ;
			from Billdet ;
			where KyBill = m.lnKyBill ;
			order by 1 ;
			into array laResults

*** As you see here I can get the amount by simple select and the amount is correct
*		SELECT sum(Amount) as TotalAmount FROM BillDet WHERE kyBill = m.lnKyBill
			
		.DetailCount = _tally
		
		if .DetailCount = 0
			dimension .Details[1]
			.Details[1] = .null.
		else
			dimension .Details[.DetailCount]
			for i = 1 to .DetailCount
				.Details[m.i] = newobject('CBillDet', 'c_billdet.prg')
				.Details[m.i].GetRec(laResults[m.i, 2])
				if .Details[m.i].InterestCount > 0
					.hasInterestAttachment = .t.
				endif
* Changed by Nadya Nosonovsky at 08/08/2007 05:30:00 PM
* Here I'm trying to follow the flow and use this complex reference, but I end up with the wrong number
				.nTotalAmount = .nTotalAmount + .Details[m.i].oTabBillDet.oFields.Amount && Let's calculate total amount
			endfor
		endif
		use in 'Billdet'
Trying to follow the logic and see all this complex classes seems to be impossible.

May be I should just put this select there and hope that the rest of the code works? I already found one minor bug in the code, but the rest I even can not comprehend :(

The developer has passed away. I want to try to use the existing classes for my tasks, but now I would have to use them without full understanding...

I'm also afraid I would not be able to clean the dangling references, if we have them (almost certain we do).
If it's not broken, fix it until it is.


My Blog
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform