29 August 2009

2. Testing base.pb

Let's see what base.pb can do for us. Create a new folder ("testbase") and make a new purebasic source file in it. Then write this into the .pb file:

IncludeFile "..\base.pb" ; Include the base file from the parent folder

Init() ; Init input by reading a line from the console
Global Buffer.s ; A temporary string used by this example

While Look ; Look is the current character we are working with
; Run this loop until Look becomes 0
Buffer + Chr(Look) ; Put Look (converted to a string) at the end of our string
GetLook() ; Discard the current value in Look and read in a new character
Wend

; Now our Buffer will be filled with all the characters read into Look

Emit(Buffer) ; Let's show it just to be sure

Input() ; Wait for enter so we can the output


When you run it, you should see a console window. When you type in some text and hit enter, what you should typed should come back at you, only indented. Read this program (and if necessary, base.pb) thoroughly to understand what's going on.

No comments: