⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 bb.doc

📁 basic interpreter for learning
💻 DOC
📖 第 1 页 / 共 5 页
字号:
                 LOOP

                 I=0
                 DO
                   PRINT I
                   I=I+1
                 LOOP WHILE I<6
                                      26





                  Copyright (c) 1992, 1993 by Mark Davidsaver






                 I=0
                 DO
                   PRINT I
                   I=I+1
                 LOOP UNTIL I>3

            The EXIT DO statement may be used to exit from a
            DO..LOOP series of statements.  Here is an example:

                 I=0
                 DO WHILE I<20000
                   IF INKEY$<>"" THEN EXIT DO
                   PRINT I
                   I=I+1
                 LOOP



          END SUB

            This statement is used at the end of a SUB procedure.
            See the CALL statement for an example.



          EOF(filenumber)

            This function tests for end-of-file.



          EXIT DO

            Statement allows exit of a DO..LOOP series.  See the
            description of the DO statement for an explanation.



          EXIT FUNCTION

            Statement allows exit of a user Function.  See the
            description of the FUNCTION statement for more details.



          EXIT SUB

            Statement allows exit of a user Procedure.  See the
            description of the SUB statement for more details.



          FIELD #filenumber,fieldwidth AS stringvariable...
                                      27





                  Copyright (c) 1992, 1993 by Mark Davidsaver






            This statement allocates space for variables in
            random-access file buffer.  The filenumber is the number
            under which the file was opened.  Fieldwidth is a number
            indicating the length of the field and string variable
            is the name of the field.  Multiple fields can be
            defined at once.

               e.g.  OPEN "TEST.DAT" FOR RANDOM AS #1
                     FIELD #1,18 AS NAME$,18 AS ADDRESS$
                     LSET NAME$="FRED SMITH"
                     LSET ADDRESS$="1 MAIN STREET"
                     PUT #1,1
                     CLOSE #1



          FIX(numeric expression)

            This function returns the integer representation of the
            value in numeric expression.  -n.x returns n-1 if x>0.



          FONT(n)

            This function returns information about a Windows font.
            See the section CREATING FONTS for a complete
            description of this function



          FONT$(n)

            This function returns information about a Windows font.
            See the section CREATING FONTS for a complete
            description of this function.



          FOR..NEXT

          FOR counter=start TO end [STEP increment]

            Defines a program loop.

                FOR I%=1 TO 100
                  PRINT I%
                NEXT I%



          FREEMEM

                                      28





                  Copyright (c) 1992, 1993 by Mark Davidsaver





            This function returns the amount of global memory
            available to other programs.



          FUNCTION name,[(Paramenter list)]

            This statement starts a user defined function.  User
            defined functions can perform a series of instructions
            and then return a single value of type String, Float,
            Integer, or Long Integer.  A user defined function is
            used in an expression in the same way that a BasicBasic
            function is used.  Functions must be defined before they
            can be used. Typically all functions are defined at the
            start of a program.  They are not executed until called
            in an expression.

            name: The name of the function.  The name defines what
            type of value is returned from the function.  This name
            is assigned a value somewhere in the the function.

            parameter list: The list of variables that will be
            passed to the User Function.  Any changes to the
            parameters are not returned to the calling expression.

            Here is an example of a function which makes all
            characters in a string upper case.

               FUNCTION UPPER$(A$)
                 FOR I%=1 TO LEN(A$)
                  A%=ASC(MID$(A$,I%,1))
                  IF A%>=96 AND A%<=96+26 THEN
                    A%=A%-32
                    MID$(A$,I%,1)=CHR$(A%)
                  END IF
                 NEXT I%
                 UPPER$=A$
               END FUNCTION

               PRINT UPPER$("This will display in upper case.")


          The EXIT FUNCTION statement may be used to exit a function
          at any time.  You may not transfer control out of the
          function except with the END FUNCTION or EXIT FUNCTION
          statements.

          In this version of BasicBasic functions do not have access
          to common variables.



          GET (x1,y1)-(x2,y2),arrayname

                                      29





                  Copyright (c) 1992, 1993 by Mark Davidsaver





            This statement gets a range of pixels from the graphics
            screen and puts them into an array.  The may be placed
            back on the screen using the PUT statement.  In
            BasicBasic only one set of pixels may be stored in each
            array and storing begins with the first element of the
            array.

                      e.g.
                         DIM A%(100)

                         GET (100,100)-(109,109),A%

            It is important that you dimension the array large
            enough to hold the pixel data.

            You can calculate the space required as follows:

               size=int(((totalpixels*bits/pixel)+1)/8)+100

            Where size is in bytes.  Each element of an integer
            array takes up 2 bytes.



          GET #filenumber,recordnumber,variable$

            This statement allows input of data from RANDOM or
            BINARY files.

            For random files the record format and input/output
            buffer must previously have been assigned with a FIELD
            statement.  The following example would read in the
            first record of an existing random file which is defined
            to have a record length of 512 bytes, of which the first
            32 bytes are the first name and the second 32 bytes are
            the last name.  After the GET statement in the example
            is executed the data will be in the input buffer
            variables FIRST$ and LAST$.  After the file is closed
            the input buffer is cleared so data must be retrieved
            from the input buffer variables before closing the file.

                 OPEN "test.dat" FOR RANDOM AS #1 LEN = 512
                 FIELD #1,32 AS FIRST$,32 AS LAST$
                 TOPREC = 1
                 GET #1, TOPREC
                 IF EOF(1) THEN
                    PRINT "NO DATA IN FILE"
                 ELSE
                    SAVEFIRST$=FIRST$
                    SAVELAST$=LAST$
                 END IF
                 CLOSE #1


                                      30





                  Copyright (c) 1992, 1993 by Mark Davidsaver






            For binary files recordnumber is an absolute byte
            position in the file.  Data will be input to variable$.
            Variable$ must be set up before an INPUT to be the same
            size as the desired number of characters to read.  The
            first byte of the file is number 1.

               OPEN "test.dat" FOR BINARY AS #1
               FIRSTBYTE=1
               FIRST$=SPACE$(32)
               LAST$=SPACE$(32)
               GET #1, FIRSTBYTE,FIRST$
               FIRSTBYTE=FIRSTBYTE+32
               GET #1, FIRSTBYTE,LAST$
               CLOSE #1



          GOSUB label

            This statement causes a branch to a subroutine.


          GOTO label

            This statement causes a jump to another program
            location.



          IF...THEN...ELSE

            Permits conditional execution depending on evaluation of
            expression.



          INKEY$

            This function returns a character from the keyboard.



          INPUT[;]["promptstring"{;|,}] variablelist

            Executing this statement causes the program to pause and
            wait for input.  A promptstring may optionally be
            printed before pausing for input.  If a comma is used
            after the promptstring or if no prompt string is
            specified a question mark is displayed before waiting
            for input.  If INPUT is followed by a semicolon, then no
            carriage return line feed is performed after the Enter
            key is pressed.

                                      31





                  Copyright (c) 1992, 1993 by Mark Davidsaver







          INPUT #filenumber,variablelist

            This statement reads items from an open file to the
            given variables.  When inputting data leading spaces
            will be ignored.



          INPUT$(n,port)

            This function returns a string of n characters from a
            communications port.  If n characters are not available
            the function will WAIT for that many characters to
            arrive.  To avoid 'hanging up' your program use the LOC
            function to find how many characters are waiting.  If a
            communications error occurs the number of characters
            returned may be less than what you requested.  In this
            case use the function COMSTATI to determine what error
            occured.  See the section "Communications Programming"
            for more details.



          INSTR([start],expressiontosearch,searchforexpression)

            This function searches for the first occurence of
            searchforexpression in expressiontosearch and returns
            the position at which the match is found.  If no match
            is found then 0 is returned.



          INT(numericexpression)

            This function returns the largest integer less than or
            equal to numericexpression.



          IRND(ilow,ihigh)

            This function returns a random number greater than or
            equal to ilow and less than or equal to high.  Where
            ilow is less than ihigh and both are integer values less
            than 32769.  See RANDOMIZE for resetting the random
            number generator or RND for another random generator
            function.



          KILL stringexpression

                                      32





                  Copyright (c) 1992, 1993 by Mark Davidsaver





            This command deletes the file whose name is in
            stringexpression.



          LEFT$(stringexpression,n)

            This function returns a string of length n from the left
            part of stringexpression



          LEN(stringexpression)

            This function returns the number of characters in
            stringexpression.



          LET

            May optionally be used before assignment statements.
            e.g. LET I=3



          LINE [STEP](x1,y1)-[STEP](x2,y2),[color],[B],

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -