Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Problem with numeric overflow (again!)
Message
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 8 SP1
OS:
Windows XP SP2
Divers
Thread ID:
00964813
Message ID:
00964837
Vues:
9
>
for i=1 to m.lCount
>	lnSum = evaluate('curtemp.' + sumfields[m.i,1]) + evaluate('m.'+sumfields[m.i,1])
>	try
>		replace ('curtemp.' + sumfields[m.i,1]) with m.lnSum in curtemp
>	catch to oError when oError.ErrorNo = 39
>		messagebox("lnSum = " + transform(m.lnSum) + " for field " + sumfields[m.i,1])
>		...
>	endtry
>endfor
>
Thanks, I currently have
for i=1 to m.lCount
					lnSum = evaluate('curtemp.' + sumfields[m.i,1]) + evaluate('m.'+sumfields[m.i,1])
					try
						replace ('curtemp.' + sumfields[m.i,1]) with m.lnSum in curtemp
						llReplace = .t.
					catch to oError
*!*						=messagebox("Error replacing!" + chr(13) + ;
*!*	                  oError.Message + chr(13) + ;
*!*	                  "Error #:"+Transform(oError.ErrorNo)+chr(13)+ ;
*!*	                  "Line #:"+Transform(oError.LineNo)+chr(13)+ ;
*!*	                  "Error #:"+Transform(oError.LineContents),48,"Error")
						if m.oError.ErrorNo = 39 && Numeric overflow
* we need to find maximum allowed for the field and use it instead of a sum
							local lcSetCompatible, lnSize
							lcSetCompatible = set('compatible')
							set compatible off && this is needed for fsize to return a field size
							lnSize = fsize(sumfields[m.i,1],"curtemp")
							set compatible &lcSetCompatible && restore its settings
							lnSum = 10 ^ m.lnSize - 1 && Maximum value for the field
							replace ('curtemp.' + sumfields[m.i,1]) with m.lnSum in curtemp
						endif
					finally && this is now not needed

					endtry
				endfor
If it's not broken, fix it until it is.


My Blog
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform