Gaming I need a batch file/program

  • Thread starter Thread starter Ace
  • Start date Start date
  • Views Views 1,671
  • Replies Replies 5

Ace

GBATemp's Patrick Bateman
Member
Joined
Apr 8, 2009
Messages
1,034
Reaction score
185
Trophies
1
Age
31
Location
Manhattan
Website
goo.gl
XP
568
Country
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
 
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....
 
Ü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
 
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
 

Site & Scene News

Popular threads in this forum