Introduction To Jbasic Basic
Introduction To Jbasic Basic
Introduction To Jbasic Basic
Introduction
jBasic BASIC is a Business-oriented programming
language designed to work efficiently with the jBasic
environment.
= + – * ** / ^ (
) # $ ! [ ] , .
Do not confuse the null value with the empty string. The empty
string is a character string of zero length which is known to have no
value.
Like all other data in jBasic BASIC, the null value is represented
internally as a character string. The string is made up of the single
byte CHAR(128).
jBasic BASIC programs can reference the null value using the system
variable @NULL.
Example:
If you concatenate a string value with an empty string, the string
value is returned, but if you concatenate a string value with the null
value, null is returned.
A = @NULL
B = ""
C = "JONES"
X = C:B
Y = C:A
When you concatenate known data with unknown data, the result is
unknown.
Constants
Unassigned
A string, which can be an alphanumeric character string, a
number, or a dynamic array
A number, which can be fixed-point (an integer) or floating-
point
The null value
A dimensioned array (that is, a vector or matrix)
A subroutine name
A file
A select list
Array Variables
An array is a variable that represents more than one data value. There
are two types of arrays - Static and dynamic.
Static Arrays:
Each value in an array is called an element of the array. Arrays can be
one or two-dimensional.
A one-dimensional array is called a vector. Its elements are arranged
sequentially in memory. The index of the first element is 1.
Examples: A(1), COST(35)
TOMSDICKSHARRYVBETTYSSUESMARYFJONESVSMITH
The two fields are:
TOMSDICKSHARRYVBETTYSSUESMARY
and:
JONESVSMITH
Dynamic Arrays
The first value has three subvalues: TOM, DICK, and HARRY. The
second value also has three subvalues: BETTY, SUE, and MARY.
The first field has three values: JONES, SMITH, and BROWN. The
second field has three values: $1.23, an empty string, and $2.75.
Dynamic Arrays
We can create a dynamic array in two ways: by treating it as a
concatenation of its fields, values, and subvalues; or by
enclosing the elements of the dynamic array in angle brackets,
using the syntax:
array.name < field# , value# , subvalue# >
For example, to create the dynamic array A as:
JONESVSMITHF1.23S20V2.50S10
We can say:
A="JONES":@VM:"SMITH":@FM:1.23:@SM:20:@VM:2.50:@SM:10
or we can say:
A = ""
A<1,1> = "JONES"
A<1,2> = "SMITH"
A<2,1,1> = 1.23
A<2,1,2> = 20
A<2,2,1> = 2.50
A<2,2,2> = 10
Operators
Example:
A = 123V456S7890S2468V10F3691V33S12
B = 13V57S912F1234V8
$OPTIONS VEC.MATH
X=A+B
Dynamic Array Operations
the result is:
X <1, 1, 1> = 136
X <1, 2, 1> = 513
X <1, 2, 2> = 8802
X <1, 2, 3> = 2468
X <1, 3, 1> = 10
X <2, 1, 1> = 4925
X <2, 2, 1> = 41
X <1, 2, 2> = 12
These elements are put into the resultant dynamic array, separated by
the delimiter mark corresponding to the highest levels that are
different (for example, X<1,1,1> and X<1,2,1> have different value
levels, so they are separated by a value mark). This yields the
following:
X = 136V513S8802S2468V10F4925V41S12