Fast Track 2.1

From BR Wiki
Jump to navigation Jump to search

Your users aren't going to be interacting with the BR console, but the GUI console. The next two sections of the tutorial are: handling Human interaction, and handling Data.

Handling Data

Variables can be filled with numeric or non-numeric values. The names of non-numeric, or string variables, must end in a $. If string variables are longer than 18 characters, they must be specified by a DIM statement, which consists of DIM, an asterisk, and the number of characters. Mathematical operations cannot be performed on strings, unless the internal function VAL(string$) is used. An operator such as the += can be used as a shortcut for "add and assign", so X+=3 is the same as X=X+3.

DIM example$*50

When the user inputs information and you can save it as individual pieces or in a matrix, using the MAT keyword. MAT can contain numeric or string values but not both. The MAT keyword must always be followed by the name of the matrix. The MAT name makes it string or numeric, just like variables with the presence or lack of a $ sign.

DIM sets the size of a matrix.

DIM X$(4)
let X$(1)="A word"
let X$(2)="B word"
let X$(3)="C word"
let X$(4)="D word"


print mat X$(3:4)

would print out

C word
D word

You can also use MAT to resize arrays:

mat X$(7) 

makes it so that X$ now contains 7 elements, the new three of which are blank.

The UDIM function returns the size of an array.

print UDIM(mat X$)

would now print out 7.

To dimension a Matrix to be one bigger than it's current unknown size, use the code:

mat X$(udim(mat x$)+1)

or

mat X$(udim(X$)+1) ! these both mean the same thing, udim is one rare exception where the mat keyword is optional.

This takes the array of X$ and makes it 1 spot bigger.

Data is often READ or INPUT into a MATrix before being processed in one way or another.

Information can be written to a file, using the WRITE and REWRITE statements. But first, you have to OPEN the file. The first time you open an internal file is when you create it.

OPEN #3: “Name=customerlist,  NEW, recl=58”: INTERNAL, OUTPUT, RELATIVE ERROR errorhandling

See Open Internal for details about each parameter.