˲ ˲:
  • -
  • ³
  • ij
  • ,
  • '
  • '
  • ˳
  • , '
  • ̳
  • ̳
  • ̳
  • ,
  •  
     

     

     

     

     

     

         
     
    Turbo Basic
         

     












    - 4 -

    1. Ͳ

    1.1.

    .
    , . ,
    a = 1: b = 1
    . -
    _. ,
    a = 1: b_
    = 1
    ( ').
    .
    _. ,
    - . ϳ -
    . ,
    aaa:
    x = x +1
    ...
    GOTO aaa
    ( '),
    .
    _. A Z ( a z), -
    _ 0 9, . -
    , ,

    1.2.

    ֳ ( -32767 32767, 2 ); -
    ( 2 5-31 0 2 531 0, 4 ); (4 ); -
    (8 ); (-
    - , 1 ).
    _ҳ . , -
    .
    .
    a $ -
    a% -
    a & -


    - 5 -
    a! -
    # -
    , -
    .
    a! = 1.1

    = 1.1
    .

    1.3.

    _ . DIM
    . ,
    DIM a (10), b (10:20, 25:45)
    a,
    0 10, b, :
    10 20, 25 45.
    ,
    0.
    _OPTION BASE n., -
    n. ,
    OPTION BASE 1
    DIM a (10)
    a 2 0 -
    , 1. ,
    10 ( - 0).
    . ,
    DIM a (n)
    n .
    _ ERASE., ', -
    , . -
    г,
    ERASE a
    ', a.

    1.4.

    _ѳ . (-
    , ), -


    - 6 -
    , , ' + (,
    '). ,
    a $ = ""
    b $ = ""
    f $ = a $ + "" + b $
    f $ " ".
    LEFT $, RIGHT $, MID $ -
    , . ,
    F1 $ = LEFT $ (f $, 4)
    F2 $ = RIGHT (f $, 4)
    F3 $ = MID $ (f $, 6,1)
    F1 $ = "", F2 $ = "" F3 $ = "".
    _׳ . , ,
    , ,
    .
    _. :
    1. ϳ (^)
    2. , (*, /)
    3. ij () (, 52 2)
    4. (MOD) (, 45 MOD 19
    7)
    5. , (+,-)< br />
    1.5.


    ABS (x)? X?
    SIN (x) sin x
    COS (x) cos x
    TAN (x) tg x
    ATN (x) arctg x
    EXP (x) e 5x
    LOG (x) ln x
    LOG2 (x) log 42 0x
    LOG10 (x) lg x
    INT (x)
    SGN (x) (1 > 0,
    0 = 0, -1 x <0)>
    SQR (x)


    - 7 -
    LEN ( $) $
    LEFT $ (a $, n) a $ n ,

    MID $ (a $, m, n) a $ n ,
    m-
    RIGHT $ (a $, n) n $,

    STR $ (x)

    VAL (a $) $
    ASC (a $)
    $
    TAB (n)

    PRINT
    SPC (n) n ,
    PRINT
    RND [(x)] -
    (0,1)
    . 1. [] ' .
    2. = 0, ;
    <0, x 2 0 >
    ; x> 0 , -
    , -
    . RANDOMIZE (
    RND), -
    .
    _ ³.:,> =,.
    ˳ -
    ( -
    ). ( ),
    -1, ( ),
    0. -
    . ,
    PRINT 5> 6, 5 <6, (5 <6) * 15>
    0, -1 -15.
    _ .: AND ( ), OR (
    ), XOR ( ), EQV (), IMP (-
    ).


    - 8 -
    -1
    (TRUE) 0 (FALSE).
    -1, A = -1, B = -1
    A AND B 0,

    0, A = 0, B = 0
    A OR B -1,

    -1, A B
    A XOR B 0, A B

    -1, A B
    A EQV B 0, A B

    0, A = -1, B = 0
    A IMP B -1,

    1.6.

    _ .
    1 0 = 1
    _ .
    GOTO 1
    _ .
    IF 1 0 THEN 1 0 [ELSE 1 0]
    ,
    IF a
    ,
    FALSE, 0, TRUE,
    0.
    THEN ELSE
    , _IF .,

    IF 1 0 THEN
    1
    ELSE
    1
    END IF
    ELSE , -


    - 9 -

    IF 1 0 THEN
    1
    END IF
    ELSE , -
    ELSEIF
    IF 1 0 THEN
    1
    ELSEIF 1 0 THEN
    1
    ELSE
    1
    END IF
    _ ʳ END.
    . . -
    IF, SUB, DEF, SELET (.)
    _ CLS.
    .
    _ INPUT.
    INPUT [;] [1 0], 1
    . -
    . ";" ϳ INPUT , -
    , "".
    _ PRINT.
    PRINT [1 0]
    "," ";" .
    (
    5 14 ), -
    - ( ) (
    ) .
    ' , (-
    ) ( -
    ).
    _ PRINT USING.
    PRINT USING 1 0; 1
    ( -
    ),
    : # - , ^ ^ ^ ^ -
    . .


    - 10 -
    1,
    ##.## - 2
    - . ,
    %.
    #. # # ^ ^ ^ ^ - -
    .
    :
    "1 0" - ( ) -
    "" 1 0 - ( ) -

    + 2.
    "!" 1 0 -
    "&" 1 0 - 1 0
    ,
    A $ = "": GA = 6.5
    B $ = "": GB = 15.3
    PRINT USING "& #. #, # #. # "; A $, GA, B $, GB
    '
    6.5, 15.3
    _
    LOCATE i, j
    ( i j), -
    PRINT.

    1.7.

    1. FOR i = i 4 0 to i 4 0 [STEP ih]
    1
    NEXT i
    i, i 4 0, i 4 0, ih - ,
    , , .
    ih = 1, . ,
    FOR i = 1 to 10
    ....< br /> NEXT i
    FOR i = 1 to 10
    FOR j = 1 to 20
    ....< br /> NEXT j: NEXT i


    - 11 -

    FOR i = 1 to 10
    FOR j = 1 to 20
    ....< br /> NEXT j, i
    2. DO WHILE 1
    1
    LOOP

    WHILE 1
    1
    WEND
    ( 1, 0 )
    3. DO UNTIL 1
    1
    LOOP
    ( , -
    ⳺. ,
    ).
    4. DO
    1
    LOOP
    EXIT.

    _ EXIT. 1 (0) SELECT, DEF, FOR, IF,
    LOOP, SUB, WHILE. ,
    EXIT FOR , -
    FOR/NEXT
    EXIT IF - - IF
    EXIT LOOP - , LOOP
    WEND.
    EXIT
    .
    _ . ON/GOTO ON/GOSUB
    ON n GOTO 1 0 [, 1 0 ...]< br /> n 0 255.
    , n. , n = 2 -
    . n = 0 n -
    , -


    - 12 -
    .
    ON n GOSUB 1 0 [, 1 ...]< br 0 /> n 0 255.
    (.), -
    , n.
    ϳ -
    , ON/GOSUB.

    1.8. ϳ,

    _. - , -
    RETURN. ,
    GOSUB.
    ....< br /> GOSUB aa
    ....< br /> END
    aa:
    1
    RETURN
    RETURN ,
    GOSUB.
    _. (--
    ) (-).
    DEF FN 1 0 [(1 0)] = 1
    ( -) 1.
    1 0 16 .
    DEF FN 1 0 [(1 0)]
    1
    1
    [EXIT DEF]
    ....< br /> [FN 1 0 = 1 0]
    END DEF
    ( -) 1.
    , -
    . .
    1,
    DEF FNF (x, y) = x * x + y * y


    - 13 -
    a = 3: b = 4
    P = FNF (a, b)

    P = FNF (3,4)
    , -
    . -
    ( ). ,
    F = FNa (1.5)
    PRINT F
    DEF FNa (x)
    FNa = x * x
    END DEF
    END

    F = FNa (1.5)
    PRINT F
    END
    DEF FNa (x)
    FNa = x * x
    END DEF
    2.25.
    -
    .
    _. - , -
    SUB END SUB -
    CALL.
    SUB 1 0 [(1 0)]
    1
    1
    [EXIT SUB]
    END SUB
    ' 31 . (
    16) .
    . , 1 -
    , 2 - ..
    ' -
    . ,
    SUB SUM (x (1), n, S)
    S = 0


    - 14 -
    FOR I = 1 to n
    S = S + x (I)
    NEXT I
    END SUB
    DIM A (3)
    A (1) = 1: A (2) = 2: A (3) = 4
    CALL SUM (A (), 3, S)
    S = S/3
    PRINT S
    END
    A,
    SUM .
    -:
    1 - ' , ;
    2 - CALL, .
    , ( -
    -), , -
    ( LOCAL), ,
    , (-
    SHARED) , -
    LOCAL, -
    ( STATIC). --
    SHARED, STATIC.
    DEF FNF1
    LOCAL i, S
    FOR i = 1 to 10
    S = S + i
    NEXT i
    FNF1 = S
    END DEF
    ϳ - i S
    ( S = 0). ֳ
    .
    DEF FNF2
    LOCAL i
    SHARED S
    FOR i = 1 to 10
    S = S + i
    NEXT i


    - 15 -
    FNF2 = S
    END DEF
    S
    .
    DEF FNF3
    LOCAL i
    STATIC S
    FOR i = 1 to 10
    S = S + i
    NEXT i
    FNF3 = S
    END DEF
    S
    , -
    FNF3 55, - 110 .. (S
    ).

























    - 16 -

    2. ˲ Բ

    , -
    ( -
    ) . x,
    y; x - ( 0 319 639 -
    ), y - ( 0 199
    349 ). 0,0 -
    .
    ( ) _-
    _ SCREEN ..
    SCREEN i [, j]
    i = 0, j = 0 -
    i = 0, j = 1
    i = 1, j = 0 -
    (320 , 200 )
    i = 1, j = 1 - -

    i = 2 - -
    (640 , 350 -
    )
    ϳ SCREEN
    .
    _ COLOR. 2 0 (
    ) ( -
    ).
    : 0 1, :
    _ 0. _ 1
    1 - 1 -
    2 - 2 -
    3 - 3 -
    16 (0 - , 1 - ,
    2 - , 3 - , 4 - , 5 - , 6 - -
    , 7 - , 8 - , 9 - , 10 - -, 11 -
    -, 12 - -, 13 - -, 14 - -
    , 15 - -)
    COLOR 2 0
    COLOR 2 0i, 2 0j [, k]


    - 17 -
    i - , j - , k - .
    ,
    SCREEN 1,0
    COLOR 9,0

    ; - ;
    0- .
    (
    ) :
    PSET 2 0 (PRESET) - ( ) ; LINE 2 0 - -
    ; CIRCLE 2 0 - ; PAINT 2 0 - -
    .

    (DRAW, GET, PUT) .4.

    PSET (x, y)
    x, y.

    PSET STEP (x, y)
    , x y -
    . ,
    (60, 75),
    PSET (10, 20) (10, 20),

    PSET STEP (10, 20) (70, 95).

    PSET (x, y), 0

    PRESET 2 0 (x, y)
    (x, y) .
    LINE 2 0 ,
    (x1, y1), (x2, y2) k
    LINE 2 0 [(x1, y1)] 2 0 - 2 0 (x2, y2), 2 0k
    , , -
    , .
    LINE 2 0

    LINE (x1, y1) - (x2, y2), 2 0 [k], 2 0B [F]
    (x1, y1) (x2, y2)


    - 18 -
    . k ,
    3- .
    F . -
    ,
    LINE (80, 175) - (100, 25), 2, BF
    , 80- 100-
    175- 25- .
    _ CIRCLE. 2 0 , ,
    .
    CIRCLE 2 0 (x, 2 0y), 2 0r, k
    r (x, y) k.
    ϳ
    .
    CIRCLE (x, y), r, k, ALPHA1, ALPHA2
    , ALPHA1 -
    ALPHA2.
    , ( PI = 3.1416)
    CIRCLE (160, 100), 80, 2, PI/2, PI PI/2 PI -
    80 (160, 100)
    .
    "-" -
    , ,
    ' . ,
    CIRCLE (160, 100), 80, 2, - PI/2, - PI
    ( ) -
    , CIRCLE .
    1, -
    , 1, - . ,
    CIRCLE (160, 100), 80, 2,,, 3/4
    CIRCLE
    . ' ,
    . -
    ', , ,
    .
    _ PAINT. 2 0 .

    (x, y), , -
    (k1) , -
    (k2), k1 k2 . PAINT


    - 19 -
    PAINT (x, y), k1, k2
    ,
    PAINT (160, 100), 2, 2
    CIRCLE,
    , ,
    CIRCLE.



































    - 20 -

    3. .


    -
    , '
    (, ). .
    '. ' : '

    1 0. 1
    ' 8 , 1 - 0 .

    A - z 0 - 9 () () @ # $ 1 0% ^ &! - _/'~
    ' MS DOS
    . ,
    C: STLABwork.bas,
    C - ' , ST - ' , LAB - ' -
    ST, work.bas - ' .
    .

    3.1.

    ,
    , n- (n -
    1)- , .
    :
    ( OPEN), (
    PRINT #, WRITE #, PRINT # USING) (
    CLOSE).
    -
    : , ( INPUT #,
    INPUT $, LINE INPUT #), .
    _ OPEN. 2 0
    (INPUT) (OUTPUT, ,
    APPEND, ).
    INPUT
    OPEN 1 0FOR OUTPUT 1 0 AS # 1
    APPEND
    _ CLOSE. , -


    - 21 -
    .
    CLOSE [# 1 0]
    CLOSE .
    ,
    1, 0 ( ) 2. 0
    . ' .
    0 :
    1) ,
    (, ).
    WRITE #, -
    INPUT #.
    , -
    INPUT, -
    .
    _ INPUT #. 2 0
    INPUT # 1 0, 2 1

    .
    2) 1, 0 ,
    -
    . PRINT #,
    - INPUT $ LINE INPUT #. _
    _INPUT $. ()
    n , , ST $
    ST $ 2 = 0INPUT $ (n, # 1 0)
    _ LINE INPUT #. 2 0 ST $

    LINE INPUT # 1 0, 2 0ST $
    ( ):
    OPEN "SEQU.DAT" FOR OUTPUT AS # 1
    ST $ = ""
    INT% = 1972
    FLOT! = 75.3
    '
    WRITE # 1, ST $, INT%, FLOT!
    ST $ = ""
    INT% = 1975
    FLOT! = 62.5
    '


    - 22 -
    WRITE # 1, INT%, ST $, FLOT!
    CLOSE # 1
    END

    "", 1972, 75.3
    1975, "", 62.5
    :
    OPEN "SEQU.DAT" FOR INPUT AS # 1
    ST $ = ""
    INT% = 0
    FLOT! = 0
    '
    INPUT # 1, ST $, INT%, FLOT!
    PRINT ST $, INT%, FLOT!
    ST $ = ""
    INT% = 0
    FLOT! = 0
    '
    INPUT # 1, INT%, ST $, FLOT!
    PRINT INT%, ST $, FLOT!
    CLOSE # 1
    END
    ( ):
    OPEN "SEQUEN.DAT" FOR OUTPUT AS # 1
    ST $ = ""
    INT% = 1972
    FlOT! = 73.1
    '
    PRINT # 1, ST $, INT%, FLOT!
    ST $ = ""
    INT% = 1975
    FLOT! = 64.3
    ' ,
    PRINT # 1, USING "+####$#.##^^^^"; INT%, ST $, FLOT!
    CLOSE # 1
    END
    :
    1972 73.1
    1975 6.43 01


    - 23 -
    :
    OPEN "SEQUEN.DAT" FOR INPUT AS # 1
    ST $ = ""
    ST $ = INPUT $ (80, # 1)
    PRINT ST $
    LINE INPUT # 1, ST $
    PRINT ST $
    CLOSE # 1
    END

    3.2.

    ,
    .
    :
    ( OPEN); ,
    ( FIELD);
    ( LSET 2 0 RSET);
    ( PUT), PUT 2 0
    , ,
    1,
    ; -
    ( CLOSE).
    .

    .
    -
    .
    MKI $ (MKL $) - ( ) 2- (4-)
    ;
    MKS $ (MKD $) - ( )
    4- (8-) .
    CVI (CVL) - 2- (4-) ( -
    );
    CVS (CVD) - 4-x (8-) (-
    ).
    ' -
    : ; ;
    ( GET); (


    - 24 -
    ); .

    ,
    .
    _ OPEN. 2 0
    OPEN 2 1 2 0AS # 1 2 0LEN 2 0 = 1
    ( ,
    ).
    _ FIELD. 2 0
    FIELD # 2 1 0, 2 0n1 2 0AS 2 11 0 [2, 0n2 2 0AS 2 12 0, 2 0 ...] 2 0,
    n1, n2, ... - 11 0, 12 0,
    ... (11 0, 12 0, - ).
    _. _LSET, RSET. 2 0
    LSET 2 1 2 0 = 2 1
    RSET 2 1 2 0 = 2 1
    LSET (RSET)
    ( LSET - , RSET - , -
    ).
    _ PUT.
    PUT 2 0 # 2 1 2 0 [2, 1 0]
    -
    ( , ).
    _ GET. 2 0
    GET 2 0 # 2 1 2 0 [, 2 1 2 0]
    -
    ( , ).
    ,
    :
    N / г
    n%, nam $, dat%; -
    np $ (2 ), nm $
    (10 ), dt $ (6 ).
    OPEN "GSR.DAT" AS # 1 LEN = 18
    FIELD # 1, 2 AS np $, 10 AS nm $, 6 AS dt $
    FOR i% = 1 to 3
    INPUT n%, nam $, dat%
    LSET np $ = MKI $ (n%)
    LSET nm $ = nam $
    LSET dt $ = MKI $ (dat%)


    - 25 -
    PUT # 1, i%
    NEXT i%
    CLOSE # 1
    END
    GSR.DAT
    .
    OPEN "GSR.DAT" AS # 1 LEN = 18
    FIELD # 1, 2 AS np $, 10 AS nm $, 6 AS dt $
    FOR i% = 3 to 1 STEP -1
    GET # 1, i%
    n% = CVI (np $)
    dat% = CVI (dt $)
    PRINT n%, nm $, dat%
    NEXT i%
    CLOSE # 1
    END

























    - 26 -

    4. , ,


    4.1. DRAW

    DRAW ()
    (), Un, Dn, Ln, Rn
    n (U),
    (D), (L) (R); En, Fn, Gn, Hn
    n (E), (F),
    (G), (H); M h, V
    h V; M 7 + 0h, 7 + 0V h
    (+) (-) V (+)
    (-). , An n, n = 0
    (0 ), 1 (90 ), 2 (180 ) 3 (270 -
    ); TAn - n, n -360 360
    . n> 0 ,
    n
    ; Sn - n/4, n 1
    255 ( n = 4); B -
    (
    , -
    ); N
    .
    ,
    , DRAW.
    ,
    DRAW "M 160, 100"
    (160, 100),
    ?? .
    DRAW "BM160, 100"
    , .
    DRAW "L10 U10 R10 D10"
    10 , 10 ,
    10 10 , .
    , , '
    .
    DRAW "BM 180, 20 NU10 ND10 NL10 NR 10"


    - 27 -
    (180, 20),
    ( +).
    DRAW
    (. ), , -
    ( -
    ), -
    DRAW. ,
    SQAR $ = "L10U10R10D10"
    DRAW SQAR $
    n, k, V ,
    DRAW, .
    VARPTR $. ,

    DRAW "E15"

    a = 15
    DRAW "E =" + VARPTR $ (a)
    .
    I% = 1
    DRAW "M =" + VARPTR $ (I%) + ", 40"

    DRAW "M = 1, 40"
    ( I%)
    DRAW , ,
    .
    . DRAW -
    ( SCREEN).

    4.2. GET PUT

    GET PUT -
    .
    GET
    '. PUT , -
    GET, -
    , .
    GET '
    , . GET



    - 28 -
    GET (x1, y1) - (x2, y2), B
    (x1, y1), (x2, y2) -
    ' , B - ' ,
    .
    , (
    ), '
    . n1
    n2
    N
    N = 4 + INT ((n1 * 2 +7)/8) * n2

    N = 4 + INT ((n1 + 7)/8) * n2
    (
    ) INT ((N + 1)/2).
    PUT , -
    GET - ,
    (x, y).
    PUT (x, y), B

    4.3. BEEP

         
     
         
     
     
     

     

     

     

     

     

     

     
     
     
      . Reff.net.ua - ! DMCA.com Protection Status