Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

[Inform] Beginner's Question re: SetTo and special

0 views
Skip to first unread message

Sam Roberts

unread,
Aug 31, 2000, 11:27:46 PM8/31/00
to
I am trying to code up a dial object that can be set or turned to a
numeric
value (like a radio dial or the dial on a combination lock, for
example).

I would like to be able to say "Set dial to 32" or "Turn dial to 32".

The grammer for the Set verb in the grammar.h library file uses
the special token. (In one place the Designer's Manual says that the
special token is "obsolete and best avoided", and in another that it
matches
any single word or number.)

I'm not sure how to be sure that I only accept "Set dial to <number>"
and not "Set dial to fred" or some object name. I would like to be able
to
restrict the setting for my dial object without restricting those for
other
set-able objects, which might allow more general settings. Is there an
easy way to accomplish this?

It seems impossible in the SetTo case of the before routine for the dial

to distinguish between a number and some object (which also equates to a

number)?

(If anyone has any examples of something like this, a code snippet would
be
greatly appreciated!)

Thanks!

Sam Roberts


Adam Cadre

unread,
Sep 1, 2000, 12:20:11 AM9/1/00
to
Sam Roberts wrote:
>
> I am trying to code up a dial object that can be set or turned to a
> numeric value (like a radio dial or the dial on a combination lock,
> for example).
> [...]

> (If anyone has any examples of something like this, a code snippet
> would be greatly appreciated!)

Sure. Here's the code for the dial from Varicella:

Object -> dial "dial"
with name 'channel' 'selection' 'dial',
number 0,
describe [; rtrue; ],
description [;
"This is a simple dial, numbered from 0 to 45. It is currently
set to ", self.number, ".";
],
before [a;
if (painting in vwall) "The dial is currently hidden by the
oil painting on the wall.";
if (panel hasnt open) "The dial is currently hidden by the
panel designed for that purpose.";
Turn, Set: "You must specify a number from 0 to 45.";
SetTo: a = special_number;
if (a > -1 && a < 46) {
self.number = a;
"You set the dial to ", self.number, ".";
}
"The dial must be set to a number between 0 and 45.";
],
has static;

-----
Adam Cadre, Sammamish, WA
web site: http://adamcadre.ac
novel: http://www.amazon.com/exec/obidos/ASIN/0060195584/adamcadreac

Carl Muckenhoupt

unread,
Sep 1, 2000, 12:37:20 AM9/1/00
to
I haven't tried this, but: It seems like this is a job
for "Extend...first".

Extend 'set' first * noun 'to' number -> SetToNumber;

The word "first" tells the parser to evaluate this rule before it tries
any of the other rules for this verb. Thus, you'll parse numbers as
numbers (and send them to and everything else as "special".

Note that that if you use the grammar line above, you'll have to define
the default response through a routine "SetToNumberSub".


Sent via Deja.com http://www.deja.com/
Before you buy.

Sam Roberts

unread,
Sep 1, 2000, 11:46:35 AM9/1/00
to
I don't think that will do what I want, since the existing Set rule in the
library grammer will still be in place for the dial object, so if the user
types "Set to fred". I think the first rule will not match (second not a
number), and the parser will go on to the next rule (the standard noun
'to' special rule) and call my dial with the SetTo action anyway?
0 new messages