Beginning Programming Series - Part 5

Glossary

Zero Based Arrays and One Based Arrays:

The base that an array uses refers to the index value that the array starts out with. For instance, if an programming language always begins counting arrays at one then we say that the arrays are One Based. If it begins counting at zero we would say it is a Zero Based language; Many languages - such as C - start arrays with the first element being a zero. This is important because when you declare and array it creates just enough space in memory to hold the elements that you define. Declaring 5 elements in a One Based language would create element 1, 2, 3, 4 and 5. Doing the same in a Zero Based language would create elements 0, 1, 2, 3 and 4. In either case just 5 elements are created. Liberty Basic is unique in that it is able to work with arrays as if it were Zero Based or One Based. This is because it always creates n+1 elements when you dimension an array. This allows the user to elect to begin referencing their arrays with an index value that starts are either 1 or 0. Most people who are new to programming are more comfortable with a value that starts at one. Liberty Basic can do either.

Empty String:

An empty string is a string that has no length or value. Set a string to empty by assigning two quotes with no spaces to it as in this example:

a$ = ""

Empty strings are often called Null Strings.

LOCATE:

LOCATE is a Liberty Basic command that is used both in Windows based windows to move controls around, and also in the main console window to position the cursor relative to the top left of the console (considered location 1,1). Used this way LOCATE emulates the function of the statement by the same name in QuickBasic. Here is what the Liberty Basic help file says about locate when used in this manner:

LOCATE IN MAINWINDOW

locate x, y

Description:

Using LOCATE in the mainwindow causes text to be printed at the x, y location specified. These coordinates refer to the column and row of text, not to screen pixels. This command functions in the same was as the Qbasic LOCATE command and is used to position text on the mainwindow. Here is a short demo:

  'plot a wave
  for x = 1 to 50
    i = i + 0.15
    locate x, 12 + int(cos(i)*10)
    print "*";
  next x

Splash Screen:

A splash screen is the typical graphic that is displayed as a program is started up. It introduces the program. Microsoft likes these a lot. Liberty Basic use to have one back in the LB2.x days. Here it that splash screen:

Absolute Value:

An absolute value is a mathematical concept that defines a number as always being positive, regardless of its true sign. It is a useful concept in computing and nearly all languages provide an Absolute Value function. Liberty Basic's function is called ABS. Here is what the help file says about it:

Description:

This function returns | n | (the absolute value of n).

Usage:

print abs( -5) produces: 5

Floating Point values and Integer values:

Liberty Basic manages the conversion and manipulation of numeric variable types behind the scenes. Even though this is the case, it is still important to understand the difference between a Floating Point number and an integer. The difference is really quite simple. A Floating Point value is a number that has a decimal (or fractional) component. For instance:

3.14
5896.231106
.00005
6.000000001

An integer number is a whole number. There is no decimal component. By definition there can not be a fractional component. Integers always have an implied decimal at the furthest right place in the number, but they do not actually have a decimal anywhere. Also, when floating point values are converted to a true integer the decimal is cut off, truncated. (This conversion is done with the INT function.) Here are some examples of the numbers above in Integer format:

3
5896
0
6