Is there a fast way to put words in quotes?

Hi I was wondering if someone knows a faster way to put words between quotes.

In my project I'm creating a random word generator on a LCD display. Now I have to put a lot of words in my code to give the Arduino to chose from like this:

char *woord[] = {"Kroket ", "Vlinder ", "Been ", "Taart ", "oog ", "banaan ", "kussen ", "vogel ", "laars ", "snor "};

Now I have a whole list of words but (over 3000 words) but the words are now between quotes and a space after each word.

Does anyone knows a way to do this fast?

If I'm not clear in my question, please ask my English is not great.

bguchte:
Hi I was wondering if someone knows a faster way to put words between quotes.

In my project I’m creating a random word generator on a LCD display. Now I have to put a lot of words in my code to give the Arduino to chose from like this:

char *woord[] = {"Kroket ", "Vlinder ", "Been ", "Taart ", "oog ", "banaan ", "kussen ", "vogel ", "laars ", "snor "};

Now I have a whole list of words but (over 3000 words) but the words are now between quotes and a space after each word.

3000 char pointers and 3000 nullterminated strings in an Arduino program?
Which board? How many RAM?`

An Arduino UNO board just has 2048 bytes of RAM (2KB), there is no way to store that many words in the RAM of an Atmega328.

For storing big lists of words you better use a mass storage device like SD card and store all words in one file as you like it comma delited or one word per line! Then read in the words you need from file.

Just to answer the original question regardless of memory usage.

Use an editor like Notepad++

Type all the words on a new line
Record a macro to insert a double quote at the beginning of the line and execute that macro as often as needed
Record a macro to append a space and a double quote and a comma at the end of the line and execute that macro as often as needed

If you have something like MS word write a macro for that to do the same
You can also use MS Excel; type in the words (including space) and save as CSV (can't gave exact result, might need a modifcation on the procedure).

Be aware that

char *woord[] = {
"Kroket ",
"Vlinder ",
"Been ",
"Taart ",
...
...
};

is also valid. So in the IDE you can type all words on a new line, next insert a double quote at the beginning of each line, add a space/double quote/comma at the end of the first line, copy that and next paste it.

PS Krijg ik nu taart?

On top of all the above, why a space at the end of each word???

And a tip if you plan to store it on a SD card. Instead of just delimiting the words with a new line (which is slow to search) I would try to use fixed width spacing between the words. Looking for the 100th word when they are newline (or comma, doesn't change a thing) means you have to read all until you found the 99th newline. With fixed length you can just jump to 100 x fixedWidth.

Mm, taart, kroket... Ik mis het bier! Immers als bijna tijd voor de VriMiBo 0:-)

jurs:
3000 char pointers and 3000 nullterminated strings in an Arduino program?
Which board? How many RAM?`

An Arduino UNO board just has 2048 bytes of RAM (2KB), there is no way to store that many words in the RAM of an Atmega328.

For storing big lists of words you better use a mass storage device like SD card and store all words in one file as you like it comma delited or one word per line! Then read in the words you need from file.

Thanks, this is my first Arduino project and I didn't think of that... hmmm. Maybe I just do like 100 words if that's possible for now (as a concept).. Thanks for the heads up!

" is ASCII 34

If you Serial.write( 34 ); that should do, it might have to be ( char( 34 )) though.

ASCII table is your friend!

Uno has 32KB for program and data.
You can use PROGMEM to store your data or you can use the F( ) macro in print statements, example:

switch (whichWoord ) // this is the index
{
case 0 :
Serial.print( F( "Kroket" )); // stored in flash memory, printed from flash memory
break;
case 1 :
Serial.print( F( "Vlinder" )); // stored in flash memory, printed from flash memory
break;
// etc
}

The PROGMEM use can make smaller code, there is a way to print that directly but I forget.

sterretje:
Just to answer the original question regardless of memory usage.

Use an editor like Notepad++

Type all the words on a new line
Record a macro to insert a double quote at the beginning of the line and execute that macro as often as needed
Record a macro to append a space and a double quote and a comma at the end of the line and execute that macro as often as needed

If you have something like MS word write a macro for that to do the same
You can also use MS Excel; type in the words (including space) and save as CSV (can't gave exact result, might need a modifcation on the procedure).

Be aware that

char *woord[] = {

"Kroket ",
"Vlinder ",
"Been ",
"Taart ",
...
...
};



is also valid. So in the IDE you can type all words on a new line, next insert a double quote at the beginning of each line, add a space/double quote/comma at the end of the first line, copy that and next paste it.


PS Krijg ik nu taart?

Thanks! that works. this saves me a lot of time. although I can't use as much words as I like. But still thanks!

PS. 1 digitale taart voor jou!