Apolyton Archive  |  Preserved copy of the Apolyton Civilization Site and its forums as they stood in September 2005. Read-only; nothing here can be posted to or replied to.  |  Forum index |  About this archive |  The 1998–2001 UBB forums
Today on Apolyton WARDELL INTERVIEW PROMO A.C.S. HISTORY CHAPTER 4 GET CIV4 /w FREE PLUS! A.C.S. PHOTO GALLERY GET A.O.M. V1.1
Apolyton Civilization Forums
main| civ2| civ3| civ4| smac| ctp2| ron| moo3| galciv| galciv2| alt| about|
ApolytonPLUS | register | search | faq | new posts | pm (-/-) | upload | members
hall of fame new! | civgroups | civgroups news | interviews | the column | radio | chat | directory | news | store | PLUS
Apolyton Civilization Forums : Powered by vBulletin version 2.0.3 Apolyton Civilization Forums > Alpha Centauri > AC-Creation > What I learned about Batch files that...
Show a Printable Version | Email This Page to Someone! | Receive updates to this thread | Report this to Apolyton news!
16.Sep: ZAKHAROV TURNS ELEVEN
15.Sep: `POSSIBILITY` IS ALL FOR NOW
15.Sep: THE SINGULARITY CONNECTION

bottom of page
  - ALPHA CENTAURI PC $9.99 - Centauri Dawn $6.50 - Dragon Sun $6.99 - Twilight of the Mind $6.99 - Power of the Mindworms $8.95 - ALPHA CENTAURI MAC $19.99
Author
Thread    < Last Thread     Next Thread > Post New Thread     Post A Reply
smacksim is offline smacksim
King
Deputy Chairman of the Council of Lords of Gaia
Feb 2004
time: 00:37
  Old Post 03-07-2004 08:26
Edit/Delete Message Reply w/Quote
#1 Report this post to a moderator
What I learned about Batch files that... Support Apolyton, buy Galactic Civilizations

".....that I was never taught in school"

Just a batch thread for discussing some things that might be good to know, especially before you take up Batch writing.

1. Dos memory is small. It can be inflated, but this is not usually recommended. Environment variables, IE, any variables you assign, seem to have the least space. I've had errors after just assigning 8 or 10 variables in a batch.

1.a. There are several ways to expand the memory. Actually dozens. MANY of them don't work on all versions of windows, which is why it's best to avoid these kind of solutions if you can. Some of these include 'Create a shortcut to the batch and then use the properties tabs to assign the memory spaces' : wrong, doesn't work in NT or XP. Or, 'change the shell environment' : wrong, you don't want to go messing with people's machine settings if you can help it. Besides which, these things are difficult to do and know where to do.

1.b. The one method that does seem to apply to all modern DOS, from what I can tell, is "command /C batchfile.bat /E:nnnnn" where n is a number between 160 and something bigger. Dos is typically run with only 256k available, so beefing that up to 1048 or higher is accpetable. the /C is to make it work like a 'call', and return to the line in the existing batch when the called batch is finished. The caveat here is that, though this works, it didn't help me with gaining more environment-variable space anyways. I had to use fewer variables. But it might help you.

2. Dos versions vary across all the windows environements. There are commands available to XP and NT users that will not work on earlier versions without installing extra files into your core directories.

3. Desipite #2, most of the best commands are available to machines with any version of Windows. Just avoid things like 'Choice' and some of the low level stuff such as modifying Command.com or things like that.

4. DOS is not Perl. There are only 10 native batch commands. 10! . Then there are another handful of DOS commands. Don't go writing real scripting with DOS. There's no hope for people who would try to do a recursive decent parser with it. You could do it, but it'd be dumb.

4.a. DOS is just powerful enough on the other hand. You can do most of the heavy lifting with it. Things like moving files around or even simple scheduling are easy. With so little possibilites, it is not at all hard to learn. Also, though Microsoft would like to see DOS die, it hasn't, so it's a convenient way to set up programs for Winblows machines. It's just that if you want to do real programming, you should do that. DOS is for the simple stuff.

5. Some simple things you can do without installing another command interpreter (IE perl, winscripting, vb, whatever); This means you can set them up in a flash on a new machine. I like having little batch files to KILL windows and shutdown when other things fail. Many people like to have a simple button to click that will back up all files modified after such-and-such a date, or to destroy all the cookies in your browser, or to merge logfiles, or whatever. If you've never given it a try, I reccomend it. I wish I'd learned DOS first (instead of basic). It's damn simple. Even better, it will screw you up bigtime when you go back to a *nix environment because everything is backwards in DOS.

No, there is no real point to this thread. But if you do have Batch tips, maybe this would be a good place to put 'em for others on Apolyton. When I did my search I found a lot of references to CivSwap, which got my heart beating fast because I've just written ModSwapper with batch. They are totally different. CivSwap is for in-game settings switchs based on Autosaves. ModSwapper is for installing and uninstalling and auto-install-launching mods for any game. Whew. But there are some people that still use DOS. Now I see why.

-Smack

Enigma_Nova is offline Enigma_Nova
King

Nov 2003
time: 14:37
  Old Post 03-07-2004 17:14
Edit/Delete Message Reply w/Quote
#2 Report this post to a moderator
Help yourself to an AD-FREE life

What I've learnt about batch files:

Never make your Autoexec.bat refer to itself. :/

smacksim is offline smacksim
King
Deputy Chairman of the Council of Lords of Gaia
Feb 2004
time: 00:37
  Old Post 07-07-2004 00:44
Edit/Delete Message Reply w/Quote
#3 Report this post to a moderator
Support Apolyton

1.b above is also wrong. Command.com and cmd.com vary on the distributions of DOS and windows.

-S

smacksim is offline smacksim
King
Deputy Chairman of the Council of Lords of Gaia
Feb 2004
time: 00:37
  Old Post 10-07-2004 06:21
Edit/Delete Message Reply w/Quote
#4 Report this post to a moderator
Get a bigger avatar today!

I could use some help getting this to work on various Windows installs. If you could download and report any errors and/or help me debug, that'd be great. I get no errors on my machine. It swaps 60+files and launches terranx.exe with one click. Let me know what Windows you are running if you get an error.

-S

#endgame is offline #endgame
Prince
of the town of ZZT
Dec 2003
time: 15:37
  Old Post 18-07-2004 15:13
Edit/Delete Message Reply w/Quote
#5 Report this post to a moderator
Support Apolyton, buy Civilization 2

You can make the first batch file in a program call itself:

code:
@echo off if not "%1"=="READY" command /E:4096 /C %0.bat READY


Will re-run the batchfile and allocate 4k of environment space. Even the spammiest batchfiles I've seen (in terms of env-vars) can't fill that.

Test the env-var %OS% to find wether or not you have cmd on the system.

go to http://www.nu2.nu and you can get a freeware version of choice called bchoice (Bart's choice). Compatible with all Windows >9x but not puredos.

Try looking for a program called batchman (freeware). really nifty batch file tool, or find a copy of WBAT (also freeware) for doing dialogs.

Some of the stuff you can do with dos is really quite scary, especially since some people like to port unix utilities of good to windows.

the rundll32 command is handy, since you can call some windows api calles with it.

That's all I can think of now.

#endgame is offline #endgame
Prince
of the town of ZZT
Dec 2003
time: 15:37
  Old Post 21-07-2004 07:29
Edit/Delete Message Reply w/Quote
#6 Report this post to a moderator
Suffering from ads?

Here's a really obscure one:

running a batchfile that calls another batchfile with

command /E:4096 /C blah.bat

in which blah.bat calls another batch file, during or after the call any if statements featuring at least one user-defined environment variable (eg not %1, etc.) will throw "Bad Command or File Name"

smacksim is offline smacksim
King
Deputy Chairman of the Council of Lords of Gaia
Feb 2004
time: 00:37
  Old Post 21-07-2004 08:04
Edit/Delete Message Reply w/Quote
#7 Report this post to a moderator
Help yourself to an AD-FREE life

Ech. That is badly obscure. Looks like a hard one to trace. Glad you squished it.

#endgame is offline #endgame
Prince
of the town of ZZT
Dec 2003
time: 15:37
  Old Post 21-07-2004 17:41
Edit/Delete Message Reply w/Quote
#8 Report this post to a moderator
Get a bigger avatar today!

Pre-NT (I think) versions of windows don't like multiple pipes

code:
tfind /h "Aldebaran 2" aldeb205.sm | tfind /v "Aldebaran 2" | lmod set filename=[$!]


works just fine on 2k but for ME (and probably below) you need:

code:
tfind /h "Aldebaran 2" aldeb205.sm>temp.txt tfind /v "Aldebaran 2" temp.txt | lmod set filename=[$!] del temp.txt

to get the same result.

#endgame is offline #endgame
Prince
of the town of ZZT
Dec 2003
time: 15:37
  Old Post 24-11-2004 16:27
Edit/Delete Message Reply w/Quote
#9 Report this post to a moderator
Suffering from ads?

And just to contradict my above post, only the 9x windows doesn't seem to like many pipes. The following works great under puredos:

code:
ipconfg | tfind "IP Address" | lmod my_ip = [$!]>>kahn.cfg

  < Last Thread     Next Thread > Post New Thread     Post A Reply
All times are GMT. The time now is 05:37.
Apolyton Time is 00:37.
    top of page
Rate This Thread:
Forum Jump:
Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is ON
vB code is ON
Smilies are ON
[IMG] code is ON
 




Contact Us - Apolyton Civilization Site - Support Us!

Building a better Apolyton through better information. Click here and take our poll!
Non-US visitors, click here!

Powered by: vBulletin Version 2.0.3
Copyright ©2000, 2001, Jelsoft Enterprises Limited.

Page generated in 0.0382 seconds (89.86% PHP - 10.14% MySQL) with 30 queries
Page Loading Time:

Support Apolyton: Amazon USA | Amazon UK | Amazon DE | Amazon FR |
Support Apolyton and get FREE PLUS, Buy from Chips&Bits: Galactic Civilizations | Galactic Civilizations: Deluxe Edition | Call to Power 2 | Civilization: The Boardgame | GURPS/ Alpha Centauri | Alpha Centauri | Civilization IV | Civilization III: Complete |


Front Page | Civilization IV | Civilization III | Civilization II | Call to Power II | Alpha Centauri | Master of Orion III
Rise of Nations | Galactic Civilizations | Galactic Civilizations II | Misc
Alt.Civs | Civ I | C:CtP I | About | News | Directory | Apolyton Store | Forums | Chat | Columns | Interviews | Newsletter
Scenario League | CSC | Clash of Civs | Spanish Site | CtP Maps | Cradle of Civ | WesW's Ctp1/2 Site | Civ3 Haven

apolyton.net | apolyton.com | civilization2.net | civilization3.net | civilization4.net | civilizationiv.info | calltopower.net | galciv.net | galciv2.net | moo3.net