Decimal BASIC Ver. 7.4.4 Outline

Decimal BASIC is a language processing system made aiming at achieving ISO Full BASIC.
Version 7.4.4 has almost achieved the implementation of the graphics module of ISO Full BASIC.
It accepts the whole syntax provided by the graphics module of ISO Full BASIC, while there are slight differences in behavior.
Moreover, the modules and individual character input modules have been roughly achieved, too.
In addition, the complex number mode and the rational number mode are prepared as original enhancements.

Line numbers can be omitted.


Reserved words

The reserved words are only the following 18 words. Any other spelling can be freely used as a variable identifier or a function name.
NOT, ELSE, PRINT, REM, PI, RND, MAXNUM, TIME, DATE, EXTYPE, EXLINE, ZER, CON, IDN, TRANSFORM, DATE$, TIME$, NUL$

Numerical value

Numerical values are the floating point decimal numbers of 15 digits.

All numeric built-in functions that ANSI Full BASIC provides are prepared.

ABS(x)the absolute value of x
ACOS(x)the arccosine of x
ANGLE(x,y)The angle between the vectors (x,y) and (1,0)
ASIN(x)The arcsine of x
ATN(x)The arctangent of x
CEIL(x) The smallest integer not less than x
COS(x)The cosine of x
COSH(x)The hyperbolic cosine of x
COT(x)The cotangent of x
CSC(x) The cosecant of x
DATE The current date
DEG(x) The number of degrees in x radians
EPS(x) The difference between x and the predecessor or successor
EXP(x) The exponential of x
FP(x) The fractional part of x
INT(x) The largest integer not greater than x
IP(x) The integer part of x
LOG(x) The natural logarithm of x
LOG10(x) The common logarithm of x
LOG2(x) The base 2 logarithm of x
MAX(x,y) The larger of x and y
MAXNUM The largest manipulable number
MIN(x,y) The smaller of x and y
MOD(x,y) x modulo y.   x-INT(x/y)*y
PI the ratio of the circumference of a circle to its diameter
RAD(x) The number of radians in x degrees
REMAINDER(x,y) The remainder
RND The pseudorandom number
ROUND(x,n) The value of x rounded to n digits
SEC(x) The secant of x
SGN(x) The sign of x
SIN(x) The sine of x
SINH(x) The hyperbolic sine of x
SQR(x) The square root of x
TAN(x) The tangent of x
TANH(x) The Hyperbolic tangent of x
TIME The current time
TRUNCATE(x,n) The value of x truncated to n digits

OPTION ANGLE DEGREES
OPTION ANGLE RADIANS
Specify the unit of angle measurement for trigonometric functions.
If ANGLE DEGREES is selected, COS(90), SIN(180) and so on become accurately zero.

Accuracy

Fulfilling the regulations of the accuracy of the calculation result of the built-in functions is aimed. At present, no counterexample is found except for the case where it operates on Virtual PC. The accuracy of some built-in functions depends on FPU. Note it when you use a non-Intel CPU.


Strings

All string built-in functions that the standard supply are prepared.

CHR$(m) The character of code m
DATE$date
LCASE$(a$)The lower case
LEN(a$) Length of the string
LTRIM$(a$)The left trimmed string
ORD(a$)The character code of a$
POS(a$,b$)The position of b$ in a$
REPEAT$(A$,m)The repeated string
RTRIM$(a$)The right trimmed string
STR$(x)The string of numeric x
TIME$The current time
UCASE$(a$)The upper case
USING$(a$,x)The formatted string
VAL(a$)The numeric value

It deals with substring qualifiers.
If s$ is a string variable and a, and b are numeric expressions, s$(a:b) stands for the substring of s$ from the a-th character to the b-th character.
Substitution of substring can be executed as follows
LET s$(a:b)=string-expression


Arrays and matrices

MAT A=B Substitution
MAT A=B+C Matrix operation (addition)
MAT A=B-C Matrix operation (subtraction)
MAT A=B*C Matrix operation (product)
MAT A=x*B Scalar multiplication
MAT A=ZER The zero matrix
MAT A=IDN The Identity matrix
MAT A=CON The matrix all of whose elements are one
MAT A=INV(B) The inverse matrix
MAT A=TRN(B) The transposed matrix
DET(A) The determinant
DOT(A,B) The dot product

Built-in functions

