|
Getting Started With
SiMPLE
An Introduction To
SiMPLE
Programming For Total Beginners
|
Even though a computer may seem powerful and smart, it's really just a dumb box that can't do anything on its own without first being told what to do and how to do it.
Every amazing and wonderful game, utility, etc. that you have ever used on your computer was created by someone else who "told" your computer how to do all those amazing and wonderful things. But now, we are going to introduce you to SiMPLE, a very easy (but powerful) programming language that lets you make your computer do whatever you want it to do!
Before you can start using SiMPLE, you will need to download and install it. . . if you haven't already done so.
Ok, now that you've got SiMPLE installed, let's start having some fun with it!
Open the "Samples" folder that you got when you installed the SiMPLE package. (If you've installed SiMPLE onto your computer's main "C:" drive, the "Samples" folder is on your desktop. If you've installed SiMPLE onto some other drive [such as a flash drive], the "Samples" folder is in the root directory of the drive.) Inside the "Samples" folder you will find a lot of text files, a
(The above image might look different on your computer, depending on
the version of Windows that you are using and how you've configured it.)
For the present time, we will be interested only in the text files and the
Each text file in the "Samples" folder contains a "program listing" (i.e., a set of "instructions" that tells the computer what it should do). Shortly, we will start creating our own program listings. But for now, let's just use the ones that we already have in the "Samples" folder.
The easiest way to run a SiMPLE program listing is by using "Drag & Drop" mode. To do so, just drag and drop any SiMPLE program listing onto the
|
*Note: On some computers, when using SiMPLE on a drive other than the main "C:" drive, the "S i M P L E" icon might only allow you to use SiMPLE in "Command-line" mode. In that event, find the "Drop SiMPLE Listing Here" icon:
Use that "Drop SiMPLE Listing Here" icon instead of the "S i M P L E" icon to use SiMPLE in "Drag & Drop" mode. |
For example, let's try running the "Circles" program listing. Just drag and drop the "Circles" text file onto the
A black window will open, and the words
Then a black screen will pop open, and some noisy animated circles will appear. (Pretty cool, eh?)
[If the "Circles" program fails to execute properly, click here for further instructions.]
Let the program run for as long as you like. When you are ready to stop the program, simply press the "Esc" key on your keyboard.
Most of the program listings in the "Samples" folder are merely intended to illustrate some of the capabilities of SiMPLE. As such, those programs are not necessarily meant to be entertaining and/or useful for anything in particular. But go ahead and try running some of them anyway. Just drag and drop any one of them onto the appropriate "runner" icon (either the
Then, after the program starts executing, simply press the "Esc" key to end the program (unless otherwise instructed).
Note: As you try running the other program listings, be sure that you do completely end each previous program before trying to run the next one. Otherwise that next program might not execute properly. [I.e., If the previous program is running in a window, be sure to end that program before trying to run another one.]
Now that you know how to run a SiMPLE program listing, let's start creating our own SiMPLE program listings! (But, before we begin, just
Project Folders
A "project folder" is merely a special folder that is designed to hold your SiMPLE program listings. Every program listing should exist in a project folder. (This is not a strict requirement, but it is highly recommended. For one thing, the use of project folders helps you keep your programs organized.)
The only project folder that we have seen so far is the "Samples" project folder. Later on, we'll see how to create as many other project folders as we need. But for now, we can use the "Samples" folder to hold the program listings that we will be creating.
Our First SiMPLE Program!
Ok, let's get started! First, create a new text document inside the "Samples" folder. (Right-click anywhere on the white portion of the "Samples" window and select "New", and then select "Text Document".)
Next, open the newly created text document (by double-clicking it) and type the word Win-SiMPLE on the top line.
Although it is usually not necessary to do so, you should begin every SiMPLE program listing with the word Win-SiMPLE (with an upper-case "W" in the word "Win") on the first line of the listing. After that first line, whatever instructions you put into the rest of the listing are up to you.
For our first program, let's have the computer do nothing more than draw a circle somewhere on the screen. So, on the second line of our new text document, type: Call circle (300, 200, 100)
By the way, when creating a program listing, you can put as many spaces anywhere you
Callcircle(300,200,100)
with no spaces at all. Or you could even type it like this:
Ca l lci rcl e (30 0, 20 0,1 00 )
with spaces all over the place! Either way will work. However, the letter "C" in the word "Call" must be a capital letter.
When you've finished typing, close the text document (by clicking the "x" button in the upper-right corner of the window) and, when asked if you want to save the changes, click the "Save" button.
Then run the program by dropping the "New Text Document" file onto the the appropriate "runner" icon:
If you didn't make any typing mistakes you should see a white circle appear somewhere on your display.
Congratulations! You've just written and executed your first SiMPLE computer program! (Now, that wasn't so hard, 
Question: In our program, what do the numbers "300, 200, 100" mean?
Answer: They are called "parameters". They specify where the circle is to be drawn and how big it should be.
Try changing those three parameters to different numbers, and then run the program listing again to see how the new values affect the size and location of the resulting circle. You will discover that the first parameter (the "300" in our above example) indicates how far over (from the left side of the screen) the circle is to be drawn, the second parameter (the "200") indicates how far down (from the top of the screen), and the third parameter (the "100") indicates how big the circle should be.
Let's Make Another SiMPLE Program!
This time, we'll write a program that draws a red circle and a green square somewhere on the screen.
Once again, first create another new text document inside the "Samples" folder. (Right-click and select "New", and then select "Text Document"). Then open new text document (by double-clicking it) and type the following five lines:
In addition to the "W" in the word "Win" and the "C"s in all of the "Call"s, make sure that you've spelled the word "Red" with a capital "R" and the word "Green" with a capital "G". While spaces don't matter in a SiMPLE program, the use of capital letters is important. (And the general rule is: "Never use capital letters unless they are so indicated." )
When you've finished typing, close the text document (by clicking the "x" button in the upper-right corner of the window) and, when asked if you want to save the file, select the "Save" button. Then run the program by dropping the file onto the the appropriate "runner" icon, just as before. If you didn't make any typing mistakes you should see a red circle and a green square appear on your display.
When the computer executes the list of instructions in a program listing, it generally does so by starting at the top of the list and then working its way down toward the bottom, performing one instruction at a time (just like you would probably do if you were given a list of things to do). So the first thing that our program told the computer to do was: "Set red as the color to be used for drawing lines." Then it told the computer to: "Draw a circle 100 units big, and put it 300 units over from the left side of the screen and 200 units down from the top of the screen." So the computer drew a red circle at that location. Next, our program told the computer to: "Set green as the color to be used for drawing lines (and forget about using red)." And finally, it told the computer to: "Draw a square 75 units big, and put it 500 units over from the left side of the screen and 350 units down from the top of the screen." So the computer drew a green square at that location.
In case you are interested, the "units" that we have been talking about are something called "pixels". [A pixel (short for Picture Element) is a single point in a graphic image. Your computer displays pictures by dividing the display screen into thousands of pixels, arranged in rows and columns. The location of each pixel on the screen is specified by giving the column number and the row number at which the pixel exists.]What Else Can I Do Besides Drawing Circles And Squares?
Don't be misled into thinking that SiMPLE is only good for creating graphic images.
SiMPLE is capable of much more than merely letting you use primitive shapes (such as circles, squares, etc.) to make "pretty pictures".
As you become more experienced at programming, you will discover that SiMPLE lets you do things like: perform complex mathematical calculations, manipulate strings of text characters, read and write data files to and from
So we're startig out by showing you how to do stuff that's perhaps a bit more interesting and fun.
The three "commands" that we've used so far ("color", "circle", and "square") are referred to as "tasks". (In other programming languages, "tasks" are sometimes referred to as "subroutines".)
Every task exists in something called a "library". In SiMPLE, there are two main types of libraries. The most important one is the "System Library". It contains hundreds of tasks that perform very general and primitive operations (such as drawing a circle, etc.)
Inside your "SiMPLE" folder (in your root directory) you will find another folder named "Docs". Open that "Docs" folder and find the file named "Win-Lib". (Or, click here to view our online copy of the Win-Lib document.) It contains a list of some of the System Library's tasks that are most commonly used by beginning programmers.
(If you are curious, a complete list of all the tasks and functions in the System Library is given in the
"W-syslib" document. But most of those tasks and functions are not intended for use by beginners.)
The System Library's "bell" task plays a "bell" sound through the speaker. The "cuckoo" task plays a "cuckoo" sound through the speaker. And the "cls" task clears the entire screen to a specified color. Let's write a program that plays three "cuckoo" sounds, then turns the entire display screen red, and then rings a bell five times.
Once again, first create another new text document, and type the following ten lines into it:
| Program Listing |
When you've finished typing, close the text document and then run the program by dropping the file onto the the appropriate "runner" icon, just as before.
Show Me More!
The System Library contains a task ("showcard") that will display the image of any playing card. And the "messbox" task displays a small window containing a message, along with an "OK" button. Let's use these tasks to write the following little program:
| Program Listing |
Notice that, even though the general rule is: "Never use capital letters unless they are so indicated," it is OK to use your own capital letters whenever you use them between quote marks (such as when specifying a message that you want to have displayed.)
At this point, before going any further, you should spend some time "playing around" with the rest of the tasks and functions described in the "Win-Lib" document. Knowing how to use as many of those tasks and functions as possible will allow you to create more interesting programs later on.
* * * * * * *
In addition to the System Library, SiMPLE also utilizes a second type of library called an "Append" library. An Append library contains tasks that were written by a third-party supplier (such as a
SiMPLE comes with one such Append library already preinstalled for you. (It is called the "toys" library.) Inside your "Docs" folder (which is located inside your "SiMPLE" folder) you will find a file named "Toys-Lib". (Or, click here to view our online copy of the Toys-Lib document.) It contains a list of all the tasks that are in the "toys" library.
Let's write a program that uses some of the tasks in the "toys" library to draw a red rocket on the screen. (We'll even put a few stars in the sky as well.) Then, when you press any key on the keyboard, the rocket will explode, and the program will automatically end:
| Program Listing |
Notice that you must remember to include an "@" character whenever you invoke a task from an Append library, and you must include an appropriate "Append" statement (with a capital "A") at the end of your listing.
How Do I Create a New Project Folder?
Creating a new Project folder is almost trivially easy:
|
*The folder must be located on the same drive that SiMPLE was installed on. (For example, if you've installed SiMPLE onto your "C" drive, you might create your new Project folder on your desktop or almost anywhere else you choose.) |
The first time you use the "S i M P L E" icon (or the "Drop SiMPLE Listing Here" icon), it will automatically create for you a Local "Append" Library folder (named "Library") inside your Project folder (so that, if the time comes that you want to start creating your own library modules, you will be all set to do so.
)
Conclusion
We have barely scratched the surface of all the different kinds of programs you can create with SiMPLE. But you now know enough to at least start playing around with writing your own little fun computer programs.
When you're ready to do so, you should next read our On-line SiMPLE Tutorial to discover many of the other cool things that you can do with SiMPLE.
![]()
[ Contact Us | Homepage | Online Forums | About the Author ] © Copyright 2011-2012 SiMPLE CodeWorks, Inc. All rights reserved. |