Thursday, May 27, 2010

Basic4GL Basics Tutorial 2 - Variables and Constants

This is the secobd part to the Basic4GL Basics Tutorial set. If you want to learn how to display text to the screen then go here.

Variables are not just very useful but they are essentially needed in every program. Basic4GL's variables have to be declared with dim no matter what type of variable you are using. The different variables types are as such:
  • integer e.g dim x = 1
  • float e.g dim x# = 1.01
  • string e.g dim string$ = "Hello World
ok so those are the three variable types used in Basic4GL. Constants are the same as variables except is just declared like so const x = 10. constants cannot be altered later on in the program where as the other three variable types can.

So lets use some variables and print them to the screen.

dim a = 1
dim b# = 1.014
dim c$ = "Hello Mate"

printr a
printr b#
printr c$

ok so thats the basic part of using variables. lest use maths with variables aye. This is a bit of fun.

dim a = 1+7
dim b = 9
dim c = a + b

print c

Well thats the addition used. You can experiment on what you have learned in this tutorial as you have completed it.

Tell me what other tutorials for Basic4GL you would like me to make for you by emailing me at

No comments:

Post a Comment