Wednesday, November 16, 2011

A simple menu that rejects invalid options

@ECHO off
cls
:start
ECHO DEFAULTS TO D WHICH WILL FAIL.
ECHO A. Case insensitive
ECHO b. second option
set choice=D
set /p choice=Type the letter
if not '%choice%'=='' set choice=%choice:~0,1%
REM the next line is case insensitive
if /I '%choice%'=='A' goto optiona
if '%choice%'=='b' goto optionb
ECHO "%choice%" is not valid, try again
ECHO.
goto start
:optiona
ECHO You typed A
goto end
:optionb
ECHO You typed B
goto end
:end
GOTO START

Monday, June 11, 2007

Escaping Redirectors in Batch Files

Use ^.

For example:

echo echo text ^> file.txt > newbatfile.bat

Friday, May 25, 2007

My first FOR-IN-DO LOOP in a batch file.

FOR.BAT
==================
FOR %%F IN (*.TXT) DO CALL TEST.BAT "%%F"

The quotes make it work in DOS for filenames with spaces.

TEST.BAT
==================
@echo off
Type %1 > file_.txt
Del %1
copy file_.txt %1
del file_.txt

Friday, March 2, 2007

First Post

This is a blog about DOS. When I got bought my first PC, a FastData 386DX40 I found for $1500.00 in Computer Shopper, it came with a letter from some lawyers saying that if I wanted to join a class action lawsuit against FastData, I could. When I plugged in and it didn't work, I realized that I was on my own.

So I started taking it apart and pulling out the cards in it. Eventually I got it to boot after taking out the 2400 baud internal modem. It must have been broken or something. I hitched a ride to Best Buy to pick up a new modem, which was the wrong kind, so I had to go back.

Eventually I got the PC to boot up into it's preloaded operating system, Windows 3.1. Looking back, I think I made the best decision of my life. I decided not to use it. I knew that Windows 3.1 ran on DOS, and since I didn't know DOS, I knew that I should learn it before moving to Windows 3.1. So I decided to just run DOS. I learned how to use DOS very well, and I can tell you that well before I used Windows, I was able to connect to FTP sites, transfer files back to my PC using ZMODEM, unpack them using pkunzip, lha, or even UC2 (my personal favorite), and install them. I have downloaded 1 MB files over a 2400 baud modem, so you will believe me when I say that I can count by 1024s.

This blog will contain information and links to my favorite old DOS programs, and tips about how to run operating systems like FreeDOS under VMWare emulation. I have turned off any annoying comment checking. If I get more spam than I do real comments, I might turn on a filter. Who knows.

I tried to make this blog match the color scheme of the Norton Utilities, my favorite DOS program of all time. Personally, if Peter Norton made a full fledged operating system, I think I would still be running it today. Everything in this Blog is in the FIXEDSYS font, so everything will look the same. In Windows it should look kinda like DOS. If you run Linux, like my mom does...it may look different. If anyone has any ideas for improving the look or improving Linux compatibility, you can comment.

HUGE
NORMAL
TINY
BOLD
ITALICIZED