Log In  

Cart #55898 | 2018-08-30 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA

I needed to do some "Mad Libs" user-controlled string substitution for a project, so I developed a system that allows both coloring and replacement per word. It's not verified to be robust in all scenarios: long words aren't broken up and substitutions containing multiple words will be treated like a single big word.

P#55899 2018-08-30 19:38 ( Edited 2018-08-31 17:05)

You might find these libraries I wrote some years ago helpful for your MadLibs, TripleFox.



If you don't plan to use the QWERTY keyboard for your MadLibs, you can use this virtual keyboard I put together:


Something I'm not doing in any of my routines, TF, is a check for long character words and breaking them apart according to their pattern of vowels and consonants.

"...though not estab-"
next line
"lished, it was readily known to be the case."

In fact, you could probably automatically determine where to divide a long word based on the number of characters in it, divide by two, and backtrack to the first consonant or vowel, depending upon how many are intermittently linked.

Except for "e." E doesn't look very good as the last character for most splits.

"ente-rprise" no
"enter-prise" yes, double consonant division

"com-puter" (double consonant division)
"calcu-lation" (standard vowel division)
"repres-entation" (skip "E," subtract, one, get next division marker, "s", vowel, consonant, vowel)

Hope This Helps !

P#55915 2018-08-30 22:03 ( Edited 2018-08-31 02:04)

Hmm, yeah, a way to break long lines would be pretty useful to me actually! Maybe I should look into it.

P#55927 2018-08-31 04:30 ( Edited 2018-08-31 08:30)

Post it when done, Tobiasvl. Would definitely like to see it !

P#55940 2018-08-31 13:05 ( Edited 2018-08-31 17:05)

[Please log in to post a comment]

Follow Lexaloffle:          
Generated 2024-04-22 11:55:42 | 0.011s | Q:20