Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Is it possible to figure out this mess?
Message
De
09/08/2007 16:33:30
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivie
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 8 SP1
OS:
Windows XP
Database:
Visual FoxPro
Divers
Thread ID:
01247190
Message ID:
01247194
Vues:
29
This message has been marked as a message which has helped to the initial question of the thread.
Hi Nadya,

At a quick glance, it does seem that a few SELECT - SQL statements will be simpler. And it might be easier to write your own code than to unwind someone else's.

To get consistent results among different results, you might consider doing more complicated selection tasks in some sort of function or class, so that you can change the calculations in one single place. But if it is only Bill_Main and Bill_Detail, even that doesn't seem warranted in this case. Unless you have lots of additional complicated details (such as special discounts).

I did something like this (a centralized function) in order to get consistent results for calculating, and preparing other data, for reports on shoe prices. But the details are quite involved in this case.

>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).
Difference in opinions hath cost many millions of lives: for instance, whether flesh be bread, or bread be flesh; whether whistling be a vice or a virtue; whether it be better to kiss a post, or throw it into the fire... (from Gulliver's Travels)
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform