I need a batch file/program

Discussion in 'Computer Games and General Discussion' started by Ace, Aug 16, 2010.

Aug 16, 2010

I need a batch file/program by Ace at 7:59 PM (857 Views / 0 Likes) 5 replies

  1. Ace
    OP

    Member Ace GBATemp's Patrick Bateman

    Joined:
    Apr 8, 2009
    Messages:
    1,035
    Location:
    Manhattan
    Country:
    Sweden
    Hello, Tempers.

    I'd like to ask if someone could very please help me and my cousin with converting a text file. He is coding a level for StarCraft 2 at the moment, and he needs some help on formatting text files quickly, hopefully in an automated way.
    What my cousin has is a text file with a collection of random words like so:
    CODEcat
    dog
    chill
    wet
    dry
    cold
    sausage
    hair
    thick
    And so forth...
    He wants a way to convert every row into something like this:
    CODElv_setup_intiger = (lv_setup_intiger + 1);
    gv_words[lv_setup_intiger] = "cat";
    lv_setup_intiger = (lv_setup_intiger + 1);
    gv_words[lv_setup_intiger] = "dog";
    lv_setup_intiger = (lv_setup_intiger + 1);
    gv_words[lv_setup_intiger] = "chill";
    lv_setup_intiger = (lv_setup_intiger + 1);
    gv_words[lv_setup_intiger] = "wet";
    lv_setup_intiger = (lv_setup_intiger + 1);
    gv_words[lv_setup_intiger] = "dry";
    lv_setup_intiger = (lv_setup_intiger + 1);
    gv_words[lv_setup_intiger] = "cold";
    lv_setup_intiger = (lv_setup_intiger + 1);
    gv_words[lv_setup_intiger] = "sausage";
    lv_setup_intiger = (lv_setup_intiger + 1);
    gv_words[lv_setup_intiger] = "hair";
    lv_setup_intiger = (lv_setup_intiger + 1);
    gv_words[lv_setup_intiger] = "thick";

    And so forth....

    Essentially, he wants to take the first word of each row of the text file, and place it within the brackets of the second row of the code, following "gv_words[lv_setup_intiger] ="

    I need to know if there's any kind of program or batch file that could be made to generate or overwrite a text file to do something like this. Any help at all can be credited to the person who wants and who helps. If you cannot help, you can point to websites that can help, as it would very helpful.

    The text file consists of somewhere between 100 & 9000 words, so converting it manually would be a big hassle.

    Thanks in advance,

    Ace Faith
     
  2. tk_saturn

    Member tk_saturn GBAtemp Psycho!

    Joined:
    Jan 26, 2010
    Messages:
    3,327
    Country:
    United Kingdom
    It would be simple to do. If someone else doesn't do it first, i'll help you later. I'm busy for now.

    edit:

    see if this works http://www.themolehole.eclipse.co.uk/sc2batch.exe save to your PC and then drag your text file onto it.


    from

    Code:
    cat
    dog
    chill
    wet
    dry
    cold
    sausage
    hair
    thick
    you get

    Code:
    lv_setup_intiger = (lv_setup_intiger + 1);ÂÂ
    ÂÂÂÂgv_words[lv_setup_intiger] = "cat";ÂÂ
    lv_setup_intiger = (lv_setup_intiger + 1);ÂÂ
    ÂÂÂÂgv_words[lv_setup_intiger] = "dog";ÂÂ
    lv_setup_intiger = (lv_setup_intiger + 1);ÂÂ
    ÂÂÂÂgv_words[lv_setup_intiger] = "chill";ÂÂ
    lv_setup_intiger = (lv_setup_intiger + 1);ÂÂ
    ÂÂÂÂgv_words[lv_setup_intiger] = "wet";ÂÂ
    lv_setup_intiger = (lv_setup_intiger + 1);ÂÂ
    ÂÂÂÂgv_words[lv_setup_intiger] = "dry";ÂÂ
    lv_setup_intiger = (lv_setup_intiger + 1);ÂÂ
    ÂÂÂÂgv_words[lv_setup_intiger] = "cold";ÂÂ
    lv_setup_intiger = (lv_setup_intiger + 1);ÂÂ
    ÂÂÂÂgv_words[lv_setup_intiger] = "sausage";ÂÂ
    lv_setup_intiger = (lv_setup_intiger + 1);ÂÂ
    ÂÂÂÂgv_words[lv_setup_intiger] = "hair";ÂÂ
    lv_setup_intiger = (lv_setup_intiger + 1);ÂÂ
    ÂÂÂÂgv_words[lv_setup_intiger] = "thick";
    using the file linked above.
    It's lv_setup_intiger as in your post, however I would have assumed it to be lv_setup_integer instead....
     
  3. Ace
    OP

    Member Ace GBATemp's Patrick Bateman

    Joined:
    Apr 8, 2009
    Messages:
    1,035
    Location:
    Manhattan
    Country:
    Sweden
    deleted
    disregard this post, see the next one.
     
  4. XFlak

    Member XFlak Wiitired but still kicking

    Joined:
    Sep 12, 2009
    Messages:
    9,122
    Location:
    Ontario
    Country:
    Canada
    I could easily do this in excel in under 2 minutes (I do a lot of batch programming and I find excel useful for repetitive code, then just do a copy and paste into the batch file)
     
  5. Ace
    OP

    Member Ace GBATemp's Patrick Bateman

    Joined:
    Apr 8, 2009
    Messages:
    1,035
    Location:
    Manhattan
    Country:
    Sweden
    ÜBER EDIT:

    It would seem my cousin has updated the system he used for his SC2 Custom Campaign, without warning me. I need the same function as the last one, but with thie text file, presented so:
    CODEhello
    there
    mate

    Converted into this:
    CODEgv_wordList[0] = "hello";
    gv_wordList[1] = "there"
    gv_wordList[2] = "mate"

    Where "hello", "there" and "mate" are separated by a new line in the text file. Take note that each number following "gv_wordList" should always be increased by one for each row, starting from zero.

    And, if possible, could it be a batch file instead of an executable, so that any improvements made to the system can be ironed out without asking for a new program every time?

    Thank you very much, tk_saturn. My cousin will deliver his promise of crediting, if it's worth anything as gratitude.

    And like my first post, I will ask him to credit you for any help you can present in this thread.

    Peace and love, and sorry for being a bit of a hassle with this,

    Ace Faith
     
  6. Naico

    Newcomer Naico Member

    Joined:
    Mar 6, 2005
    Messages:
    12
    Country:
    Finland
    Here is a batch program for you; the code should be pretty simple to understand. I've quickly tested it and it should work as requested above.

    Just make a new text file, copy & paste the code below and rename the file extension to .bat

    Code:
    @SET off
    SET sc2file_open=sc2.txt
    SET sc2file_result=gv_wordList.txt
    SET index=0
    @ECHO off
    SETLOCAL enabledelayedexpansion
    ECHO.
    ECHO ====================
    ECHO StarCraft 2 Batch
    ECHO ====================
    ECHO.
    ECHO Doing stuff ...
    ECHO.
    TYPE NUL > %sc2file_result%
    FOR /F %%i IN (%sc2file_open%) DO @ECHO gv_wordList[!index!] = "%%i"; >> %sc2file_result% && SET /A index+=1
    ECHO Done.
    ECHO.
    PAUSE
    @ECHO on
     

Share This Page