Can variables used in functions?
-
Hi there,
i have a big Problem.
Imagine, I want to calculate the total Price of different parts, that have a Price payed, a amount bought and an amount used.
For example:
ingredient1 Price: 5.00 Euro
bought: 100ml
used: 20mlPrice / bought * used is the solution for calculating the Price of the amount used. Thats easy.
But what I one or more ingredients are not bought (so bought is “0”) => results in Division through Zero.
Is it possible do something like this:
If incredient1bought = 0 then totalPrice = totalPrice
Else totalPrice = totalPrice + ingredient1price / ingredient1bought * ingredient1usedIf incredient2bought = 0 then totalPrice = totalPrice
Else totalPrice = totalPrice + ingredient2price / ingredient2bought * ingredien2usedIf incredient3bought = 0 then totalPrice = totalPrice
Else totalPrice = totalPrice + ingredient3price / ingredient3bought * ingredien3usedSo totalPrice is updated whenever an “bought” value is not “0”
Can totalPrice be used as a variable the Price of each used ingredient is added like this?
I can think of a Workaround creating a Price field for every single ingredient, but this could be a heavy Workaround 🙂
The topic ‘Can variables used in functions?’ is closed to new replies.