LBOUND(M,i) The lower bound of the i-th subscripts of M
UBOUND(M,i) The upper bound of the i-th subscripts of M
SIZE(M,i) The number of elements in the i-the dimension of M
SIZE(M) The number of the total elements of M
MAXSIZE(M)The upper bounds of permitted size of M

String MAT-statements are available, too.


Control structures

FOR - NEXT
DO - LOOP
IF - ELSE - ELSEIF - END IF
SELECT - CASE - END SELECT

Control statements

EXIT FOR
EXIT DO
GOTO
GOSUB
RETURN
ON GOTO
ON GOSUB


Program Segmentation

DEF-statements

Example.

DEF f(x)=x^2+3*x+1
PRINT f(4)
END

Internal function definitions (FUNCTION - END FUNCTION)

Example.

FUNCTION GCD(a,b)
   IF b=0 THEN LET GCD=a  ELSE LET GCD=GCD(b,MOD(a,b))
END FUNCTION
INPUT a,b
PRINT GCD(a,b)
END

External function definitions (EXTERNAL FUNCTION - END FUNCTION)

Example.

DECLARE EXTERNAL FUNCTION P
INPUT n,r
PRINT P(n,r)
END
EXTERNAL FUNCTION P(n,r)
LET t=n
FOR k=1 TO r-1
   LET t=t*(n-k)
NEXT k
LET P=t
END FUNCTION

Internal subprograms (SUB - END SUB)

Example.

SUB double(x)
   LET x=2*x
END SUB
LET a=10
CALL double(a)
PRINT a
END

External subprograms (EXTERNAL SUB - END SUB)

Example.

DECLARE EXTERNAL SUB exchange
LET a=4
LET b=7
CALL exchange(a,b)
PRINT a,b
END
EXTERNAL SUB exchange(a,b)
LET t=a
LET a=b
LET b=t
END SUB

Internal picture definitions (PICTURE - END PICTURE)

Example.

PICTURE arrow
   PLOT AREA : 0,1; 0,-1; 10,-1; 10,-2; 14,0; 10,2; 10,1
END PICTURE
SET WINDOW -20,20,-20,20
DRAW arrow WITH ROTATE(PI/6)
END

External picture definitions (EXTERNAL PICTURE - END PICTURE)

Example.

DECLARE EXTERNAL PICTURE circle
SET WINDOW -4,4,-4,4
DRAW circle WITH SCALE(2)*SHIFT(0,2)
END
EXTERNAL PICTURE circle
OPTION ANGLE DEGREES
FOR t=0 TO 360
   PLOT LINES: COS(t),SIN(t);
NEXT t
END PICTURE

Statements

CALL-statements
DRAW-statements
DECLARE EXTERNAL-statements

Transform Functions

SHIFT(a,b)
ROTATE(θ)
SCALE(a,b)
SCALE(a)
SHEAR(θ)


Modules

MODULE - END MODULE
DECLARE EXTERNAL
PUBLIC
SHARE
MODULE OPTION

Note. These features are found in ANSI X3.113a-1989, modules and individual character input for Full BASIC.

Example.

DECLARE EXTERNAL SUB turtle.fd, turtle.rt
SET WINDOW -2,2,-2,2
FOR i=1 TO 30
   CALL fd(1)
   CALL rt(135)
NEXT i
END
! LOGO-like turtle graphics
MODULE turtle
MODULE OPTION ANGLE DEGREES
PUBLIC SUB fd, rt
SHARE NUMERIC curX, curY, direction
LET curX=0
LET curY=0
LET direction=90
EXTERNAL SUB fd(r)  ! Forward
   LET curX=curX+r*COS(direction)
   LET curY=curY+r*SIN(direction)
   PLOT LINES: curX, curY;
END SUB
EXTERNAL SUB rt(t)  ! Right Turn
   LET direction=direction - t
END SUB
END MODULE

Input and Output

INPUT
LINE INPUT
READ
READ IF MISSING
PRINT
PRINT USING

The array I/O is prepared. It deals with undefined length vectors.

MAT READ
MAT INPUT
MAT PRINT

The execution results of PRINT-statements are output to another window.
The number of lines are not limited. The whole can be seen by scrolling vertically or horizontally.
The output result can be printed, and be put on the clipboard by the menu selection.


Individual character input

CHARACTER INPUT
ASK CHARACTER PENDING

Note. These features are found in ANSI X3.113a-1989, modules and individual character input for Full BASIC.


Files

Concerning the files, Decimal BASIC implements only the core module.
Sequential display files, sequential internal files, and stream internal files are available.
Channels can become parameters of subprograms.
However, enhanced files such as RELATIVE or KEYED are not available.

