- 陶小凡
-
QBASIC - Statements
命令:
BEEP, BLOAD, BSAVE, CALL, CHAIN, CHDIR, CIRCLE, CLEAR, CLOSE, CLS, COLOR, COM, COMMON, CONST, DATA, DATE$, DECLARE, DEF, DEFDBL, DEFINT, DEFLNG, DEFSNG, DEFSTR, DIM, DO, DRAW, END, ENVIRON, ERASE, ERROR, EXIT, FIELD, FILES, FOR, FUNCTION, GET, GOSUB, GOTO, IF, INPUT, IOCTL, KEY, KILL, LET, LINE, LINE INPUT, LOCATE, LOCK, LPRINT, LSET, MID$, MKDIR, NAME, ON, OPEN, OPTION, OUT, PAINT, PALETTE, PCOPY, PEN, PLAY, POKE, PRESET, PRINT, PSET, PUT, RANDOMIZE, READ, REDIM, REM, RESET, RESTORE, RESUME, RETURN, RMDIR, RSET, RUN, SCREEN, SEEK, SELECT CASE, SHARED, SHELL, SLEEP, SOUND, STATIC, STOP, STRIG, SUB, SWAP, SYSTEM, TIME$, TROFF, TRON, TYPE, UNLOCK, VIEW, WAIT, WHILE, WIDTH, WINDOW, WRITE
程序:
CALL
CHAIN
DECLARE
END
OPTION
REM
RUN
STOP
事件:
ON
SLEEP
WAIT
结构:
DO
ERROR
EXIT
FOR
FUNCTION
GOSUB
GOTO
IF
RESUME
RETURN
SELECT CASE
SUB
WHILE
数据
CLEAR
COMMON
CONST
DATA
DEFDBL
DEFINT
DEFLNG
DEFSNG
DEFSTR
DIM
ERASE
INPUT
LET
MID$
RANDOMIZE
READ
REDIM
RESTORE
SHARED
SWAP
STATIC
TYPE
Pen
PEN
Joystick
STRIG
Keyboard
INPUT
KEY
LINE INPUT
Screen
CLS
COLOR
LOCATE
PALETTE
PCOPY
PRINT
SCREEN
VIEW
WIDTH
WINDOW
Printer
LPRINT
WIDTH
Graphics
CIRCLE
DRAW
GET
LINE
PAINT
PRESET
PSET
PUT
Sound
BEEP
PLAY
SOUND
Memory
BLOAD
BSAVE
CLEAR
DEF
DEF SEG
POKE
File
CLOSE
KILL
NAME
OPEN
RESET
Sequential file
INPUT
LINE INPUT
PRINT
WRITE
Random file
FIELD
GET
LOCK
LSET
PUT
RSET
SEEK
UNLOCK
Binary file
BLOAD
BSAVE
Directory
CHDIR
MKDIR
RMDIR
System
COM
ENVIRON
IOCTL
OUT
SHELL
SYSTEM
Date & Time
DATE$
TIME$
Debug
TROFF
TRON
BEEP
Sounds the speaker at 800 Hz for 1/4 second.
PRINT CHR$(7) also beeps
CIRCLE
>SCREEN 1: CIRCLE
CLOSE
Close an open file
>OPEN
DATA
>maskinkode: array
DEF
DEF SEG
Sets the current segment address.
DEF SEG [=address]
address A segment address used by BLOAD, BSAVE, CALL ABSOLUTE, PEEK, or POKE
- a value in the range 0 - 65535.
If address is omitted, DEF SEG resets the current segment address to the default data segment.
Example:
DEF SEG = 0
Status% = PEEK(&H417)
POKE &H417, (Status% XOR &H40)
DEF SEG
Read keyboard status.
Change Caps Lock state, bit 6.
Reset segment address.
>maskinkode: array
DIM
DIM declares an array or specifies a data type for a nonarray variable.
>REDIM, $DYNAMIC, $STATIC
DIM [SHARED] variable[(subscripts)] [AS type][, variable[(subscripts)] [AS type]]...
SHARED Specifies that variables are shared with all SUB or FUNCTION procedures in the module.
subscripts Dimensions of the array, expressed as follows:
[lower TO] upper [, [lower TO] upper]...
lower The lower bound of the array"s subscripts.
The default lower bound is zero.
upper The upper bound.
>OPTION BASE
AS type Declares the data type of the array or variable:
INTEGER A 16-bit signed integer variable
LONG A 32-bit signed integer variable
SINGLE A single-precision 32-bit floating-point variable
DOUBLE A double-precision 64-bit floating-point variable
STRING * n% A fixed-length string variable n% bytes long
STRING A variable-length string variable
DIM i%
DIM i AS INTEGER
DIM s AS STRING * 20
DIM a(4) AS SINGLE "5 numbers (0 to 4)
DRAW
> SCREEN 1: DRAW
GET
>GET [File I/O]
>GET [Graphics]
IF...THEN...ELSE
IF condition THEN statements [ELSE statements]
IF condition THEN
statements
[ELSEIF condition THEN
statements]...
[ELSE
statements]
END IF
KEY
>KEY [Assignment]
>KEY [Event Trapping]
LINE (Graphics)
> SCREEN 1: LINE
LOCATE
> SCREEN 0: LOCATE (show/hide/define cursor)
LPRINT
> Printer: LPRINT
> PRINT
MID$
The MID$ statement replaces part of a string variable with another string.
MID$(stringvariable$,start%[,length%])=stringexpression$
stringvariable$ The string variable being modified.
start% The position of the first character in the substring being replaced.
length% The number of characters in the substring. If the length is omitted, MID$ replaces all characters to the right of the start position.
stringexpression$ The replacement string. It can be any string expression.
Ex:
Text$ = "Paris, France"
PRINT Text$
MID$(Text$, 8) = "Texas "
PRINT Text$
Paris, France
Paris, Texas
>Function: MID$()
PAINT
> SCREEN 1: PAINT
PALETTE
> SCREEN 1: PALETTE
PLAY
> Sound: PLAY
> SOUND
> PLAY (Event Trapping)
POKE
> DEF SEG
> SCREEN 0: POKE (attributes and chars)
> PEEK()
PRESET
> PSET
> SCREEN 1: PRESET
PSET
> PRESET
> SCREEN 1: PSET
PUT
>PUT (File I/O)
>PUT (Graphics)
>GET
RANDOMIZE [seed]
Benytter "seed" til at danne en ny start p? den sekvens af "tilf?ldige" tal, som RND() returnerer.
Med en fast seed-v?rdi kan man sikre, at den tilf?ldige sekvens altid er den samme:
RANDOMIZE 124
FOR i = 1 TO 4
PRINT RND
NEXT
.2441675
.214439
.6458486
.7624476
Hvis talsekvensen skal v?re "rigtig tilf?ldig" benyttes
RANDOMIZE TIMER
der benytter maskines aktuelle tid som seed.
REDIM
REDIM declares or resizes a dynamic array, erasing any previous values.
REDIM [SHARED] variable[(subscripts)] [AS type][, variable[(subscripts)] [AS type]]...
>DIM
SOUND
> Sound: SOUND
> PLAY
SYSTEM
Lukker alle ?bne filer og returnere til operativsystemet (DOS)
VIEW
Definerer et omr?de af en grafik-sk?rm ("viewport") - grafik (men ikke tekst) bliver begr?nset til dette omr?de.
VIEW Uden parametre nulstiller en defineret Viewport - s? hele sk?rmen benyttes til grafik.
Grafikkoordinater er relative til en defineret Viewport - men:
VIEW SCREEN ... benytter absolutte koordinater.
CLS rydder kun det indre af en Viewport.
VIEW [[SCREEN] (x1!,y1!)-(x2!,y2!) [,[color%] [,border%]]]
SCREEN Specifies that coordinates are relative to the
screen rather than the viewport.
(x1!,y1!)-(x2!,y2!) The coordinates of diagonally opposite corners
of the viewport.
color% A color attribute that sets the viewport fill
color. Depends on Screen mode.
border% A color attribute that sets the viewport border
color. Depends on Screen mode.
F?lgende to rutiner (uden og med SCREEN) giver samme resultat (bem?rk parametrene til CIRCLE):
SCREEN 1
VIEW (80, 80)-(160, 120), , 1
LOCATE 13, 13: PRINT "A viewport";
CIRCLE (25, 20), 30
SCREEN 1
VIEW SCREEN (80, 80)-(160, 120), , 1
LOCATE 13, 13: PRINT "A viewport";
CIRCLE (105, 100), 30
et udsnit af sk?rmen:
view1.gif (1722 bytes)
SCREEN 1
VIEW (80, 80)-(160, 120), 2, 1
LOCATE 13, 13: PRINT "A viewport";
CIRCLE (25, 20), 30
view2.gif (1904 bytes)
WHILE...WEND
WHILE
"statements
WEND
Wait for any key:
WHILE Inkey$="": WEND
WIDTH
> SCREEN
- 我不懂运营
-
QBASIC
-
Statements
命令:
BEEP,
BLOAD,
BSAVE,
CALL,
CHAIN,
CHDIR,
CIRCLE,
CLEAR,
CLOSE,
CLS,
COLOR,
COM,
COMMON,
CONST,
DATA,
DATE$,
DECLARE,
DEF,
DEFDBL,
DEFINT,
DEFLNG,
DEFSNG,
DEFSTR,
DIM,
DO,
DRAW,
END,
ENVIRON,
ERASE,
ERROR,
EXIT,
FIELD,
FILES,
FOR,
FUNCTION,
GET,
GOSUB,
GOTO,
IF,
INPUT,
IOCTL,
KEY,
KILL,
LET,
LINE,
LINE
INPUT,
LOCATE,
LOCK,
LPRINT,
LSET,
MID$,
MKDIR,
NAME,
ON,
OPEN,
OPTION,
OUT,
PAINT,
PALETTE,
PCOPY,
PEN,
PLAY,
POKE,
PRESET,
PRINT,
PSET,
PUT,
RANDOMIZE,
READ,
REDIM,
REM,
RESET,
RESTORE,
RESUME,
RETURN,
RMDIR,
RSET,
RUN,
SCREEN,
SEEK,
SELECT
CASE,
SHARED,
SHELL,
SLEEP,
SOUND,
STATIC,
STOP,
STRIG,
SUB,
SWAP,
SYSTEM,
TIME$,
TROFF,
TRON,
TYPE,
UNLOCK,
VIEW,
WAIT,
WHILE,
WIDTH,
WINDOW,
WRITE
程序:
CALL
CHAIN
DECLARE
END
OPTION
REM
RUN
STOP
事件:
ON
SLEEP
WAIT
结构:
DO
ERROR
EXIT
FOR
FUNCTION
GOSUB
GOTO
IF
RESUME
RETURN
SELECT
CASE
SUB
WHILE
数据
CLEAR
COMMON
CONST
DATA
DEFDBL
DEFINT
DEFLNG
DEFSNG
DEFSTR
DIM
ERASE
INPUT
LET
MID$
RANDOMIZE
READ
REDIM
RESTORE
SHARED
SWAP
STATIC
TYPE
Pen
PEN
Joystick
STRIG
Keyboard
INPUT
KEY
LINE
INPUT
Screen
CLS
COLOR
LOCATE
PALETTE
PCOPY
PRINT
SCREEN
VIEW
WIDTH
WINDOW
Printer
LPRINT
WIDTH
Graphics
CIRCLE
DRAW
GET
LINE
PAINT
PRESET
PSET
PUT
Sound
BEEP
PLAY
SOUND
Memory
BLOAD
BSAVE
CLEAR
DEF
DEF
SEG
POKE
File
CLOSE
KILL
NAME
OPEN
RESET
Sequential
file
INPUT
LINE
INPUT
PRINT
WRITE
Random
file
FIELD
GET
LOCK
LSET
PUT
RSET
SEE
查看原帖>>