Discuss Scratch

scratchvirtuoso
Scratcher
6 posts

How Do I Convert Words To Numbers Easily?

Hey scratchers,
I'm trying to make a program where a sprite asks the user a question, and they then answer and that answer is converted into numbers.
I've tried many times, but I can't really find the answer for a simple and fast word-to-number converter.
If you do happen to have the answer, please tell me and I will thank you. (I would like an answer as soon as possible)

Thanks everyone,

scratchvirtuoso
hello2248
Scratcher
100+ posts

How Do I Convert Words To Numbers Easily?

defineencodestringrun without screen refreshsetcharacterstoabcdefghijklmnopqrstuvwxyz,./?;':"-=_+1234567890!@#$%^&*`~//or what ever characterssetindexto1repeatlengthofstringsetCindexto1repeatuntilletterCindexofcharacters=letterindexofstringchangeCindexby1iflengthofCindex<2thensetCindextojoin0Cindexchangeindexby1setoutputtojoinoutputcindex
try that, it should work

Last edited by hello2248 (Aug. 22, 2015 18:18:24)

deck26
Scratcher
1000+ posts

How Do I Convert Words To Numbers Easily?

Give an example of the user responses you might get. If the response is all numeric you can just treat it as a number in a calculation and Scratch will convert it so we need to know what you mean.
daemys
Scratcher
100+ posts

How Do I Convert Words To Numbers Easily?

If a string contains only numbers it's a number as well, all the mathematical features are applicable for such strings.

whenclickedaskgive me a numberandwaitsetnumbertoanswerchangenumberby1changenumberby-1ifnotnumber=answerthensayIt's not a numberfor3secselsesayYes, it's a number!!!for3secs

Last edited by daemys (Aug. 22, 2015 19:10:22)

scratchvirtuoso
Scratcher
6 posts

How Do I Convert Words To Numbers Easily?

Thanks everyone for the responses!
And whoever's string I use, I will definitely give credit.
Thanks!
scratchvirtuoso
Scratcher
6 posts

How Do I Convert Words To Numbers Easily?

Here are a few user example responses:

1. Why did the Chicken cross the road?

2. Hello there!

3. What's your name?

deck26
Scratcher
1000+ posts

How Do I Convert Words To Numbers Easily?

scratchvirtuoso wrote:

Here are a few user example responses:

1. Why did the Chicken cross the road?

2. Hello there!

3. What's your name?

Surely those are questions rather than responses!

So what do you mean by converting the answer to numbers? Are you talking about encoding - as in the Encoding section here http://wiki.scratch.mit.edu/wiki/Global_High_Scores

scratchvirtuoso
Scratcher
6 posts

How Do I Convert Words To Numbers Easily?

Don't worry, I've already got everything settled. Thanks everyone, though.
scratchvirtuoso
Scratcher
6 posts

How Do I Convert Words To Numbers Easily?

Also, anyone out there, do you have the code to converting numbers to words easily?
I know, I know. I also need the vice-versa code, though, too.
daemys
Scratcher
100+ posts

How Do I Convert Words To Numbers Easily?

What you need is called ENCODING and DECODING. Converting numbers to words is a different operation.
deck26
Scratcher
1000+ posts

How Do I Convert Words To Numbers Easily?

The decoding has to match the encoding method so it's hard to advise on decoding without knowing your encoding method.
scratchvirtuoso
Scratcher
6 posts

How Do I Convert Words To Numbers Easily?

Ok, thanks.
LegendaryLion1005
Scratcher
2 posts

How Do I Convert Words To Numbers Easily?

I am trying to make something in which the computer asks the user to choose a number and then the computer says the number in words.Is there any simple way to do this?
joinpleasehelp
deck26
Scratcher
1000+ posts

How Do I Convert Words To Numbers Easily?

LegendaryLion1005 wrote:

I am trying to make something in which the computer asks the user to choose a number and then the computer says the number in words.Is there any simple way to do this?
joinpleasehelp
You should really start your own topic. The best answer for a small enough range (eg 1 to 20) would be a list containing the word version so you can just

sayitemnumberofwords

Last edited by deck26 (Nov. 17, 2015 20:55:06)

Powered by DjangoBB