#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2013
    Posts
    3
    Rep Power
    0

    Posting to different text documents that each add a suffix to the posted content


    Hi all,

    Im trying to create a program that allows me to enter a name into a text field and submit the name into 3 seperate pre-made text files named doc1, doc2 and doc3.

    For example: If I were to enter dazbrad into the programme and press submit, doc1, doc2 and doc3 (pre-made text files) would each recieve and add that name to its content.

    Furthermore, I would like each pre-made text document to add a seperate suffux to each name that is added. For example, after submitting the name 'dazbrad', doc1, doc2 and doc3 should look as follows:

    Doc1 contains - dazbrad1
    Doc2 contains - dazbrad2
    Doc3 contains - dazbrad3

    To further complicate matters, I would like to then go on to add other names at a later point. For example, if I were to later add the name 'brad' to the programme and press submit, the result should be as follows:

    Doc1 now contains - dazbrad1 and brad1.
    Doc2 now contains - dazbrad2 and brad2.
    Doc3 now contains- dazbrad3 and brad3.

    If somebody could enlighten me in overcoming this issue, even pointing me in the right direction. Any help would be greatly appreciated. Many thanks in advance.
  2. #2
  3. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2013
    Posts
    2
    Rep Power
    0

    Just learning, but...


    Originally Posted by dazbrad
    Hi all,

    Im trying to create a program that allows me to enter a name into a text field and submit the name into 3 seperate pre-made text files named doc1, doc2 and doc3.

    For example: If I were to enter dazbrad into the programme and press submit, doc1, doc2 and doc3 (pre-made text files) would each recieve and add that name to its content.

    Furthermore, I would like each pre-made text document to add a seperate suffux to each name that is added. For example, after submitting the name 'dazbrad', doc1, doc2 and doc3 should look as follows:

    Doc1 contains - dazbrad1
    Doc2 contains - dazbrad2
    Doc3 contains - dazbrad3

    To further complicate matters, I would like to then go on to add other names at a later point. For example, if I were to later add the name 'brad' to the programme and press submit, the result should be as follows:

    Doc1 now contains - dazbrad1 and brad1.
    Doc2 now contains - dazbrad2 and brad2.
    Doc3 now contains- dazbrad3 and brad3.

    If somebody could enlighten me in overcoming this issue, even pointing me in the right direction. Any help would be greatly appreciated. Many thanks in advance.
    I'm just starting out, learning Python. Sounds like you need to use a string method. Should be pretty simple to program.
  4. #3
  5. Banned ;)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Nov 2001
    Location
    Woodland Hills, Los Angeles County, California, USA
    Posts
    9,643
    Rep Power
    4247
    I actually wrote something like this in python a while back (I use it to add licenses to my source code files). You'll probably need to modify it for your purposes though. Let me know if you're interested.
    Up the Irons
    What Would Jimi Do? Smash amps. Burn guitar. Take the groupies home.
    "Death Before Dishonour, my Friends!!" - Bruce D ickinson, Iron Maiden Aug 20, 2005 @ OzzFest
    Down with Sharon Osbourne

    "I wouldn't hire a butcher to fix my car. I also wouldn't hire a marketing firm to build my website." - Nilpo
  6. #4
  7. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2013
    Posts
    3
    Rep Power
    0
    Thanks guys,

    Python is not a language I have ever worked with, however, it appears that you both agree that its a good way to go. I will look into it and see what I can learn.

    As for Scorpians4ever, that would be brilliant if I could have an example inwhich to learn from. Not sure if il be able to modify it for my purpose, but il give it a damn good go. Thankss again guys, I look forward to hearing from you soon.
  8. #5
  9. Banned ;)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Nov 2001
    Location
    Woodland Hills, Los Angeles County, California, USA
    Posts
    9,643
    Rep Power
    4247
    dazbrad, I sent you a private message with the link to the code and some documentation.

    The code was written a long time ago for python 2.xx. It may need minor syntax modifications to work with python 3.xx. If you download the python 2.xx interpreter from python.org, it should run as is.

    You'll also need to make some minor changes for it to search for .txt files (right now it only looks for files ending in .c, .h, .php, .inc, .pl, .pm, .cpp, .rb, .java and .py )

    Happy hackin!
    Last edited by Scorpions4ever; May 12th, 2013 at 04:48 PM.
    Up the Irons
    What Would Jimi Do? Smash amps. Burn guitar. Take the groupies home.
    "Death Before Dishonour, my Friends!!" - Bruce D ickinson, Iron Maiden Aug 20, 2005 @ OzzFest
    Down with Sharon Osbourne

    "I wouldn't hire a butcher to fix my car. I also wouldn't hire a marketing firm to build my website." - Nilpo

IMN logo majestic logo threadwatch logo seochat tools logo