|
-
Dec 30th, 2024, 02:40 PM
#1
Thread Starter
PowerPoster
My (improved) Little Token Replacement Engine
I've had this code for a long time and it's worked very well for me.
But I wanted a simple way for the token to tell the engine how to "Case" the text.
E.g.
Proper, Upper, Lower-Case and no change (inserts replacement as it is in the look-up list or table or whatever it is you're using).
The attached code is what I landed on.
I'm super-pleased with it.
Thus:
(The word in the Look-up is entered as "bIg")
<Adjective> = "Big"
<adjective> = "big"
<ADJECTIVE> = "BIG"
<aDjective> = "bIg" ' Any random capitalization works as long as it doesn't meet the criteria for lower, upper and proper cases.
Now you can easily create your own Mad Libs.
See comments in the Project.
Token Engine (Mad Libs).zip
-
Dec 30th, 2024, 02:48 PM
#2
Thread Starter
PowerPoster
Re: My (improved) Little Token Replacement Engine
PS. The reason for looping through and changing tokens one at a time (even tokens that are the same) is so the replacement is different.
You could use Replace instead but if you had "<adjective>" multiple times in the same text sent to the engine, then it would replace them all with the same word.
If that's what you want then you can easily change the sub to just use Replace instead of looping through the text.
The way I've done it, each instance of a token in the same text is randomly selected.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|