Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Evaluation of numerics
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Classes - VCX
Divers
Thread ID:
00413400
Message ID:
00413943
Vues:
36
Marc, are you looking for something like this?

? operate('120+5%') && -> 126
? operate('120-5%') && -> 114
? operate('110+10+5%) && -> 126

value=120
perc=5
? operate('value+perc%') && -> 126
function operate
lparameters lcOperation
local lnPosPlus, lnPosMinus, lnPos, lcValue, lcPerc

lnPosPlus=rat('+', lcOperation)
lnPosMinus=rat('-', lcOperation)

if (lnPosPlus=0 and lnPosMinus=0) or right(lcOperation, 1)#'%'
	return null && or whatever, like evaluate(lcOperation)
else
	lnPos=max(lnPosPlus, lnPosMinus)
	lcValue=left(lcOperation, lnPos-1)
	lcPerc=substr(lcOperation, lnPos+1, len(lcOperation)-lnPOs-1)
	lnReturn=evaluate(lcValue+substr(lcOperation, lnPos, 1)+'(('+lcValue+')*'+lcPerc+'/100)')
endif
return lnReturn
"The five senses obstruct or deform the apprehension of reality."
Jorge L. Borges?

"Premature optimization is the root of all evil in programming."
Donald Knuth, repeating C. A. R. Hoare

"To die for a religion is easier than to live it absolutely"
Jorge L. Borges
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform