If the weights are EXACTLY as you gave, then it's real easy.
Make a property list, with weights and prices, as in:
priceList =[.5:49.00, 1:63.70, 1.5:78.35, 2:93.00, 5:165.45, 10:275,
15:375.10, 20:468.45]
then just look it up:
itemPrice =getaProp(priceList, itemWeight)
So if itemWeight is 10, then the answer would be 275
On the other hand, if you need to do ranges, such as everything up to .5 kg
is 49.00, and from there until 1 kg is 63.70, then it gets a little more
complicated:
Make a list, either using a property list, or using two separate linear
lists, one part has weight thresholds, one part has prices.
Then, look through the list
For instance (using two linear lists)
weights =[.5, 1, 1.5, 2, 5, 10, 15, 20]
prices =[49.00, 63.70, 78.35, 93.00, 165.45, 275.00, 375.10, 468.45]
Then, if the weight of the item (in kilograms) is in a variable called
itemWeight, then find the appropriate price by scanning through..
on findPrice itemWeight
weights =[.5, 1, 1.5, 2, 5, 10, 15, 20]
prices =[49.00, 63.70, 78.35, 93.00, 165.45, 275.00, 375.10, 468.45]
numRanges =count(weights)
repeat with x=1 to numRanges
if (itemWeight < weights[x]) then
itemPrice =prices[x]
return(itemPrice)
end if
end repeat
-- Either return 0, or return a maximum price, or whatever you
-- need to do when it's outside the range.
return(0)
end
This presumes that you mean that up to .5 kg is $49. I haven't tried this
code out, but it should work as written.
- Tab
At 01:38 PM 5/10/01 +1200, Teo Petralia wrote:
>Hi!
>I would like to find out the price of an item or better a number of this
>items accordingly to their weight.
>In other words looking at the table below:
>
>0.5kg = $49.00
>1kg = 63.70
>1.5kg = 78.35
>2kg = 93.00
>5kg = 165.45
>10kg = 275.00
>15kg = 375.10
>20kg = 468.45
>
>how can I know the price of an order that weight 3kg or and order that
>weight 12.3kg.
>
>Thanks
>Teo
[To remove yourself from this list, or to change to digest mode, go to
http://www.penworks.com/LUJ/lingo-l.cgi To post messages to the list,
email [EMAIL PROTECTED] (Problems, email [EMAIL PROTECTED])
Lingo-L is for learning and helping with programming Lingo. Thanks!]