Home World Forum
Stars! AutoHost web forums

Jump to Stars! AutoHost


 
 
Home » Stars! 2.6/7 » The Bar » Making a backup of your Stars! turns
Making a backup of your Stars! turns Sun, 16 November 2003 18:53 Go to next message
Micha

 

Messages: 2342
Registered: November 2002
Location: Belgium GMT +1
Some time ago I went looking for an easier way to keep backup of all my Stars! turns by using a batch file. Since I'm Lazy (at least that's my race's name in the Penta game Grin ) I first went to look at the newsgroup so I wouldn't invent the hot water again (or was that the wheel?).

Recently it came up in the "Questions about Stars! AutoHost" part of the forum, so I figured I would post what I found.
The newsgroup post can be found here.

Quote:

Van:Andrew (andrewt@nildram.dot.co.dot.uk.invalid)
Onderwerp:Re: New Player Q: Keeping track of a universe
Discussies:rec.games.computer.stars
Datum:2003-05-09 11:19:48 PST

I got fed up with the details of copying my files, I wrote a simple
batch file.

if "%1" == "" goto end
md "%1"
for %%e in (xy x3 m3 h3) do copy "gamename.%%e" "%1"
:end

Right at the beginning of the game I change gamename and the numbers to suit the current game

Save this as save.bat into your game directory. Right-click and choose properties. Edit the command line by adding a question mark, so it reads SAVE.BAT ?

The question mark means you'll get asked for a parameter when you
double-click the batch file. Type in the year number and hit "OK".
That number gets substituted in place of %1. The batch file takes care of creating the new directory and copying the files.

The result: you build up a folder for each year. The multiple
redundant copies of gamename.xy mean it's easy to open up earlier
turns to see what the situation was. In a long game you'll want to delete or zip the earliest turns.



