Programming Software Yourself
Programming is the process of writing instructions that tell the hardware what to do. It is at the heart of computers, however, for most people is an impenetrable black art. You must not be a mystery, however. It would be ridiculous to suggest that we non-programmers could soon be writing software to compete with Microsoft Word or Excel, but understanding the basic principles are not as difficult as you might think.
If you’ve never touched a computer programming, here’s your chance to get an appreciation of what is involved. In the first of a two-part series, we’ll teach you the basics so you can start writing programs for your PC.
Many programming languages are available; Here base used (short for any purpose symbolic instruction code for beginners). We chose this language to its relative simplicity. All you need to know before starting is the definition of a program: a list of instructions that are executed sequentially and tells the computer what to do.
A basic drawback is that it is an ancient language. As the name suggests, it is also pretty basic. In the 47 years since it was introduced basic, many variations have occurred. SmallBASIC, we use the following workshop is only one of them (not to be confused with the product of the same name Microsoft: Small Basic).
SmallBASIC contains many instructions that are not in the original database. Except for graphics, we avoided the use of most of them, instead help you get struggling with instructions that will be familiar to all versions.
Because the original database does not include the facilities for graphical programming, graphics statements are the property of all the basic versions. How graphic output occurs SmallBASIC is different from many other versions
Step 1. Before you write software will perform a sampling program SmallBASIC. Select File, Open and select plasma.bat C \ Program Files (x86) \ \ SBW32 FLTK_0.10.7 \ graphics. The program appears in a tab labeled plasma.bas. Click Run in the bottom tray, then select the Output tab.
Step 2. Select the tab and change const plasma.bas “to” contras “in line 10. This goes from red to black, as there is more keyword of a base (see below ). Click Run, and you’ll see the error message “Undefined Code SUB / func: cons’ with the status line indicating that it is on line 10. Get used to see these error messages.
Step 3. Select File, Close to rid the sample program. Then select untitled.bas tab, enter the following code and click Run. “Hello, World” appears in the Output tab. You wrote your first program. It is not mandatory in SmallBASIC, but we’ll use line numbers to make it easier to add later orders.
Step 4. PRINT is a basic keyword and tells the PC to perform an action. Basic allows you to create and variable names that contain a value. He illustrates this by using ‘N’. It will start a new program and enters the code above, then click Run. the FOOTPRINT N ‘The three states produce different results due to changes in the value of N on lines 3 and 5.
Step 5. The “N = N + 1” is an instruction that tells the computer to change the N content with greater value than before. Test the program on the screen above to see to other arithmetic functions, ie, subtract (-), multiply (*), division (/) and “raise to the power of ‘(^).
Step 6. Create a new program and enter the code above. Figure out what you think the answer will be, and then click Run. You’ve probably added 10 and 2, making 12 then multiply by 4, which 48. In fact, the answer is 18. complete basic multiplication and division before addition and subtraction.
Step 7. GOTO statement tells the PC to access a specified line number. SmallBASIC also uses the IF statement, which allows you to have multiple conditions. For example, SI N = 10 and K = 0 THEN GOTO 50 ‘. We also introduce INPUT and END instruction. Strictly speaking, all programs must end with END.
Step 8. GOTO can generate loops, but for NEXT and provide a better solution. The code between the two states is performed for each value of the variable in the FOR statement (our program shows the numbers from 1 to 10 and their squares). You can also specify a step, as “n = 2-100 STEP 2 ‘.
Step 9. In Step 2 is a syntax error. This type of error was collected before attempting to run a program; others are found only when a program is executed. The above program illustrates this – have a go yourself. Work fine until one is 0 and the program is able to divide by zero.
Step 10. Here is another mistake. Run the program and enter “1” when prompted. Will be terminated properly. Run again and type ‘0.3’. The program will not end because it is N BRK 10. Click the status bar to force it to stop. Noting that he has changed RUN BRK demonstrates a program is running, perhaps in an infinite loop.
Step 11. The programs sometimes require data that can be read from an external file or included in the program as data declarations and accessed by the statement. You can include as many values as you want in a given instruction. This program works in the same way if all the values were within a length of instruction data.
Step 12. Use Playing data and stored by a large number of assignment statements (for example, X = 108), but does not produce a very interesting or useful result. Change the first statement in ’20 PRINT SET X, Y COLOR 5 ‘and the second for ’50 LINE X, Y COLOR 5’. Check out the tab corresponding to the following picture.
Step 13. Add ‘REM 1’ as the first line of the program and run it again. It will work exactly the same. REM statements (observation) are ignored, but useful to add comments. Make it a habit to include REM statements – they make their programs easier to understand if you want to change later.
Step 14. If you want to use the values in the DATA statement more than once, use the RESTORE statement. This makes the next play return to the specified line (for example, RESTORE 100). Try it now: modify the program to draw two or more of these symbols, each offset by 10 pixels by using a For / Next loop.