Re: Inform Telephone 2


24 Aug 1995 17:28:11 GMT

Arthur LaFrana <lafrana@omni.voicenet.com> wrote:
> A few days ago I posted a question asking about creating an Inform
> telephone. Some of the replies stated that I should try a
> special_number type routine. I have been able to work with small
> numbers with this global, but I have been unable to get past the two
> byte limit to be able to work with seven digit telephone numbers.

Integers in Inform are 16-bit, you can't store numbers larger than 65535
in them. So you'll need to do some character-by-character parsing of
the player's input. Try using grammar like this:

[ ConTopicOn w; consult_from = wn;
do w=NextWordStopped(); until (w=='on' or -1); if (w==-1) return -1;
wn--; consult_words = wn-consult_from;
if (consult_words==0) return -1; return 0;
];
Verb "dial" * ConTopicOn "on" noun -> Dial;

and then pulling apart the input, perhaps like this:

Array phone_number -> 2 0 3 4 5 9 1;

[ DialSub a i word len;
if (noun ~= Telephone) "You can't dial on that.";
if (consult_words ~= 1) "Try typing the phone number as one \
word, so ~dial 1234567~, not ~dial 123 4567~.";
a = (consult_from * 4) + 1 ! address of information in parse table
word = buffer + parse->a; ! address of phone number in input table
len = parse->(a-1); ! length of phone number in characters
if (len ~= 7) "Nothing happens. Perhaps you should type a phone \
number with seven digits.";
for (i = 0: i < 7: i++)
if (word->i ~= phone_number->i)
"The phone rings, but you get no answer.";
"~Hello?~ says a voice on the phone.";
];

--
Gareth Rees