OPEN
CLOSE
ERASE
WRITE
READ
SET MARGIN
SET ZONEWIDTH
SET POINTER
ASK-statements (MARGIN, ZONEWIDTH, POINTER, NAME, ACCESS, RECTYPE, ORGANIZATION, etc.)

Note. COM ports can be dealt as files on Windows version of Decimal BASIC .


Exception Handling

The structured exception handling provided by ISO Full BASIC is available.

WHEN EXCEPTION IN - USE - END WHEN
WHEN USE - END WHEN
HANDLER - END HANDLER
CAUSE EXCEPTION
EXIT HANDLER
CONTINUE
RETRY
EXTYPE-function
EXLINE-function

The mechanism that propagates the exception not processed in a procedure to the invoking statement is implemented.

Debugging

DEBUG ON/OFF
TRACE ON/OFF
BREAK


Graphics

Graphics with problem coordinates is available.

SET WINDOW
SET VIEWPORT
SET DEVICE WINDOW
SET DEVICE VIEWPORT
SET LINE COLOR
SET POINT COLOR
SET AREA COLOR
SET TEXT COLOR
SET COLOR MIX
SET LINE STYLE
SET POINT STYLE
SET TEXT JUSUTIFY
SET TEXT HEIGHT
SET TEXT ANGLE
ASK-statements (ASK WINDOW, ASK COLOR MIX , etc.)

PLOT LINES
PLOT POINTS
PLOT AREA
PLOT TEXT
GET POINT
MAT PLOT LINES
MAT PLOT POINTS
MAT PLOT AREA
MAT PLOT CELLS
GRAPH-statements (GRAPH POINTS, GRAPH LINES, GRAPH AREA, GRAPH TEXT, etc.)
ASK PIXEL VALUE
ASK PIXEL ARRAY
ASK PIXEL SIZE
CLEAR
LOCATE CHOICE
LOCATE VALUE
MAT GET POINT

Picture definitions and DRAW-statements
Transform functions

SHIFT(a,b)Translation
SCALE(a,b)Scaling
SCALE(a)Scaling
ROTATE(a)Rotation
SHEAR(a)Shear
Projective transformations can be performed when 4×4 matrices are specified.

Following four statements are found in Appendix F of ANSI Full BASIC.
SET AREA STYLE
SET AREA STYLE INDEX
ASK AREA STYLE
ASK AREA STYLE INDEX

The coordinates at the mouse cursor position are displayed under the graphics output window based on the SET WINDOW executed at the end.
A graphic output can be printed, and be put on the clipboard by menu selection.

The output destination of the graphics can be chosen from four ( bitmap (screen display), metafile (size specification), metafile (refer to the printer), and the printer).
LOCATE POINT, GET POINT, MAT LOCATE POINT, MAT GET POINT are available only for bitmap.


Original enhancement

The operating numerical values can be selected from the following five modes

1) Decimal 15-digit mode (ISO). Decimal numbers are accurate. All supplied functions are available.

2) Decimal 1000-digit mode. Decimal numbers up to 1000-digits are accurate. Four operations , integer-powers and the operation of square root are available.

3) Binary about 16-digit mode. It calculates at high speed by using a binary operation of FPU. All built-in functions can be used.

4) Complex number mode. It acts just like 16-digit binary mode except that the domains of some built-in functions are enhanced.

5) Rational number mode. Four arithmetic operations, INTSQR, and GCD etc. are available in this mode. No upper bound of the number of digits. (It is possible to calculate as long as there are rest memories).


Complex number mode

The domains of ABS(z), SQR(z), EXP(z), and LOG(z) are enhanced to the complex numbers.

The following built-in functions are added.

COMPLEX(x,y) 
RE(z)        
IM(z)        
ARG(z)      
CONJ(z)      

Transform functions SCALE and SHIFT are extended to complex numbers to deal with complex transformation


Rational numbers

In the rational number mode, multi byte precision rational operation is executed.

The following built-in functions are only for the rational number mode.

INTSQR(x) 
NUMER(x)   
DENOM(x)   
GCD(x,y)   

Syntax

There are 3 modes of Syntax: Standard (ISO Full BASIC), Obsolete minimal BASIC, and Microsoft compatible.

