TGC Codebase Backup



Intro to Programming by MikeS

16th Sep 2003 17:21
Summary

This will be a short guide that introduces some of the basic commands of dark basic and darkbasic professional. By the end of this lesson, you'll have completed many small programs



Description

This will be a short guide that introduces some of the basic commands of dark basic and darkbasic professional. By the end of this lesson, you'll have completed many small programs along with one small text game.



Code
                                    ` This code was downloaded from The Game Creators
                                    ` It is reproduced here with full permission
                                    ` http://www.thegamecreators.com
                                    
                                    `Intro to Programming
`This has been produced by Mike(Yellow)
`Please use this guide for your own benefit.
`Please do not modify this tutorial in any way without the author's permission
`
` Some basics of programming first.
` You may have noticed the "`" sign. It is used mainly for posting notes.
` Anything behind the "`" sign is ignored from the compiler when the program is running ` or compiling. There is also another way of ignoring the text or syntax.
Rem The rem statement also will give you the same results.
Rem Often, I use the ` sign, just because it is shorter, and less time consuming. 
Rem There is one more way I know of that you can block out the syntax, but I will not Rem get into it in this tutorial.

` First, we'll start with the basics
` Practice typing these lines of code into your dark basic or dark basic professional 
` screen.(If you don't have DB or DBP see the downloads section of the TGC website.

Do
Print "My first program"
wait 4000
end

` Basically what this does is Print my first program, onto the screen. Then it waits 
` about 4 seconds and then closes the program. There are many other ways you can write   
` this statement, but this is just a simple one.

Do
Print "Hello"
Loop

`What this does, is prints Hello, and keeps printing Hello vertically on the screen with the loop command.

`Now we'll move onto something a little more complex. We'll begin learning about `variables.

A = 100
Do
Print A
Loop

` Our first line of code says that A = 100, so any time we type Print A, it will print `100. Finally we use the loop to keep printing A.
`Next we move onto Input Commands

Do
Input "Pick any number that you can think of",Number#
Print "You picked the number " ;" "  Number#
loop

` We're now working with Input Statements. Basically, we ask the user to input data, and ` we store it in a special variable. When using the # sign after whatever you call your ` variable, it will store a number. Then we type in Print "You picked the number " and  ` we put a semicolon in and our variable so that it will print our number that we picked
` right after the print statement.

Do
Input "What is your Name",Name$
Print "Hi " Name$
Loop

` Now we've used the $ sign, so that we can store text. Go ahead and try and see what `would happen if you replaced the $ sign with a # sign in this statement. You'd end `upwith 0.
`How easy is that, you've just writeen your first few programs, and probebly didn't even realize it!