Results 1 to 2 of 2

Thread: My (improved) Little Token Replacement Engine

  1. #1

    Thread Starter
    PowerPoster cafeenman's Avatar
    Join Date
    Mar 2002
    Location
    Florida
    Posts
    2,819

    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

  2. #2

    Thread Starter
    PowerPoster cafeenman's Avatar
    Join Date
    Mar 2002
    Location
    Florida
    Posts
    2,819

    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
  •  



Click Here to Expand Forum to Full Width