Microsoft Compatible mode allows following syntax.
Omission of LET in a LET-statement
Multi-statements
Nested if-statements, for example, IF a=8 THEN IF b=1 THEN b=0 ELSE a=0
Omission of NEXT-variable
INPUT "string"; variable
PRINT USING "format";(semicolon)
LPRINT
Unary minus in a numeric expression, for example, A^-2, A*-B
MOD-operator and \-operator, for example, 15 MOD 7, 15 \ 7
+ for string concat operator, for example, s$ + "12"
A Comparison is dealt as a numerical operation with -1 for truth and 0 for false.
AND, OR, NOT operations are dealt as bitwise operation for 32-bit integers.
Conditions written in numeric expressions, for example, IF A+5 THEN GOTO 120
' for comment
Some of graphics commands (WINDOW, PSET, LINE, COLOR, SCREEN, CLS, CIRCLE, PAINT)
RANDOMIZE seed

Automatic correction

The mechanism of rewriting programs written in Microsoft syntax is prepared.

Programs executable in Microsoft compatible mode excluding shown below can be automatically corrected.

Numerical expression written as a condition.
Comparison or Logical expression written as a numerical expression
Variables followed by % , !, or #
LPRINT
Graphics commands

Miscellaneous Enhancements

Arithmetic Functions

FACT(x) the factorial of x
PERM(n,r) the number of permutations
COMB(n,r) the number of combinations (the binary coefficient)
ROUND(x) = ROUND(x,0)

String Functions

SUBSTR$(a$,m,n)
MID$(a$,m,n)
LEFT$(a$,n)
RIGHT$(a$,n)

These functions are defined as
DEF SUBSTR$(a$,m,n)=a$(m:n)
DEF MID$(a$,m,n)=a$(m:m+n-1)
and so on.

Statements

DIM s$(a numerical expression)
Full BASIC requires constant bounds on a DIM statement.
This is an enhancement, but is not recommended due to making incompatibles.

MAT REDIM
compatible with True BASIC

LOCAL
Declares local variables of inner procedures. Compatible with True BASIC.

Matrix

MAT C=CROSS(A,B)
The outer product of A and B, where A, B, C are 1-dimensional array of size 3.

Graphics

Predefined pictures


DRAW GRID
DRAW GRID(p,q)
DRAW AXES
DRAW AXES(p,q)
DRAW GRID0
DRAW AXES0
DRAW circle
DRAW disk

Graphics Commands

PLOT LABEL ,AT x,y: string-expression
Similar to PLOT TEXT, except no changing the text size nor text directions on transformation.

MOUSE POLL x,y,left,right
Gets real-time mouse status.

SET BEAM MODE "IMMORTAL"
The beam shall NOT be cut off even if any graphics input or output statement except PLOT LINES or GRAPH LINES be executed.

SET BEAM MODE "RIGOROUS"
The beam shall be cut off according to the ANSI or ISO standard.

SET TEXT FONT fontname$ ,size
Specifies the size in points

SET BITMAP SIZE width,height
Specifies width and height in pixels (valid only on the Bitmap graph mode)

FLOOD x,y
Compatible with True BASIC

PAINT x,y
Functionally equivalent to PAINT command of Microsoft BASIC.

SET COLOR MODE "NATIVE"
Color indices become equal to Windows Color numbers.
A color index can be obtained with function COLORINDEX(r,g,b).

SET COLOR MODE "REGULAR"
Return to the regular mode of this BASIC.

SET DRAW MODE HIDDEN
Graphics drawing shall be done implicitly.

SET DRAW MODE EXPLICIT
Return regular graphics mode.

SET DRAW MODE NOTXOR
SET DRAW MODE OVERWRITE


SET AREA STYLE "SOLID"
SET AREA STYLE "HOLLOW"
SET AREA STYLE "HATCH"

SET AREA STYLE INDEX hatch_sytle_index

hatch_style_index must be an integer in the range from 1 to 6.

Functions

PIXELX(x) problem coordinate to pixel coordinate
PIXELY(y)
PROBLEMX(x) pixel coordinate to problem coordinate
PROBLEMY(y)
COLORINDEX(r,g,b)

Real-Time

The Following Statement and functions are defined in the real-time module of Full BASIC, while Decimal BASIC does not implement Real-Time module.

Statement

WAIT DELAY numeric-expression
numeric-expression indicates delaying time in seconds.

Functions

BVAL(string-expression,2)
BSTR$(numeric-expression,2)
BVAL(string-expression,16)
BSTR$(numeric-expression,16)

Others


Back

inserted by FC2 system