Thursday, July 22, 2010

Batch scripts in action - Algorithms LAB

Lets have a look @ batch scripts aka batch programming.

I have algorithm lab - C programming.

On very first day new instructions were given - You must create new folder every time named "Lab_DATE" and do respective programs in them. First assignment was to write a C program that performed Quick sort.

As soon as task was fixed, my lab-mates pounced on traditional C editor - Blue-screen and rectangular cursor. I rather prefer to write my program in notepad and then later debug and run in C environment. Notepad is quick, easy copy and paste ;-) , clean interface and much more.



So my actions were prefixed to be performed in every lab,
  •  Create new folder every time
  •  Open notepad and write program
  •  Open that program in C

I thought of making a batch script that would do all these for me.

Quickly, I opened notepad and typed these commands.

mkdir Lab_
cd Lab_
notepad test.c
C:\tc\bin\tc.exe test.c

Next thing to do is save it as "start.bat". Job's done.

Just two lazy clicks on start.bat
  •  Creates "Lab_" folder
  •  Goes into folder
  •  Starts notepad with test.c file
  •  Once program is written and notepad is closed, the program opens in C editor ready for CTRL+F9.

Jobs well done but I am still finding script that would write a Quick sort program Quickly ;-)

No comments:

Post a Comment