Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Evaluation of numerics
Message
General information
Forum:
Visual FoxPro
Category:
Classes - VCX
Miscellaneous
Thread ID:
00413400
Message ID:
00413943
Views:
35
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
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform