Previous | Contents | Index |
Example 1
!Numeric Initialization MAT CONVERT = zer(10,10) |
!Initialization MAT na_me$ = NUL$(5,5) |
!Array Arithmetic MAT new_int = old_int - rslt_int |
!Scalar Multiplication MAT Z40 = (4.24) * Z |
!Inversion and Transposition MAT Q% = INV (Z) |
The MAT INPUT statement assigns values from a terminal or terminal-format file to array elements.
MAT INPUT XYZ(5,5) MAT PRINT XYZ; |
Output
? 1,2,3,4,5 1 2 3 4 5 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 |
The MAT LINPUT statement receives string data from a terminal or terminal-format file and assigns it to string array elements.
DIM cus_rec$(3,3) MAT LINPUT cus_rec$(2,2) PRINT cus_rec$(1,1) PRINT cus_rec$(1,2) PRINT cus_rec$(2,1) PRINT cus_rec$(2,2) |
Output
? Babcock ? Santani ? Lloyd ? Kelly Babcock Santani Lloyd Kelly |
The MAT PRINT statement prints the contents of a one- or two-dimensional array on your terminal or assigns the value of each array element to a record in a terminal-format file.
DIM cus_rec$(3,3) MAT LINPUT cus_rec$(2,2) MAT PRINT cus_rec$(2,2) |
Output
? Babcock ? Santani ? Lloyd ? Kelly Babcock Santani Lloyd Kelly |
The MAT READ statement assigns values from DATA statements to array elements.
MAT READ A(3,3) MAT READ B(3,3) PRINT PRINT "Matrix A" PRINT MAT PRINT A; PRINT PRINT "Matrix B" PRINT MAT PRINT B; DATA 1,2,3,4,5,6 |
Output
Matrix A 1 2 3 4 5 6 0 0 0 Matrix B 0 0 0 0 0 0 0 0 0 |
The MAX function compares the values of two or more numeric expressions and returns the highest value.
BASIC allows you to specify up to eight numeric expressions.
DECLARE REAL John_grade, & Bob_grade, & Joe_grade, & highest_grade INPUT "John's grade";John_grade INPUT "Bob's grade";Bob_grade INPUT "Joe's grade";Joe_grade highest_grade = MAX(John_grade, Bob_grade, Joe_grade) PRINT "The highest grade is";highest_grade |
Output
John's grade? 90 Bob's grade? 95 Joe's grade? 79 The highest grade is 95 |
MID$ can be used either as a statement or as a function. The MID$ statement performs substring insertion into a string. The MID$ function extracts a specified substring from a string expression.
A$ = "ABCDEFG" MID$ (A$,3) = "123456789" PRINT A$ |
"AB12345" |
!MID$ Function DECLARE STRING old_string, new_string old_string = "ABCD" new_string = MID$(old_string,1,3) PRINT new_string |
Output
ABC |
!MID$ Statement DECLARE STRING old_string, replace_string old_string = "ABCD" replace_string = "123" PRINT old_string MID$(old_string,1,3) = replace_string PRINT old_string |
Output
ABCD 123D |
The MIN function compares the values of two or more numeric expressions and returns the smallest value.
BASIC allows you to specify up to eight numeric expressions.
DECLARE REAL John_grade, & Bob_grade, & Joe_grade, & lowest_grade INPUT "John's grade";John_grade INPUT "Bob's grade";Bob_grade INPUT "Joe's grade";Joe_grade lowest_grade = MIN(John_grade, Bob_grade, Joe_grade) PRINT "The lowest grade is";lowest_grade |
Output
John's grade? 95 Bob's grade? 100 Joe's grade? 84 The lowest grade is 84 |
The MOD function divides a numeric value by another numeric value and returns the remainder.
Num-exp1 is divided by num-exp2.
DECLARE REAL A,B A = 500 B = MOD(A,70) PRINT "The remainder equals";B |
Output
The remainder equals 10 |
The MOVE statement transfers data between a record buffer and a list of variables.
MOVE FROM #1%, I%, A$ = I% |
Previous | Next | Contents | Index |