# Converting a Snippet to Number...or a String to Number

So I have a table that has a number column that I need to write an entry in.

However, the entry comes from a player’s command.

``````Now the Damage entry is the player's command;
``````

Of course, i’m met with the dreaded data mismatch - Snippet and Number…

So what’s the best way of writing a number entry to a table that’s been typed via player command?

I could change the data type in the table to string but then i would need to convert string to number when i grab the number from the table later.

In essence, I need the reverse of:

``````the substituted form of "[number]";
``````

I’ve tried:

``````Now Damage is the number understood;
``````

That just returns a 0.
Obviously i’m not quite getting how number understood works but im guessing thats where my solution lies.

1 Like

Are you trying to allow the player to enter a number?

Take a look at chapter 17.9, and then example 304 “Down in Oodville” in that chapter. That shows how to accept a player command which is a number. The number winds up in `the number understood` so then you can do whatever you want with it.

I actually ended up using your code from a previous forum topic.

``````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);
];
-).
``````

Then I used this in my script:

``````let N be the numeric equivalent of the player's command;
``````

The player input isn’t from a custom action; it’s from a “After reading a command when the command prompt is”