I have a use for the Metric Units extension, but I am not really all that conversant in metric units and I don't care too much about rounding errors, so I'd like to be able to say things in the source like "the height of a person is usually about 5 foot 6" and have Inform convert this into 167.64 centimeters (give or take) for me, but I can't seem to figure out how to make this happen. I tried:
Code:
To decide which length is about (X - a number) foot (Y - a number): decide on ((X * 12 + Y) * 2.54) centimeters.
To decide which length is about (X - a number) feet: decide on X foot 0.
To decide which length is about (X - a number) inch: decide on 0 foot X.
To decide which length is about (X - a number) inches: decide on 0 foot X.
[...]
A thing has a length called the height. The height of a person is usually 5 foot 6.
But Inform says:
Quote:
Problem. In the sentence 'The height of a person is usually about 5 foot 6' , it looks as if you intend 'The height of a person is usually about 5 foot 6' to be asserting something, but that tries to set the value of the 'height' property to an object - which must be wrong because this property has to be a length.
What is the magic syntax that makes this work?
ETA: After experimenting, it seems that to really get the calculations right, the functions have to be like this:
Code:
To decide what length is about (X - a number) foot (Y - a number) (this is imperial-conversion):
decide on (((X * 12) + Y) * 127cm) / 50.
To decide what length is about (X - a number) feet: decide on imperial-conversion applied to X and 0.
To decide what length is about (X - a number) inches: decide on imperial-conversion applied to 0 and X.
It will let me assign the result using "let" and can print them out using "say", but I can't use it as a default value or in any phrase using "is". This is very tiresome.