Documente Academic
Documente Profesional
Documente Cultură
4 Outline
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
All numeric built-in functions that ANSI Full BASIC provides are prepared.
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.
Built-in functions
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
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
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
Example.
SUB double(x)
LET x=2*x
END SUB
LET a=10
CALL double(a)
PRINT a
END
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
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
Statements
CALL-statements
DRAW-statements
DECLARE EXTERNAL-statements
Transform Functions
SHIFT(a,b)
ROTATE()
SCALE(a,b)
SCALE(a)
SHEAR()
Modules
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
LINE INPUT
READ
READ IF MISSING
PRINT
PRINT USING
MAT READ
MAT INPUT
MAT PRINT
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
Debugging
DEBUG ON/OFF
TRACE ON/OFF
BREAK
Graphics
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
SHIFT(a,b) Translation
SCALE(a,b) Scaling
SCALE(a) Scaling
ROTATE(a) Rotation
SHEAR(a) Shear
Projective transformations can be performed when 44 matrices are specified.
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.
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).
The domains of ABS(z), SQR(z), EXP(z), and LOG(z) are enhanced to the
complex numbers.
Rational numbers
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.
Automatic correction
Arithmetic Functions
String Functions
SUBSTR$(a$,m,n)
MID$(a$,m,n)
LEFT$(a$,n)
RIGHT$(a$,n)
Statements
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
Functions
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