But winxp does not let you use the "?" so you don't get prompted for the year. Sad
That's why I only use it for one game, it's the "default" (the first that's get shown, because it was the last you used) for the "Run" command (is it called that way in English win versions?) in the Start menu, like:
"C:\stars\penta\save.bat 2458"
So each time I want to run it I can quickly change the game year (most of the times only the last digit Grin )... Using it for more than one game would require to select the correct line for the other game and that takes as much time as making the backup manually ...

Anyone care to share how they do it or how to improve the method/batch file above?

mch

Report message to a moderator

Re: Making a backup of your Stars! turns Mon, 17 November 2003 01:12 Go to previous messageGo to next message
Captain Maim is currently offline Captain Maim

 
Lt. Junior Grade

Messages: 492
Registered: March 2003
Location: USA, Mesa, Arizona

Hmm.. Hey I've got something that could help this work, you wouldn't even need to put in the year... Though it would require an external exec to read the year off in hex...
However,to do it purely with batch in XP it would probably have to be like this:

@echo off
echo What year is this file?
set /p year=
if "%year%" == "" goto end
md "%year%"
for %%e in (xy x3 m3 h3) do copy gamename.%%e %year%
:end


That should work out for ya... If you wanted to run it every year, it's possible to make it so it "remembers" and can increment for you.. (XP only) Like this:


@echo off

if exist year.bat goto skip

echo What year is this file?
set /p year=
echo set year=%year% > year.bat

:skip
call year.bat
if "%year%" == "" goto end
md "%year%"
for %%e in (xy x3 m3 h3) do copy gamename.%%e %year%
set /a year=%year% +1
echo set year=%year% > year.bat
:end


And that should solve even your input work, assuming you run it every year. (and of course alter the number "3" to your race, and "gamename" to the game name... and you should be JUST FINE!)

If you don't wanna edit the batch file, to add game and race# in use this one:

@echo off

if exist year.bat goto skip

echo What year is this file?
set /p year=
echo Game name?
set /p game=
echo Race number?
set /p race=

echo set year=%year% > year.bat
echo set game=%game%>> year.bat
echo set race=%race%>> year.bat

:skip
call year.bat
if "%year%" == "" goto end
md "%year%"
for %%e in (xy x%race% m%race% h%race%) do copy %game%.%%e %year%
set /a year=%year% +1
echo set year=%year%> year.bat
echo set game=%game%>> year.bat
echo set race=%race% >> year.bat
:end


[Updated on: Mon, 17 November 2003 01:38]




Rule 1: "Pillage, THEN burn!"

Report message to a moderator

Re: Making a backup of your Stars! turns Mon, 17 November 2003 03:35 Go to previous messageGo to next message
gible

 
Commander

Messages: 1343
Registered: November 2002
Location: Wellington, New Zealand

There is an exec called staryear.exe that is part of the XChange script that is(was) the basis of AutoHost.
With its /q switch it outputs only the year.
Damned if I can figure out how to make that help tho...haven't really done batch programming in years.


On a related note....does anyone know of an email client that will execute programs within the filter system? Besides Eudora(which is what I'm using...but my batch file only keeps one year backups - it also moves the received file from my attachments dir to my game dir)


[Updated on: Mon, 17 November 2003 03:41]

Report message to a moderator

Re: Making a backup of your Stars! turns Mon, 17 November 2003 15:20 Go to previous messageGo to next message
Captain Maim is currently offline Captain Maim

 
Lt. Junior Grade

Messages: 492
Registered: March 2003
Location: USA, Mesa, Arizona

Yeah I know how to make that one work (not the email thing). Let me see here.... Batch is my only skill at "programming" Smile So now to incorperate the use of staryear.exe.... Automation here we come!

Now assuming you put "Staryear.exe" into the same directory as this batch file... hmmm.... This isn't going to be enough... To convert the output to a useable command I'll need 1 other program. I'll have to post this... But it's really tiny.. (I could do it just with this other program, but it would only work well upto year 2555 then it would start having problems.) It might be possible to do this with a "for" command, but I don't think "for" can weed out those pesky hard returns. Anyway, here we go:

@echo off

if exist player.bat goto skip

echo Game name?
set /p game=
echo Race number?
set /p race=
echo set game=%game%> player.bat
echo set race=%race% >> player.bat

:skip
call player.bat
echo set year=>!.bat
staryear %game%.m%race% /q >>!.bat
poke !.bat 0x9 0xd
poke !.bat 0xa 0xd
call !.bat

md "%year%"
for %%e in (xy x%race% m%race% h%race%) do copy %game%.%%e "%year%"


:end
del !.bat



There's only 1 problem with this, it takes 2 programs to make work.
You can get "poke.exe" out of this file:
http://www.pirates.retreat.btinternet.co.uk/StarNameChanger. zip
And "staryear.exe" out of this file:
ftp://library.southern.edu/xchange.zip

Copy the batch file I have above to *.bat (* being whatever you want) and then extract Staryear.exe and Poke.exe from the 2 files, put them in the same directory as your batch file and VWALLA! Your all ready to go! It'll read the year, make the directories, all you have to do is say what game and what race.. ONCE! Neat eh? I might also be able to whip up one to do multiple players.. maybe.. or you can just edit it, add a few more lines.. whatever.


[Updated on: Mon, 17 November 2003 15:26]




Rule 1: "Pillage, THEN burn!"

Report message to a moderator

Re: Making a backup of your Stars! turns Tue, 18 November 2003 03:10 Go to previous messageGo to next message
zoid is currently offline zoid

 
Ensign

Messages: 348
Registered: December 2002
Location: Murray, KY - USA
ROFL

All of this sounds easier than doing it manually? Man, I don't get it!

Why can't someone just say...

"Sure dude, there's this nifty little utility you can download from Superduperstarsthingies.com that'll do all of that for ya with a mouse-click; it's only a 69kb file so it's a cinch to download, nothing to set up, and you'll love it."
Twisted Evil



I'M NOT AN EXPERT AND I'M OFTEN PROVEN WRONG. TAKE THAT INTO CONSIDERATION WHEN YOU READ MY POSTS.
Math? Confused Ummm, sure! Nod I do FREESTYLE math.

Report message to a moderator

Re: Making a backup of your Stars! turns Tue, 18 November 2003 03:30 Go to previous messageGo to next message
gible

 
Commander

Messages: 1343
Registered: November 2002
Location: Wellington, New Zealand

awww diddums.... Laughing
The point is you only have to do it once Razz

Tho I did start thinking about writing a little backup proggie when I read this thread...can't be bothered atm tho.

Report message to a moderator

Re: Making a backup of your Stars! turns Tue, 18 November 2003 12:15 Go to previous messageGo to next message
Micha

 

Messages: 2342
Registered: November 2002
Location: Belgium GMT +1
Thanks Captain! This works great! I edited the batch file with correct game name and player numbers (team game so backupping the files of all 3 races in the team) and with the creation of the year.bat I now just click the save.bat and it creates a dir with the new year and copies the files all by itself, just like I wanted too!

Really gratefull for your help!! Very Happy

mch

Report message to a moderator

Re: Making a backup of your Stars! turns Tue, 18 November 2003 16:51 Go to previous messageGo to next message
Captain Maim is currently offline Captain Maim

 
Lt. Junior Grade

Messages: 492
Registered: March 2003
Location: USA, Mesa, Arizona

My pleasure.


Rule 1: "Pillage, THEN burn!"

Report message to a moderator

Re: Making a backup of your Stars! turns Wed, 17 December 2003 18:10 Go to previous message
Captain Maim is currently offline Captain Maim

 
Lt. Junior Grade

Messages: 492
Registered: March 2003
Location: USA, Mesa, Arizona

Hey I just wrote up 1 last batch file here. It requires Poke.exe but so does all my other stars utilities Very Happy

Improvements: It's faster than the one I had that used Staryear.exe (which used to hang on me.) It can also calculate the year on it's own accurately! WOOT! All you need to do is copy this text into a file with a .bat at the end, and get poke! from my star namer program at Pirates retreat. Run it, adjust it. Whatever. I've also got one that'll save you time when opening your ally's turn files.. You edit in the password and then just drag drop to load the turn! (I didn't include that one here)

@echo off

if exist zgame.bat goto skip

echo Game name?
set /p game=
echo Race number?
set /p race=
echo set game=%game%> zgame.bat
echo set race=%race% >> zgame.bat

:skip
call zgame.bat
echo set year=>!.bat
::staryear %game%.m%race% /q >>!.bat
poke %game%.m%race% 0xc >>!.bat
poke !.bat 0x9 0xd
poke !.bat 0xa 0xd
call !.bat
set year1=%year%

echo set year=>!.bat
poke %game%.m%race% 0xd >>!.bat
poke !.bat 0x9 0xd
poke !.bat 0xa 0xd
call !.bat
set year2=%year%
set /a year=(year2 *256) +year1

set /a year=year +2400

md "%year%"

for %%e in (xy x%race% m%race% h%race%) do copy %game%.%%e "%year%"

:end
del !.bat


=====================
And as a special bonus! here's one that'll auto detect how many player M files you have and auto back them up for you! (still requires POKE.exe)
=====================


@echo off

if exist zgame.bat goto skip

echo Make sure any races you want backed up are present in the directory.
echo .
echo Game name?
set /p game=
echo set game=%game%> zgame.bat
set num1=1
set num=0

:loop1
if exist %game%.m%num1% set /A num=num +1
if exist %game%.m%num1% echo set race%num%=%num1% >> zgame.bat
if %num1%==16 goto next
set /A num1=num1 +1
goto loop1

:next
echo set num=%num% >> zgame.bat

:skip
call zgame.bat
set race=%race1%
echo set year=>!.bat
poke %game%.m%race% 0xc >>!.bat
poke !.bat 0x9 0xd
poke !.bat 0xa 0xd
call !.bat
set year1=%year%

echo set year=>!.bat
poke %game%.m%race% 0xd >>!.bat
poke !.bat 0x9 0xd
poke !.bat 0xa 0xd
call !.bat
set year2=%year%
set /a year=(year2 *256) +year1

set /a year=year +2400

md "%year%"
copy %game%.xy "%year%"

for %%e in (%race1% %race2% %race3% %race4% %race5% %race6% %race7% %race8% %race9% %race10% %race11% %race12% %race13% %race14% %race15% %race16%) do copy %game%.?%%e "%year%"

copy !trade* %year%

:end
del !.bat


[Updated on: Wed, 17 December 2003 22:06]




Rule 1: "Pillage, THEN burn!"

Report message to a moderator

Previous Topic: History of Hilton Lange and the Star(s!)Base
Next Topic: Variable Max
Goto Forum:
  


Current Time: Sun Jun 02 10:42:55 EDT 2024