I recently came across a program I wrote about 7 years ago. It was an ambitious project at the time — to build a virtual friend. Most of the programming I did back then was creating simple scripts that could just display text on the screen.
With Virtual Friend, the goal was more than just printing text.
My aim was to create a program that could interact with humans like the modern-day chatbots. Years later, looking back at it, I now understand what inspired me to start creating software.
My interest in computers began about a decade ago, toying around with our old PC — a Dell tower — with an old-school CRT monitor. On weekends and school holidays, I’d spend hours on it going through menus and creating PowerPoint presentations with all sorts of transitions and sound effects.
I first discovered programming as a result of frustration. After countless PC crashes due to viruses, I was determined to create my own.
The simplest at the time was a script that deleted Windows XP’s system32 folder.
This was pointless.
I couldn’t test it to see if it worked cause that would crash my PC.
However, through this process, I came across DOS commands.
These are files with a .bat extension consisting of single-line DOS commands based on the MS-DOS operating system.
Prior to transparent taskbars and the bliss wallpaper, operating systems were based on the command line. Through a series of commands, you were able to open and manipulate files on the computer.
Unlike programming languages, the commands are interpreted line by line — not compiled.
To display output on the terminal the ‘echo’ command is used followed by the text to display.
c:\> echo hello worldc:\> hello world
Working with Batch files taught me the 3 basics elements of any program:
- Displaying output
- Handling user input
- Control structures
echo welcome to THE V.Fecho LOGIN to acess VIRTUAL FRIENDSET /P uname=Please enter your name:
On line 3, a prompt is displayed to the user to enter their name and the input is stored in a variable called ‘uname’.
Java has a similar approach to reading users’ input.
Scanner sc = new Scanner(System.in);String uname= sc.nextLine();
And so does Python.
uname = input(“Enter name”)print(uname)
Virtual Friend had a rather simple login algorithm. If no input was provided the program simply exited.
IF “%uname%”==”” GOTO Error:ErrorECHO You did not enter your name! Bye Bye!!
GOTO’s aren’t that popular with modern programming languages since they reduce the readability of code. C++ is the only language I know of that still supports them, but it’s still considered a bad practice.
If statements in DOS are similar to those in other languages.
The only difference is that it doesn’t support ELSE statements. To check for multiple conditions, one has to chain multiple IF’s.
SET /P choice=input 1 , 2 or 3=if "%choice%"== "1" GOTO 1if "%choice%"== "2" GOTO 2if "%choice%"== "3" GOTO 3
The highlight of Virtual Friend was the ability to chat with your VF. I remember the excitement on my friends’ faces when I first showed it to them.
Though, looking at it now, I cringe every time I run the program.
echo Hi %uname% its me %vfname% your VFSET /P doin=what you doing?`SET /P now=you really like %doin% dont you?SET /P oh= oh okay
VF:Hi Edwin its me PC3000 your VFVF:what you doing?listening to musicVF:you really like listening to music don't you?yesVF:oh okay
Despite having limited learning resources at the time, I used 3 commands:
Accepting user input:
SET /P age=enter age
echo your age is %name%
And control structures:
if "%age%">= "13"echo you are a teenager
to come up with simple programs that I could show off to my friends in school.And because of those simple programs, I’m proud of my journey in developing software.
In the business world they say that after learning to make your first million, the next ten will be easy. I believe the same applies to programming.
The first language you learn can be daunting but the next ten will be a walk in the park.
Keep on going.
You can find the source code here. Thanks!