converting snippets to numnbers

I feel like I might be missing something obvious here, but is there a way to convert a snippet to an equivalent number? Like, if the player types ASK BOB ABOUT 204, can I do something like:

let X be the number equivalent of the topic understood;
let Y be X plus 10;
say "'Not quite,' says Bob. 'I was looking for something more like [Y].'"

If you match the player’s command against “[number]” the result gets stored in “the number understood.” So in theory (I think) you should be able to do this:

Instead of asking Alice about when the topic understood matches "[number]": say "Alice says, 'Not quite. I was thinking more of [number understood plus 10].'"

However, this can produce weird results. I tried this:

[code]Lab is a room.
Alice The Math Wizard is a woman in Lab. Bob is a man in Lab.

Instead of asking Alice about when the topic understood matches “[number]”:
say “Alice says, ‘Not quite. I was thinking more of [number understood plus 10].’”

Instead of asking someone about:
say “[The noun] says ‘[Topic understood], huh?’”[/code]

EDITED: changed the sample code to reflect what produces the error.

And it produces a runtime error when I try “ASK ALICE ABOUT 5 ROCKS.” I guess I’ll report it and see if I get told it’s supposed to work that way.

OK, zarf has confirmed that there are deep code reasons why “the number understood” overwrites “the topic understood.” But I’ve tried a shallow dive into parser internals to fix that, like this:

[code]Lab is a room.
Alice is a woman in Lab.

Parsed-number is a number that varies. The parsed-number variable translates into I6 as “parsed_number”.

Temporary-parsed-number is a number that varies.

To cache the topic understood: now temporary-parsed-number is parsed-number.

To restore the topic understood: now parsed-number is temporary-parsed-number.

Asking it numerically about is an action applying to one thing and one number.

Before asking someone about:
cache the topic understood;
if the topic understood matches “[number]”:
try asking the noun numerically about the number understood instead;
otherwise:
restore the topic understood.

Instead of asking someone numerically about:
say “[The noun] says, ‘Go higher! Try [the number understood plus 10]!’”

Instead of asking someone about:
say “[The noun] says ‘[Topic understood], huh?’”

test me with “ask Alice about 5/ask alice about rocks/ask alice about 5 rocks”.[/code]

…an easier thing to do would be to find some code that someone has probably already written to do things like translate the text “256” into the number 256. But this would miss out on spelled-out numbers like “two hundred fifty-six,” which the code I’ve written should catch.

On the other hand, you probably shouldn’t use any code I write that involves I6 hacks without running it by someone who knows what they’re doing better than I.

Tidier way of doing this, though limited in range:

To decide what number is the numeric equivalent of (P - snippet): (- SnippetToNumber({P}) -).

Include (-
! This only recognizes zero and positive numbers. It accepts English words "zero" to "thirty" and digit forms up to 10000. If the snippet is not a number, or contains more than one word, this returns -1000.
[SnippetToNumber snip   snippos sniplen;
	snippos = snip/100;
	sniplen = snip%100;
	if (sniplen ~= 1)
		return -1000;
	return TryNumber(snippos);
];
-).

[Example code:]
Check answering Steve that:
	let N be the numeric equivalent of the topic understood;
	if N is -1000:
		instead say "Topic: '[topic understood]' is not a number.";
	else:
		instead say "Topic: '[topic understood]' is [N].";