This documentation describes the PC-BASIC language, which aims to faithfully emulate
    GW-BASIC 3.23, IBM Advanced BASIC, IBM Cartridge BASIC and Tandy 1000 GW-BASIC.
    Differences with the original languages do arise, and where this is the case they are documented.
    Please note that Microsoft's official documentation for the original languages is rather hit-and-miss;
    it leaves several features undocumented and incorrectly describes others. To avoid making the same errors,
    the present documentation was written from scratch with reference to the actual behaviour.
    The errors in this document are therefore all my own. Please contact me if you encounter them.
    Functions
    
        Functions can only be used as part of an expression within a statement; they may take input values
        between parentheses and produce a return value. For example,
        in PRINT ABS(-1) the ABS function is used in an expression within a
        PRINT statement; in Y = SQR(X) + 2 the SQR function
        is used in an expression within a LET statement.
    
    
        Some reference works also use terms such as system variable for functions that do not take
        an input, presumably since in the GW-BASIC syntax such functions have no parentheses, in contrast to
        the languages in the C family (and indeed some modern BASICs).
        However, this is simply the GW-BASIC syntax for functions without inputs.
        For example, one can do DEF FNA=1: PRINT FNA
        in which no parentheses are allowed.
    
    
        ABS
        
            y = ABS(x)
        
        
            Returns the absolute value of x if x is a number and the
            value of x if x is a string.
        
        Parameters
        
    
    
        ASC
        
            val = ASC(char)
        
        
            Returns the code point (ASCII value) for the first character of char.
        
        Parameters
        
            - 
                charis an expression with
                a string value.
Errors
        
            - 
                charhas a numeric value: Type mismatch.
- 
                charequals"": Illegal function call.
    
        ATN
        
            y = ATN(x)
        
        
            Returns the inverse tangent of x.
        
        Parameters
        
            - 
                xis a numeric expression that gives
                the angle in radians.
Notes
        
            - 
                Unless PC-BASIC is run with the doubleoption, this function
                returns a single-precision value.
- 
                ATN(x)differs in the least significant digit from GW-BASIC.
Errors
        
            - 
                xhas a string value: Type mismatch.
    
        CDBL
        
            y = CDBL(x)
        
        
            Converts the numeric expression x to a double-precision value.
        
        Errors
        
            - 
                xhas a string value: Type mismatch.
    
        CHR$
        
            char = CHR$(x)
        
        
            Returns the character with code point x.
        
        Parameters
        
            - 
                xis a numeric expression in the range[0—255].
Errors
        
            - 
                xhas a string value: Type mismatch.
- 
                xis not in[-32768—32767]: Overflow.
- 
                xis not in[0—255]: Illegal function call.
    
        CINT
        
            y = CINT(x)
        
        
            Converts the numeric expression x to a signed integer.
            Halves are rounded away from zero, so that e.g.
            CINT(2.5) = 3 and CINT(-2.5) = -3.
        
        Errors
        
            - 
                xhas a string value: Type mismatch.
- 
                xis not in[-32768—32767]: Overflow.
    
        COS
        
            cosine = COS(angle)
        
        
            Returns the cosine of angle.
            Unless PC-BASIC is run with the double option,
            this function returns a single-precision
            value.
        
        Parameters
        
            - 
                angleis a numeric expression that
                gives the angle in radians.
Notes
        
            - 
                The return value usually differs from the value returned by GW-BASIC in the least significant figure.
            
Errors
        
            - 
                anglehas a string value: Type mismatch.
    
        CSNG
        
            y = CSNG(x)
        
        
            Converts the numeric expression x to a single-precision value
            by Gaussian rounding.
        
        Errors
        
            - 
                xhas a string value: Type mismatch.
    
        CSRLIN
        
            y = CSRLIN
        
        
            Returns the screen row of the cursor on the active page.
            The return value is in the range [1—25].
        
        Notes
        
            - 
                This function takes no arguments.
            
    
        CVI
        
            y = CVI(s)
        
        
            Converts a two-byte string to a signed integer.
        
        Parameters
        
            - 
                sis a string expression that represents an integer using
                little-endian two's complement encoding. Only the first two bytes are used.
Errors
        
            - 
                shas a numeric value: Type mismatch.
    
        CVS
        
            y = CVS(s)
        
        
            Converts a four-byte string to a single-precision floating-point number.
        
        Parameters
        
            - 
                sis a string expression that represents a single-precision
                number in Microsoft Binary Format. Only the first four bytes are used.
Errors
        
            - 
                shas a numeric value: Type mismatch.
    
        CVD
        
            y = CVD(s)
        
        
            Converts an eight-byte string to a double-precision floating-point number.
        
        Parameters
        
            - 
                sis a string expression  that represents a double-precision
                number in Microsoft Binary Format. Only the first eight bytes are used.
Errors
        
            - 
                shas a numeric value: Type mismatch.
    
        DATE$ (function)
        
            s = DATE$
        
        
            Returns the system date as a string in the format "mm-dd-yyyy".
        
        Notes
        
            - 
                This function takes no arguments.
            
    
        ENVIRON$
        
            value = ENVIRON[ ]$(x)
        
        
            Returns an environment variable.
        
        Parameters
        
            x is an expression.
        
        
            - 
                If xhas a string value, returns the value for the environment variablexor the empty
                string if no variable with the namexis set in the environment table.
- 
                If xhas a numeric value, it must be in[1—255]. Returns thexth entry in
                the environment table.
Errors
        
            - 
                xis the empty string: Illegal function call.
- 
                xis a number not in[-32768—32767]: Overflow.
- 
                xis a number not in[1—255]: Illegal function call.
    
        EOF
        
            is_at_end = EOF(file_num)
        
        
            Returns -1 if file with number file_num has reached end-of-file; 0 otherwise.
            The file must be open in INPUT or RANDOM mode. EOF(0) returns 0.
        
        Notes
        
            - 
                If file_numis open toKYBD:, performs a blocking read and returns -1 if
                CTRL+Z is entered, 0 otherwise. The character entered is then echoed to
                the console.
Errors
        
            - 
                file_numhas a string value: Type mismatch.
- 
                file_numis a number not in[-32768—32767]: Overflow.
- 
                file_numis a number not in[0—255]: Illegal function call.
- 
                file_numis not 0 or the number of an open file:
                Bad file number.
- 
                The file with number file_numis in OUTPUT or APPEND mode:
                Bad file mode.
    
        ERDEV
        
            zero = ERDEV
        
        
            Returns 0.
        
        Notes
        
            - 
                In GW-BASIC, returns the value of a device error.
            
- 
                This function is not implemented in PC-BASIC.
            
- 
                This function takes no arguments.
            
    
        ERDEV$
        
            empty = ERDEV[ ]$
        
        
            Returns the empty string.
        
        Notes
        
            - 
                In GW-BASIC, returns the device name of a device error.
            
- 
                This function is not implemented in PC-BASIC.
            
- 
                This function takes no arguments.
            
    
        ERL
        
            error_line = ERL
        
        
            Returns the line number where the last error was raised.
        
        Notes
        
            - 
                If the error was
                raised by a direct statement, returns 65535.
            
- 
                If no error has been raised,
                returns 0.
            
- 
                This function takes no arguments.
            
    
        ERR
        
            error_code = ERR
        
        
            Returns the number of the last error.
        
        Notes
        
            - 
                If no error has been raised, returns 0.
            
- 
               If the last error was a Syntax error raised by a direct statement, returns 0.
            
- 
                This function takes no arguments.
            
    
        EXP
        
            y = EXP(x)
        
        
            Returns the exponential of x, i.e. e to the power x.
        
        Parameters
        
            - 
                xis a number-
                valued expression.
Notes
        
            - 
                Unless PC-BASIC is run with the doubleoption, this function returns a single-precision
                value.
- 
                The return value sometimes differs in the least significant digit from GW-BASIC. For
                large values of x, the difference may be 3 digits.
Errors
        
            - 
                xhas a string value: Type mismatch.
- 
                xis larger than the natural logarithm of the maximum single-precision
                value: Overflow.
    
        EXTERR
        
            zero = EXTERR(x)
        
        
            Returns 0.
        
        Parameters
        
            - 
                xis a numeric expression in[0—3].
Notes
        
            - 
                In GW-BASIC, this function returns extended error information from MS-DOS.
            
- 
                This function is not implemented in PC-BASIC.
            
Errors
        
            - 
                xhas a string value: Type mismatch.
- 
                xis not in[-32768—32767]: Overflow.
- 
                xis not in[0—3]: Illegal function call.
    
        FIX
        
            whole = FIX(number)
        
        
            Returns number truncated towards zero.
        
        Parameters
        
            - 
                numberis a numeric expression.
Notes
        
            - 
                FIXtruncates towards zero: it removes the fractional part. By contrast,INTtruncates towards negative infinity.
Errors
        
            - 
                numberis a string expression: Type mismatch.
    
        FN
        
            result = FN[ ]name [(arg_0 [, arg_1] ...)]
        
        
            Evaluates the user-defined function previously defined with DEF FN name.
            Spaces between FN and name are optional.
        
        Parameters
        
            - 
                nameis the name of a previously defined function.
- 
                arg_0, arg_1, ...are expressions, given as parameters to the function.
Errors
        
            - 
                No function named nameis defined:
                Undefined user function.
- 
                The number of parameters differs from the function definition:
                Syntax error.
            
- 
                The type of one or more parameters differs from the function definition:
                Type mismatch.
            
- 
                The return type is incompatible with the function name's sigil:
                Type mismatch.
            
- 
                The function being called is recursive or mutually recursive:
                Out of memory.
        
    
        FRE
        
            free_mem = FRE(x)
        
        
            Returns the available BASIC memory.
        
        Parameters
        
            x is an expression.
        
        
            - 
                If xhas a numeric value, it is ignored.
- 
                If xhas a string value, garbage collection is performed
                before returning available memory.
    
        HEX$
        
            hex_repr = HEX$(x)
        
        
            Returns a string with the hexadecimal representation of x.
        
        Parameters
        
            - 
                xis a
                numeric expression in[-32768—65535]. Values for
                negativexare shown as two's-complement.
Errors
        
            - 
                xis not in[-32768—65535]: Overflow.
- 
                xhas a string value: Type mismatch.
    
        INKEY$
        
            key = INKEY$
        
        
            Returns one key-press from the keyboard buffer. If the keyboard buffer is
            empty, returns the empty string. Otherwise, the return value is a one- or two-
            character string holding the e-ASCII code of the pressed key.
        
        Notes
        
            - 
                This function takes no arguments.
            
- 
                When a function key F1–F10 is pressed,
                INKEY$will return the letters of the associated macro
                — unless this macro has been set to empty with theKEYstatement, in which case
                it returns the e-ASCII code for the function key.
    
        INP
        
            code = INP(port)
        
        
            Returns the value of an emulated machine port.
        
        Parameters
        
            port is a numeric expression in [0—65535].
        
        
        Notes
        
            - 
                Only a limited number of machine ports are emulated in PC-BASIC.
            
Errors
        
            - 
                portis not in[-32768—65535]: Overflow.
- 
                porthas a string value: Type mismatch.
    
        
        
            chars = INPUT[ ]$ (num_chars [, [#] file_num])
        
        
            Returns a string of num_chars characters from the keyboard or,
            if file_num is provided, from a text file.
        
        Parameters
        
            - 
                num_charsis a numeric expression in[1—255].
- 
                file_numis a numeric expression that returns the number of a text file opened inINPUTmode. The#is optional and has no effect.
Notes
        
            - 
                This is a blocking read. It will wait for characters if there are none
                in the buffer.
            
- 
                All control characters except Ctrl+Break, Ctrl+Scroll Lock and Pause
                are passed to the string by INPUT$. Ctrl+Break and Ctrl+Scroll Lock break
                execution whereas Pause halts until another key is pressed (and not read).
- 
                When reading from the keyboard directly or through KYBD:, arrow keys, Del,
                Home, End, Pg Up, Pg Dn are passed asNULcharacters. Function keys
                are ignored if they are event-trapped, otherwise function-key macro replacement is
                active as normal.
Errors
        
            - 
                num_charsis not in[-32768—32767]: Overflow.
- 
                num_charsis not in[1—255]: Illegal function call.
- 
                file_numis not an open file: Bad file number.
- 
                file_numis less than zero: Illegal function call.
- 
                file_numis greater than32767: Overflow.
- 
                file_numis not open forINPUT: Bad file mode.
- 
                num_charsorfile_numare strings: Type mismatch.
- 
                file_numis open to aCOMport and this is the
                firstINPUT,LINE INPUTorINPUT$call on that port
                since the buffer has filled up completely (i.e.LOF(file_num)has become zero):
                Communication buffer overflow.
    
        INSTR
        
            position = INSTR([start,] parent, child)
        
        
            Returns the location of the first occurrence of the substring child in
            parent.
        
        Parameters
        
            - 
                parentandchildare string expressions.
- 
                startis a numeric expression in[1—255], specifying
                the starting position from where to look; if not specified, the search starts
                at character 1.
Notes
        
            - 
                If childis not a substring ofparentoccurring at or beforestart,INSTRreturns 0.
Errors
        
            - 
                starthas a string value orparentorchildhave numeric values: Type mismatch.
- 
                startis not in[-32768—32767]: Overflow.
- 
                startis not in[1—255]: Illegal function call.
    
        INT
        
            whole = INT(number)
        
        
            Returns number truncated towards negative infinity.
        
        Parameters
        
        Notes
        
            - 
                FIXtruncates towards zero: it removes the
                fractional part. By contrast,INTtruncates towards negative infinity.
- 
                If numberis a string expression,INTreturns its value unchanged.
    
        IOCTL$
        
            result = IOCTL[ ]$ ([#] file_num)
        
        
            Raises Illegal function call.
        
        Notes
        
            - 
                In GW-BASIC, IOCTL$reads the reply toIOCTLfrom a device.
- 
                This function is not implemented in PC-BASIC.
            
Errors
        
            - 
                file_numhas a string value: Type mismatch.
- 
                file_numis not in[-32768—32767]: Overflow.
- 
                file_numis not an open file: Bad file number.
- 
                Otherwise: Illegal function call
            
    
        LEFT$
        
            child = LEFT$(parent, num_chars)
        
        
            Returns the leftmost num_chars characters of parent.
        
        Parameters
        
            - 
                parentis a string expression.
- 
                num_charsis a numeric expression in[0—255].
Notes
        
            - 
                If num_charsis zero orparentis empty,LEFT$returns
                an empty string.
- 
                If num_charsis greater than the length ofparent,
                returnsparent.
Errors
        
            - 
                parenthas a numeric value ornum_charshas a string value: Type mismatch.
- 
                num_charsis not in[-32768—32767]: Overflow.
- 
                num_charsis not in[0—255]: Illegal function call.
    
        LEN
        
            length = LEN(string)
        
        
            Returns the number of characters in string.
        
        Parameters
        
            - 
                stringis a string
                expression.
Errors
        
            - 
                stringhas a number value: Type mismatch.
    
        LOC
        
            location = LOC(file_num)
        
        
            Returns the current location in the file opened under number file_num.
        
        
            - 
                If the file is opened for INPUT,OUTPUTorAPPEND,LOCreturns the number
                of 128-byte blocks read or written since opening the file.
- 
                If the file is opened for RANDOM,LOCreturns the record number last read or
                written.
- 
                If the file is opened to a COMdevice,LOCreturns the number of characters
                in the input buffer, with a maximum of 255.
- 
                If the file is opened to KYBD:,LOCreturns 0.
Parameters
        
            - 
                file_numis a numeric expression in the range[0—255].
Notes
        
            - 
               file_nummust not be preceded by a#.
- 
                In OUTPUTorAPPENDmode, before any writesLOCreturns 0. After the 128th
                character is written,LOCreturns 1.
- 
                In INPUTmode, before any readsLOCreturns 1. After the 129th character
                is read,LOCreturns 2.
Errors
        
            - 
                file_numhas a string value: Type mismatch.
- 
                file_numis not in[-32768—32767]: Overflow.
- 
                file_numis not in[0—255]: Illegal function call.
- 
                file_numis not an open file: Bad file number.
- 
                file_numis open to aLPTdevice: Bad file mode.
    
        LOF
        
            length = LOF(file_num)
        
        
            Returns the number of bytes in the file open under file_num.
        
        Parameters
        
            - 
                file_numis a numeric expression in the range[0—255].
Notes
        
            - 
                If file_numis open to aCOM:device,LOFreturns the number of bytes
                free in the input buffer.
Errors
        
            - 
                file_numhas a string value: Type mismatch.
- 
                file_numis not in[-32768—32767]: Overflow.
- 
                file_numis not in[0—255]: Illegal function call.
- 
                file_numis not an open file: Bad file number.
- 
                file_numis open to aLPTdevice: Bad file mode.
    
        LOG
        
            y = LOG(x)
        
        
            Returns the natural logarithm of x.
        
        Parameters
        
            - 
                xis a numeric expression greater than zero.
Notes
        
            - 
                Unless PC-BASIC is run with the doubleoption, this function returns a single-precision value.
- 
               LOG(x)can differ from GW-BASIC by 1 in the least significant digit.
Errors
        
            - 
                xhas a string value: Type mismatch.
- 
                xis zero or negative: Illegal function call.
    
        LPOS
        
            position = LPOS(printer_number)
        
        
            Returns the column position for a printer.
        
        Parameters
        
            - 
                printer_numberis a numeric expression in[0—3].
                If it is 0
                or 1, the position forLPT1:is returned. If it is 2,LPT2:; 3,LPT3:.
Notes
        
            - 
                When entering direct mode, LPT1:(but not other printers)
                is flushed and its position is reset to 1.
Errors
        
            - 
                printer_numberhas a string value: Type mismatch.
- 
                printer_numberis not in[-32768—32767]: Overflow.
- 
                printer_numberis not in[0—3]: Illegal function call.
    
        MID$ (function)
        
            substring = MID$(string, position [, length])
        
        
            Returns a substring of string starting at position, counting from 1. The
            substring has length length if specified.
            If length is not specified, the substring extends to the end of the string.
        
        Parameters
        
            - 
                stringis a string expression.
- 
                positionis a numeric expression between 1 and the string length, inclusive.
- 
                lengthis a numeric expression in[0—255].
Errors
        
            - 
                stringhas a number value orpositionorlengthhave string values: Type mismatch.
- 
                positionorlengthare not in[-32768—32767]: Overflow.
- 
                positionis not in[1—255]: Illegal function call.
- 
                lengthis not in[0—255]: Illegal function call.
    
        MKD$
        
            bytes = MKD$(double)
        
        
            Returns the internal 8-byte Microsoft Binary Format representation of a double-
            precision number.
        
        Errors
        
            - 
                doublehas a string value: Type mismatch.
    
        MKI$
        
            bytes = MKI$(int)
        
        
            Returns the internal 2-byte little-endian representation of an integer.
        
        Errors
        
            - 
                inthas a string value: Type mismatch.
- 
                intis not in[-32768—32767]: Overflow.
    
        MKS$
        
            bytes = MKS$(single)
        
        
            Returns the internal 8-byte Microsoft Binary Format representation of a single-
            precision number.
        
        Errors
        
            - 
                singlehas a string value: Type mismatch.
    
        OCT$
        
            octal = OCT$(x)
        
        
            Returns a string with the octal representation of x.
        
        Parameters
        
            - 
                xis a
                numeric expression in[-32768—65535]. Values for
                negativexare shown as two's-complement.
Errors
        
            - 
                xhas a string value: Type mismatch.
- 
                xis not in[-32768—65535]: Overflow.
    
        PEEK
        
            value = PEEK(address)
        
        
            Returns the value of the memory at  segment * 16 + address where segment
            is the current segment set with DEF SEG.
        
        Parameters
        
            - 
                addressis a numeric expression in[-32768—65535]. Negative values are interpreted as their
                two's complement.
Notes
        
            - 
               The memory is only partly emulated in PC-BASIC. See Memory model for supported addresses.
               Outside emulated areas, PEEKreturns 0.
- 
               Values for particular memory address can be preset on the command line
                using the peekoption. This can be used for compatibility with old
                programs. These values will override video or data segment values, if they
                are in those locations.
Errors
        
            - 
                addresshas a string value: Type mismatch.
- 
                addressis not in[-32768—65535]: Overflow.
    
        PEN (function)
        x = PEN(mode)
        
            Reads the light pen. What this function returns depends on mode:
        
        
        Parameters
        
            - 
                modeis a numeric expression in[0—9].
Notes
        
            - 
                In PC-BASIC, for pen down read mouse button pressed. For pen
                position read mouse pointer position.
            
Errors
        
            - 
                modehas a string value: Type mismatch.
- 
                modeis not in[-32768—32767]: Overflow.
- 
                modeis not in[0—9]: Illegal function call.
    
        PLAY (function)
        
            length = PLAY(voice)
        
        
            Returns the number of notes in the background music queue. The return value is in [0—32].
        
        Parameters
        
            - 
                voiceis a numeric expression in[0—255].
                Ifsyntax={pcjr|tandy}, indicates for which tone voice channel
                the number of notes is to be returned. Ifvoiceis not in[0—2], the
                queue for voice 0 is returned.
                For other choices ofsyntax, thevoicevalue has no effect.
Notes
        
            - 
                There are at most 32 notes in the music queue. However, unless the articulation is
                set to legato, there are short gaps between each note; these are counted as
                separate notes in the queue. Effectively, the queue length is thus 16 for the default
                and staccato articulations and 32 for legato.
            
Errors
        
            - 
                voicehas a string value: Type mismatch.
- 
                voiceis not in[0—255]: Illegal function call.
- 
                voiceis not in[-32768—32767]: Overflow.
    
        PMAP
        
            transformed_coord = PMAP(original_coord, fn)
        
        
            Maps between viewport and logical (WINDOW) coordinates.
            If no VIEW has been set, the viewport coordinates
            are physical coordinates.
        
        
            Depending on the value of fn, PMAP
            transforms from logical to viewport coordinates or vice versa:
        
        
        Parameters
        
            - 
                fnis a numeric expression in[0—3].
Notes
        
            - 
                Initially, in text mode, PMAPreturns 0.
- 
                In GW-BASIC, PMAPbehaves anomalously onSCREENchanges, where it sometimes
                returns results as if the lastWINDOWsetting had persisted. This behaviour is not
                implemented in PC-BASIC.
Errors
        
            - 
                Any of the parameters has a string value: Type mismatch.
            
- 
                A physical coordinate is not in [-32768—32767]: Overflow.
- 
                fnis not in[-32768—32767]: Overflow.
- 
                fnis not in[0—3]: Illegal function call.
    
        POINT (current coordinate)
        
            coord = POINT(fn)
        
        
            Returns a currently active coordinate of the graphics screen. This is usually
            the last position at which a pixel has been plotted, the second corner given
            in a LINE command, or the centre of the viewport if nothing has been plotted.
            fn is a numeric expression in [0—3].
        
        
            The coordinate returned depends on the value of fn:
        
        
        Parameters
        
            - 
                fnis a numeric expression in[0—3].
Notes
        
            - 
                In text mode, returns the active coordinate of any previous graphics mode;
                if no graphics mode has been active, returns 0.
            
Errors
        
            - 
                fnhas a string value: Type mismatch.
- 
                fnis not in[-32768—32767]: Overflow.
- 
                fnis not in[0—3]: Illegal function call.
    
        POINT (pixel attribute)
        
            attrib = POINT(x, y)
        
        
            Returns the attribute of the pixel at logical coordinate x,y.
        
        Parameters
        
            - 
                x,yare numeric expressions in[-32768—32767].
Notes
        
            - 
                If x,yis outside the screen, returns -1.
Errors
        
            - 
                Function is called in text mode: Illegal function call.
            
- 
                xoryhas a string value: Type mismatch.
- 
                xoryor the physical coordinates they translate into are not in[-32768—32767]: Overflow.
    
        POS
        
            pos = POS(dummy)
        
        
            Returns the current cursor column position, in the range [1—80].
        
        Parameters
        
            - 
                dummyis a valid expression of any type; its value has no effect.
    
        RIGHT$
        
            child = RIGHT$(parent, num_chars)
        
        
            Returns the rightmost num_chars characters of parent.
            If num_chars is zero or parent is empty, RIGHT$ returns
            an empty string. If num_chars is greater than the length of parent,
            returns parent.
        
        Parameters
        
            - 
                parentis a string expression.
- 
                num_charsis a numeric expression in[0—255].
Errors
        
            - 
                num_charshas a string value: Type mismatch.
- 
                num_charsis not in[-32768—32767]: Overflow.
- 
                num_charsis not in[0—255]: Illegal function call.
    
        RND
        
            random = RND[(x)]
        
        
            Returns a pseudorandom number in the interval [0—1).
        
        Parameters
        
            x is a numeric expression.
        
        
            - 
                If xis zero,RNDrepeats the last
                pseudo-random number.
- 
                If xis greater than zero, a new pseudorandom number is
                returned.
- 
                If xis negative,xis converted to a single-precision floating-point value
                and the random number seed is set to the absolute value of its mantissa.
                The function then generates a new pseudorandom numer with this seed.
                Since the only the mantissa ofxis used, any two values whose ratio is a
                power of 2 will produce the same seed.
                Note that this procedure for generating a new seed differs from that used byRANDOMIZE.
Notes
        
            - 
                PC-BASIC's RNDfunction generates pseudo-random numbers through a linear congruential generator with modulo 224,
                multiplier 214013 and increment 2531011. This exactly reproduces the random numbers of GW-BASIC'sRND.
- It should be
                noted, however, that this is a very poor random number generator: its parameters imply a recurrence period of
                224, meaning that after less than 17 million calls RNDwill wrap around
                and start running through the exact same series of numbers all over again.RNDshould not be used for
                cryptography, scientific simulations or anything else remotely serious.
Errors
        
            - 
                xhas a string value: Type mismatch.
    
        SCREEN (function)
        
            value = SCREEN(row, column [, fn])
        
        
            Returns the code point or colour attribute for the character at position
            row, col.
        
        Parameters
        
            - 
                rowis a numeric expression in the range[1—25].
- 
                colis a numeric expression between 1 and the screen width (40 or 80).
- 
                fnis a numeric expression in[0—255]. If it is zero or not specified,
                the code point of the character is returned. If it is non-zero, in text mode the
                attribute is returned; in other screens, 0 is returned.
Errors
        
            - 
                Any parameter has a string value: Type mismatch.
            
- 
                fnis not in[0—255]: Illegal function call.
- 
                fnis not in[-32768—32767]: Overflow.
- 
                rowis not inside the currentVIEW PRINTarea:
                Illegal function call.
- 
                KEY ONandrow=25: Illegal function call.
- 
                colis not in[1, width]: Illegal function call.
    
        SGN
        
            sign = SGN(number)
        
        
            Returns the sign of number: 1 for positive, 0 for zero and -1 for negative.
        
        Parameters
        
            - 
                numberis a numeric expression.
Errors
        
            - 
                numberhas a string value: Type mismatch.
    
        SIN
        
            sine = SIN(angle)
        
        
            Returns the sine of angle.
        
        Parameters
        
            - 
            angleis a numeric expression giving
            the angle in radians.
Notes
        
            - 
                Unless PC-BASIC is run with the doubleoption, this function returns a single-precision value.
- 
                The sine returned usually differs from the value returned by GW-BASIC in the least significant figure.
            
Errors
        
            - 
                anglehas a string value:
                Type mismatch.
    
        SPACE$
        
            spaces = SPACE$(number)
        
        
            Returns a string of number spaces.
        
        Parameters
        
            - 
                numberis a numeric expression in[0—255].
Errors
        
            - 
                numberhas a string value: Type mismatch.
- 
                numberis not in[-32768—32767]: Overflow.
- 
                numberis not in[0—255]: Illegal function call.
    
        SQR
        
            root = SQR(number)
        
        
            Returns the square root of number.
        
        Parameters
        
            - 
                numberis a numeric expression.
Notes
        
            - 
                Unless PC-BASIC is run with the doubleoption, this function returns a single-precision value.
Errors
        
            - 
                numberhas a string value: Type mismatch
    
        STICK
        
            pos = STICK(axis)
        
        
            Returns a coordinate of a joystick axis. All coordinates returned are in the
            range [1—254] with 128 indicating the neutral position.
        
        
        Parameters
        
            - 
                axisis a numeric expression in[0—3]and indicates which axis to read.
Errors
        
            - 
                axishas a string value: Type mismatch
- 
                axisis not in[-32768—32767]: Overflow.
- 
                axisis not in[0—3]: Illegal function call.
    
        STR$
        
            repr = STR$(number)
        
        
            Returns the string representation of number.
        
        Parameters
        
            - 
                numberis a numeric expression.
Errors
        
            - 
                numberhas a string value: Type mismatch.
    
        STRIG (function)
        
            result = STRIG(mode)
        
        
            Returns the status of the joystick trigger buttons.
            STRIG returns the following
            results, all Boolean values:
        
        
        Parameters
        
            - 
                modeis a numeric expression in[0—7].
Notes
        
            - 
                The STRIGfunction returns correct results regardless of theSTRIG ONstatus or whetherSTRIG(0)has been called first.
Errors
        
            - 
                modehas a string value: Type mismatch.
- 
                modeis not in[-32768—32767]: Overflow.
- 
                modeis not in[0—7]: Illegal function call.
    
        STRING$
        
            string = STRING$(length, char)
        
        
            Returns a string of length times character char.
        
        Parameters
        
            - 
                If charis a numeric expression, it must be in[0—255]and is
                interpreted as the code point of the character.
- 
                If charis a string expression, its first character is used.
Errors
        
            - 
                lengthhas a string value: Type mismatch.
- 
                charis the empty string: Illegal function call.
- 
                charorlengthis not in[-32768—32767]: Overflow.
- 
                charorlengthis not in[0—255]: Illegal function call.
    
        TAN
        
            tangent = TAN(angle)
        
        
            Returns the tangent of angle.
        
        Parameters
        
            - 
                angleis a numeric expression giving
                the angle in radians.
Notes
        
            - 
                Unless PC-BASIC is run with the doubleoption, this function returns a single-precision value.
- 
                The tangent returned usually differs from the value returned by GW-BASIC in the least significant figure.
            
- 
                For angleclose to multiples ofπ/2, the tangent is divergent or close
                to zero. The values returned will have very low precision in these cases.
Errors
        
            - 
                anglehas a string value: Type mismatch.
    
        TIME$ (function)
        
            time = TIME$
        
        
            Returns the current BASIC time in the form "HH:mm:ss".
        
        Notes
        
            - 
                This function takes no arguments.
            
    
        TIMER (function)
        
            seconds = TIMER
        
        
            Returns the number of seconds since midnight on the internal BASIC
            clock.
        
        Notes
        
            - 
                TIMERupdates in ticks of 1/20 second.
- 
                The least-significant two bytes of TIMERare often used as a seed for the
                pseudorandom number generator throughRANDOMIZE TIMER. Since these bytes
                only take values from a limited set, that's not in fact a particularly good
                random seed. However, the pseudorandom number generator included with GW-BASIC and PC-BASIC
                is so weak that it should not be used for anything serious anyway.
- 
                This function takes no arguments.
            
    
        USR
        
            value = USR[n](expr)
        
        
            Raises Illegal function call.
        
        Parameters
        
            - 
                nis a digit[0—9].
- 
                expris an expression.
Notes
        
            - 
                In GW-BASIC, calls a machine-code function and returns its return value.
            
- 
                This function is not implemented in PC-BASIC.
            
Errors
        
            - 
                nis not a digit[0—9]: Syntax error.
    
        VAL
        
            value = VAL(string)
        
        
            Returns the numeric value of the string expression string.
            Parsing stops as soon as the first character is encountered that cannot be
            part of a number. If no characters are parsed, VAL returns zero.
            See the section on numeric literals for the
            recognised number formats.
        
        Notes
        
            - 
                Spaces before or even inside a number are ignored:
                VAL(" 1 0")returns10.
- 
                If stringcontains one of the ASCII separator
                charactersCHR$(28)(file separator),CHR$(29)(group separator) orCHR$(31)(unit separator),VALreturns zero.
                This is not the case withCHR$(30)(record separator).
                This behaviour conforms to GW-BASIC.
Errors
        
            - 
                stringhas a number value: Type mismatch.
    
        VARPTR
        
            pointer = VARPTR({name|#file_num})
        
        
            Returns the memory address of variable name
            or of the File Control Block of
            file number file_num.
        
        Parameters
        
            - 
                nameis a
                previously defined variable or fully indexed array element.
- 
                file_numis a legal file number.
Notes
        
            - 
                VARPTRcan be used withPEEKto read a variable's internal representation.
Errors
        
            - 
                namehas not been previously defined: Illegal function call.
- 
                file_numhas a string value: Type mismatch.
- 
                file_numis not in[1, max_files],
                wheremax_filesis the maximum number of files
                as set by themax-filesoption:
                Bad file number.
    
        VARPTR$
        
            pointer = VARPTR$(name)
        
        
            Returns the memory address of variable name in the form of a 3-byte string.
            The first byte is the length of the record the pointer points to:
        
        
            - 2
- for integers
- 3
- for strings (length + pointer to string space)
- 4
- for single-precision floats
- 8
- for double-precision floats
            The last two bytes are the pointer address (as returned by
            VARPTR) in little-endian order.
        
        Errors
        
            - 
                namehas not been previously defined: Illegal function call.
    Statements
    
        A program line is composed of a line number and one or more statements. If multiple statements
        are put on one line, they must be separated by colons :. Statements may be empty.
        Each statement has its own idiosyncratic syntax.
    
    
        Many reference works on GW-BASIC distinguish commands and statements; this distinction stems
        from the original Dartmouth design of the BASIC language, in which commands were not part of the
        language and could not be used in programs, but were rather used to control the
        interpreter itself. However, in GW-BASIC this distinction is less useful and therefore this reference
        includes what is traditionally thought of as commands in the category of statements.
    
    
        AUTO
        
            AUTO [line_number|.] [, [increment]]
        
        
            Start automatic line numbering. Line numbers
            are automatically generated when Enter is pressed.
            If a program line exists at a generated line number, a * is shown after the
            line number. To avoid overwriting this line, leave it empty and press Enter.
            To stop automatic line numbering, press Ctrl+Break or Ctrl+C. The line being edited at
            that point is not saved. BASIC will return to command mode, even if AUTO was
            run from a program line.
        
        Parameters
        
            - 
                Line numbering starts at line_number, if specified. If.is specified, line
                numbering starts at the last program line that was stored. Otherwise, line
                numbering starts at10.
- 
                Each next line number is incremented by increment, if specified. If a comma
                is used without specifying an increment, the last increment specified in anAUTOcommand is used. If not,incrementdefaults to10.
Errors
        
            - 
                line_numberis not an unsigned-integer value in[0—65529]:
               Syntax error.
- 
                When automatic line numbering is enabled and Enter is pressed on an empty line with number larger than
               65519: Undefined line number.
- 
                incrementis0:
                Illegal function call.
    
        BEEP
        
            BEEP
        
        
            Beep the speaker at 800Hz for 0.25s.
        
        Errors
        
            - 
                If a Syntax error is raised, the beep is still produced.
            
    
        BEEP (switch)
        
            BEEP {ON|OFF}
        
        
            Switches the internal speaker on or off.
        
        Notes
        
            - 
                Only legal with the syntax={pcjr|tandy}option.
- 
                On PC-BASIC, both the internal and the external speaker are emulated through
                the same sound system.
            
    
        BLOAD
        
            BLOAD file_spec [, offset]
        
        
            Loads a memory image file into memory.
        
        Parameters
        
            - 
                The string expression file_specis a
                valid file specification indicating
                the file to read the memory image from.
- 
                offsetis a numeric expression in the range[-32768—65535].
                It indicates an offset in the currentDEF SEGsegment where the file is to be
                stored. If not specified, the offset stored in theBSAVEfile will be used. If
                negative, its two's complement will be used.
Errors
        
            - 
                The loaded file is not in BSAVEformat: Bad file mode.
- 
                file_speccontains disallowed characters:
                Bad file number (onCAS1:);
                Bad file name (on disk devices).
- 
                file_spechas a numeric value: Type mismatch.
- 
                offsetis not in the range[-32768—65535]: Overflow.
    
        BSAVE
        
            BSAVE file_spec, offset, length
        
        
            Saves a region of memory to an image file.
        
        Parameters
        
            - 
                The string expression file_specis a
                valid file specification indicating
                the file to write to.
- 
                offsetis a numeric expression in the range[-32768—65535]indicating
                the offset into the currentDEF SEGsegment from where to start reading.
- 
                lengthis a numeric expression in the range[-32768—65535]indicating
                the number of bytes to read.
- 
                If offsetorlengthare negative, their two's
                complement will be used.
Errors
        
            - 
                file_spechas a numeric value: Type mismatch.
- 
                file_speccontains disallowed characters:
                Bad file number (onCAS1:);
                Bad file name (on disk devices).
- 
                offsetis not in the range[-32768—65535]: Overflow.
- 
                lengthis not in the range[-32768—65535]: Overflow.
    
    CALL and CALLS
    
        {CALL|CALLS} address_var [( p0 [, p1] ... )]
    
    
        Does nothing.
    
    Notes
    
        - 
            In GW-BASIC, CALLorCALLSexecutes a machine language subroutine.
- 
            This statement is not implemented in PC-BASIC.
        
Parameters
    
        - 
            address_varis a numeric variable name.
- 
            p0, p1, ...are variable names or array elements.
Errors
    
        - 
            address_varis a string variable: Type mismatch.
- 
            address_varis a literal or expression: Syntax error.
    
    CHAIN
        
            CHAIN [MERGE] file_spec [, [line_number_expr] [, ALL] [, DELETE range [, ign]]]
        
        
            Loads a program from file into memory and runs it, optionally transferring variables.
        
        
            - 
                If ALLis specified, all variables are transferred. If not, the variables
                specified in aCOMMONstatement are transferred.
- 
                If MERGEis specified, the loaded program is merged into the existing program. To be
                able to use this, the program file indicated byfile_specmust be in plain text format.
- 
                If DELETEis specified, therangeof line numbers is deleted from the
                existing code before the merge. This is pointless withoutMERGE.
Parameters
        
            - 
                The string expression file_specis a
                valid file specification indicating
                the file to read the program from.
- 
                line_number_expris a numeric expression. It
                will be interpreted as a line number in the new program and execution will
                start from this line number. Ifline_number_expris negative, it will be
                interpreted as its two's-complement.
- 
                rangeis a line number range of which the closing line number is
                specified and exists before the merge.
- 
                ignis optional and ignored.
Notes
        
            - 
                CHAINpreserves theOPTION BASEsetting.
- 
                Only if ALLis specified,DEF FNdefinitions are preserved.
- 
                Only if MERGEis specified,DEFINT,DEFSTR,DEFSNG,DEFDBLdefinitions
                are preserved.
- 
                If specified, ALLmust precedeDELETE; if unspecified, no comma must
                be put in its place and only two commas should precedeDELETE.
Errors
        
            - 
                file_spechas a numeric value: Type mismatch.
- 
                file_speccontains disallowed characters:
                Bad file number (onCAS1:);
                Bad file name (on disk devices).
- 
                The file specified in file_speccannot be found: File not found.
- 
                MERGEis specified and the loaded program was not saved in plain-text mode:
                Bad file mode.
- 
                A line number in rangeis greater than 65529: Syntax error.
- 
                If a Syntax error is raised by CHAIN, no lines are deleted and the new
                program is not loaded.
- 
                The closing line number in rangedoes not exist: Illegal function call
- 
                If line_number_exprdoes not evaluate to an existing line number in the
                new program, Illegal function call is raised but the load or merge is
                being performed.
- 
                A loaded text file contains lines without line numbers:
                Direct statement in file.
            
- 
                A loaded text file contains lines longer than 255 characters:
                Line buffer overflow.
                Attempting to load a text file that has LFrather thanCR LFline endings may cause this error.
    
        CHDIR
        
            CHDIR dir_spec
        
        
            Change the current directory on a disk device to dir_spec.
            Each disk device has its own current directory.
        
        Parameters
        
            - 
                The string expression dir_specis a
                valid file specification indicating an existing
                directory on a disk device.
Errors
        
            - 
                No matching path is found: Path not found.
            
- 
                dir_spechas a numeric value: Type mismatch.
- 
                dir_specis empty: Bad file name.
    
        CIRCLE
        
            CIRCLE [STEP] (x, y), radius
            [, [colour] [, [start] [, [end] [, aspect]]]
        
        
            Draw an ellipse or ellipse sector.
        
        Parameters
        
            - 
                The midpoint of the ellipse is at (x,y).
                IfSTEPis specified, the midpoint is(x,y)away from the current position.
- 
                radiusis the radius, in pixels, along the long axis.
- 
                colouris the colour attribute.
- 
                If startandendare specified, a sector of the ellipse is drawn fromstartradians toendradians, with zero radians the intersection with the
                right-hand x axis. If a negative value is specified, the arc sector is
                connected by a line to the midpoint.
- 
                aspectspecifies the ratio between the y radius and the x radius. If it is
                not specified, the standard value for theSCREENmode is used (see there), so
                as to make the ellipse appear like a circle on the original hardware.
Notes
        
            - 
                For aspect <> 1, the midpoint algorithm used does not pixel-perfectly
                reproduce GW-BASIC's ellipses.
Errors
        
            - 
                The statement is executed in text mode: Illegal function call.
            
- 
                startorendis not in[0—2π]: Illegal function call.
- 
                The statement ends with a comma: Missing operand.
            
    
        CLEAR
        
            CLEAR [expr] [, [mem_limit] [, [stack_size] [, video_memory]]]
        
        
            Clears all variables, arrays,DEF FN user functions and DEFtype type definitions.
            Closes all files.
            Turns off all sound. Resets PLAY state and sets music to foreground.
            Clears all ON ERROR traps. Resets ERR and ERL to zero. Disables all events.
            Turns PEN and STRIG off. Resets the random number generator.
            Clears the loop stack. Resets the DRAW state and the current graphics position.
        
        Parameters
        
            - 
                mem_limitspecifies the upper limit of usable memory. Default is previous
                memory size. Default memory size is 65534.
- 
        stack_sizespecifies the amount of memory available to the BASIC stack.
        Default is previous stack size. Default stack size is 512.
- 
                video_memoryspecifies the amount of memory available
                to the video adapter. This parameter is only legal with one of the optionssyntax={pcjr, tandy}. Instead of usingCLEAR, the optionvideo-memorycan also be used to set video memory size.
Notes
        
            - 
                The purpose of expris unknown.
- 
                If called inside a FOR—NEXTorWHILE—WENDloop, an error will be raised at
                theNEXTorWENDstatement, since the loop stacks have been cleared.
Errors
        
            - 
                Any of the arguments has a string value: Type mismatch.
            
- 
                mem_limit,stack_sizeare not in[-32768—65535]: Overflow.
- 
                mem_limitorstack_sizeequal0: Illegal function call.
- 
                mem_limitequals-1or65535: Out of memory.
- 
                mem_limitorexprare too low: Out of memory.
- 
                expris not  in[-32768—32767]: Overflow.
- 
                expris negative: Illegal function call.
    
        CLOSE
        
            CLOSE [[#] file_0 [, [#] file_1] ...]
        
        
            Closes files. If no file numbers are specified, all open files are closed.
            The hash (#) is optional and has no effect.
        
        Parameters
        
            - 
                file_1, file_2, ...are numeric expressions yielding
                file numbers.
Notes
        
            - 
                No error is raised if the specified file numbers were not open.
            
Errors
        
            - 
                file_1, file_2, ...are not in[-32768—32767]: Overflow.
- 
                file_1, file_2, ...are not in[0—255]: Illegal function call.
- 
                file_1, file_2, ...have a string value: Type mismatch.
- 
                The statement ends in a comma, Missing operand.
            
- 
                If an error occurs, only the files before the erratic value are closed.
            
    
        CLS
        
            CLS [x][,]
        
        
            Clears the screen or part of it.
            If x is not specified, in SCREEN 0 the text view region is cleared;
            in other screens, the graphics view region is cleared.
            The comma is optional and has no effect.
        
        Parameters
        
            x is a numeric valued expression.
        
        
            - 
                If x = 0, the whole screen is cleared.
- 
                If x = 1, the graphics view region is cleared.
- 
                If x = 2, the text view region is cleared.
            The optional argument x is not available with
            syntax={pcjr|tandy}.
        
        Errors
        
            - 
                xis has a string value: Type mismatch.
- 
                xis not in[-32768—32767]: Overflow .
- 
                xis not in[0, 1, 2]: Illegal function call.
- 
                No comma is specified but more text follows: Illegal function call.
            
- 
                A comma is specified followed by more: Syntax error.
            
- 
                syntax=pcjris set
                and an argument is specified: Syntax error.
- 
                syntax=tandyis set
                and an argument is specified: Illegal function call.
- 
                If an error occurs, the screen is not cleared.
            
    
        COLOR (text mode)
        
            COLOR [foreground] [, [background] [, border]]
        
        
            Changes the current foreground and background attributes.
            All new characters printed will take the newly set attributes. Existing
            characters on the screen are not affected.
        
        Parameters
        
            - 
                foregroundis a numeric expression in[0—31].
                This specifies the new foreground attribute. Attributes16—31are
                blinking versions of attributes0—15.
- 
                backgroundis a numeric expression in[0—15].
                This specifies the new background attribute. It is takenMOD 8: Values8—15produce the same colour as0—7.
- 
                borderis a numeric expression in[0—15]specifying the border attribute.
Textmode attributes (colour)
        
        Textmode attributes (monochrome)
        
        Notes
        
        Errors
        
            - 
                Any of the parameters has a string value: Type mismatch.
            
- 
                Any of the parameters is not in [-32768—32767]: Overflow.
- 
                foregroundis not in[0—31],backgroundis not in[0—15]orborderis not in[0—15]: Illegal function call.
- 
                Statement is used in SCREEN 2: Illegal function call.
    
        COLOR (SCREEN 1)
        
            COLOR [palette_0] [, palette [, override]]
        
        
            Assigns new colours to the palette of attributes.
        
        
            - 
                palette_0is a numeric expression  in[0—255].
                This sets the palette colour associated with attribute 0; by default, the
                background has this attribute. All pixels with this attribute will
                change colour. The palette colour value is taken from the 64-colour
                set.palette_0is takenMOD 64.
- 
                paletteis a numeric expression in[0—255]that specifies the palette:
                    - 
                        paletteodd sets the standard CGA palette (cyan, magenta, grey).
- 
                        paletteeven sets the alternative palette (green, red, brown).
 All pixels with attributes 1,2,3 will change colour to the new palette.
- 
                overrideis a numeric expression in[0—255].
                Ifoverrideis specified, palette is set as above but usingoverrideinstead ofpalette.paletteis then ignored.
CGA palettes
        
        Notes
        
        Errors
        
            - 
                Any of the parameters has a string value: Type mismatch.
            
- 
                Any of the parameters is not in [-32768—32767]: Overflow.
- 
                Any of the parameters is not in [0—255]: Illegal function call.
    
        COLOR (SCREEN 3—9)
        
            COLOR [foreground] [, palette_0 [, dummy]]
        
        
            Changes the current foreground attribute and the colour for attribute 0.
        
        Parameters
        
            - 
                foregroundis a numeric expression in[1—15]This sets the new foreground attribute. This applies only to new characters
                printed or pixels plotted.
- 
                palette_0is a numeric expression in[0—15]This sets the colour associated with attribute 0; by default, the
                background has this attribute. All pixels with this attribute will
                change colour.
                InSCREEN 7and8, thepalette_0colour is taken from the first 8 of
                the 16-colour EGA set.palette_0is takenMOD 8.
                INSCREEN 9, the colour value is taken from the 64-colour set.
- 
                dummyis a numeric expression with a value in[0—255]The value ofdummyis ignored.
EGA default palette
        
        EGA colour list
        
        Notes
        
        Errors
        
            - 
                Any of the parameters has a string value: Type mismatch.
            
- 
                Any of the parameters is not in [-32768—32767]: Overflow.
- 
                foregroundis not in[1—15];backgroundis not in[0—15]; ordummyis not in[0—255]: Illegal function call.
    
        COM
        
            COM(port) {ON|OFF|STOP}
        
        
            - 
                ON: enablesON COM(port)event trapping of the emulated serial port.
- 
                OFF: disables trapping.
- 
                STOP: halts trapping untilCOM(port) ONis used. Events that occur
                while trapping is halted will trigger immediately when trapping is re-enabled.
Parameters
        
            - 
                portis a numeric expression with a value of1or2. This specifies which
                serial port (COM1:orCOM2:) is trapped. Ifportequals0, this statement does nothing.
Errors
        
            - 
                porta string value: Type mismatch.
- 
                portis not in[-32768—32767]: Overflow.
- 
                portis not in[0—3]: Illegal function call.
    
        COMMON
        
            COMMON [var_0 [( [index_0] )] [, [var_1 [( [index_1] )] ]] ...]
        
        
            Specifies variables to be passed as common variables to the program called
            with CHAIN.
        
        Parameters
        
            - 
                var_0, var_1, ...are names of scalar or array variables.
- 
                index_0, index_1, ...are optional number literals; they are ignored.
Notes
        
            - 
                Array elements with square brackets and an index do not cause an error, but are ignored.
            
- 
                COMMONstatements are not executed during run time; rather, when aCHAINcommand is encountered whereALLis not specified,
                allCOMMONdeclarations in the program are parsed. As a consequence, theDEFSTR,DEFINT,DEFSNGorDEFDBLsettings
                used are those that are active at the time of execution of theCHAINstatement.
- 
                COMMONdeclarations need not be reachable in the program flow in order to be used.
                They may occur anywhere before or after theCHAINstatement that uses them.
- 
                Variables may be repeated or occur in multiple COMMONdeclarations.
- 
                If the COMMONkeyword is not the first element of the statement, the
                declaration will be ignored. In particular, anyCOMMONdeclaration that occurs
                directly after aTHENorELSEkeyword will not be used.COMMONin the second or later statements of a compound statement afterTHENorELSEwill be used regardless of the value of theIFcondition.
    
        CONT
        
            CONT [anything]
        
        
            Resumes execution of a program that has been halted by
            STOP, END,
            Ctrl+C, or  Ctrl+Break.
        
        Notes
        
            - 
                Anything after the CONTkeyword is ignored.
- 
                This statement can only be used in direct mode.
            
- 
                If a break is encountered in GOSUBroutine called from a continuing
                direct line (e.g.GOSUB 100:PRINT A$),CONTwill overwrite the running
                direct line. As the subroutineRETURNs to the position after theGOSUBin
                the old direct line, strange things may happen if commands are given afterCONT. In GW-BASIC, this can lead to strange errors in non-existing
                program lines as the parser executes bytes that are not part of a program
                line. In PC-BASIC, if the new direct line is shorter, execution stops
                afterRETURN; but if the direct line is extended beyond the old return
                position, the parser tries to resume at that return position, with strange
                effects.
Errors
        
            - 
                No program is loaded, a program has not been run, after a program line
                has been modified or after CLEAR: Can't continue.
- 
                The break occurred in a direct line: Can't continue.
            
- 
                CONTis used in a program: Can't continue.
    
        DATA
        
            DATA [const_0] [, [const_1]] ...
        
        
            Specifies data that can be read by a READ statement.
        
        Parameters
        
            - 
                const_0, const_1, ...are string and number literals or may be empty. String literals can be given
                with or without quotation marks. If quotation marks are omitted, leading and
                trailing whitespace is ignored and commas or colons will terminate the data
                statement.
Notes
        
            - 
                DATAdeclarations need not be reachable in the program flow in order to be used.
                They may occur anywhere before or after theREADstatement that uses them.
- 
                If the DATAkeyword is not the first element of the statement, the
                declaration will be ignored. In particular, anyDATAdeclaration that occurs
                directly after aTHENorELSEkeyword will not be used.DATAin the second or later statements of a compound statement afterTHENorELSEwill be used regardless of the value of theIFcondition.
Errors
        
            - 
                If the type of the literal does not match that of the corresponding READstatement, a Syntax error occurs on theDATAstatement.
    
        DATE$ (statement)
        
            DATE$ = date
        
        
            Sets the system date. date is a string expression that represents a
            date in one of the formats: "mm{-|/}dd{-|/}yy" or
            "mm{-|/}dd{-|/}yyyy"
        
        
            Of these,
        
        
            - 
                mmmay be one or two characters long and must be in[1—12].
- 
                ddmay be one or two characters long and must be in[1—31].
- 
                yyyymust be in[1980—2099].
- 
                yymay be one or two characters long and must be in one of the ranges:
                    - 
                        [0—77], interpreted as2000—2077; or
- 
                        [80—99], interpreted as1980—1999.
 
Notes
        
            - 
                The system date is not actually changed; rather, PC-BASIC remembers the
                offset from the true system date. This avoids requiring user permission
                to change the system time.
            
- 
                GW-BASIC appears to accept invalid dates such as "02-31-2000". PC-BASIC
                raises Illegal function call for these.
Errors
        
            - 
                datehas a numeric value: Type mismatch.
- 
                dateis not in the format specified above:
                Illegal function call.
    
        DEF FN
        
            DEF FN[ ]name [(arg_0 [, arg_1] ...)] = expression
        
        
            Defines a function called FNname
            (or FN name: spaces between FN and name are optional).
            On calling FNname( ... ), expression is
            evaluated with the supplied parameters substituted. Any variable names used in the function that are not
            in the argument list refer to the corresponding global variables.
            The result of the
            evaluation is the return value of FNname. The type of the return value
            must be compatible with the type indicated by name.
        
        Notes
        
            - 
                This statement may only be used on a program line.
            
- 
                As the function must be a single expression and PC-BASIC does not have a ternary operator, there is
                no way to define a recursive function that actually terminates.
            
Parameters
        
            - 
                namemust be a legal variable name.
- 
                arg_0, arg_1, ...must be legal variable names. These are the parameters of the
                function. Variables of the same name may or may not exist in the program; their value is not affected or used by the defined function.
- 
                expressionmust be a legal PC-BASIC expression.
Errors
        
            - 
                The statement is executed directly instead of in a program line: Illegal direct.
            
- 
                If the type of the return value is incompatible with the type of name,
                no error is raised at theDEF FNstatement; however, a Type mismatch
                will be raised at the first call ofFNname.
    
        DEFINT, DEFDBL, DEFSNG, DEFSTR
        
            {DEFINT|DEFDBL|DEFSNG|DEFSTR} first_0[- last_0] [, first_1[- last_1]] ...
        
        
            Sets the type that is assumed if no sigil is specified when a variable name is used.
            The statement sets the default type for variables starting with a letter from the ranges specified.
        
        
            The default type is set to:
        
        
            - DEFINT
- integer (%)
- DEFDBL
- double (#)
- DEFSNG
- single (!)
- DEFSTR
- string ($)
Parameters
        
            - 
                first_0, last_0, ...are letters of the alphabet.
                Pairs of letters connected by a dash-indicate inclusive ranges.
Notes
        
            - 
                DEFSNG A-Zis the default setting.
    
        DEF SEG
        
            DEF SEG [= address]
        
        
            Sets the memory segment to be used by BLOAD, BSAVE, CALL,
            PEEK, POKE, and USR.
        
        Parameters
        
            - 
                addressis a numeric expression in[-32768—65535].
Notes
        
            - 
                If addressis negative, it is interpreted as its two's complement.
- 
                If addressis not specified, the segment is set to the GW-BASIC data
                segment.
Errors
        
            - 
                addresshas a string value: Type mismatch.
- 
                addressis not in[-32768—65535]: Overflow.
    
        DEF USR
        
            DEF USR[n] = address
        
        
            Does nothing.
        
        Parameters
        
            - 
                nis a digit between 0 and 9 inclusive.
- 
                addressis a numeric expression in[-32768—65535].
Notes
        
            - 
                In GW-BASIC, this statement sets the starting address of an assembly-language function.
            
- 
                This statement is not implemented in PC-BASIC.
            
- 
               If addressis negative, it is interpreted as its two's complement.
Errors
        
            - 
            nis not a digit in[0—9]: Syntax error.
- 
            addresshas a string value: Type mismatch.
- 
            addressis not in[-32768—65535]: Overflow.
    
        DELETE
        
            DELETE [line_number_0|.] [-[line_number_1|.] ]
        
        
            Deletes a range of lines from the program.
            Also stops program execution and returns control to the user.
        
        Parameters
        
            - 
                line_number_0andline_number_1are line numbers in the range[0—65529], specifying the inclusive range of line numbers to delete.
- 
                A .indicates the last line edited.
- 
                If the start point is omitted, the range will start at the start of the program.
            
- 
                If the end point is omitted, the range will end at the end of the program.
            
- 
                If no range is specified, the whole program will be deleted.
            
Errors
        
            - 
                line_number_0orline_number_1is greater than65529: Syntax error.
- 
                The range specified does not include any program lines stored: Illegal function call.
            
    
        DIM
        
            DIM name [{(|[} limit_0 [, limit_1] ... {)|]}] [, ... ]
        
        
            Allocates memory for one or more arrays.
            The DIM statement also fixes the number of indices of the array.
            An array can only be allocated once; to re-allocate an array, ERASE or
            CLEAR must be executed first.
            If an array is first used without a DIM statement, it is automatically allocated with its maximum indices set at 10
            for each index position used.
            A DIM entry with no brackets and no indices performs no operation. Empty brackets are not allowed.
            The least index allowed is determined by OPTION BASE.
        
        Parameters
        
            - 
                name, ...are legal variable names
                specifying the arrays to be allocated.
- 
                limit_0, limit_1, ...are numeric
                expressions that specify the greatest index allowed at that position.
Notes
        
            - 
                Mixed brackets are allowed.
            
- 
                The size of arrays is limited by the available BASIC memory.
            
- 
                The maximum number of indices is, theoretically, 255. In practice,
                it is limited by the 255-byte limit on the length of program lines.
Errors
        
            - 
                namehas already been dimensioned: Duplicate definition.
- 
                An index is empty: Syntax error.
            
- 
                An index is missing at the end: Missing operand.
            
- 
                limit_0, limit_1, ...have a string value: Type mismatch.
- 
                limit_0, limit_1, ...are not within[-32768—32767]: Overflow.
- 
                limit_0, limit_1, ...are negative: Illegal function call.
- 
                The array exceeds the size of available variable
                space: Out of memory.
            
    
        DRAW
        
            DRAW gml_string
        
        
            Draws the shape specified by gml_string,
            a string expression in Graphics Macro Language (GML).
        
        Graphics Macro Language reference
        
            - Movement commands
- 
                
                    [B][N] movement
                where the default is to move and draw; the optional prefixes mean:
                
                andmovementis one of:
                    where nis an integer in[-32768—32767]andx,yare integers in[0—9999].
                    Where optional,ndefaults to1.
 
- Scale commands
- 
                
            
- Colour commands
- 
                
            
- Subroutine command
- 
                
                sis one of the following:
 
                    - a string variable name followed by semicolon (;)
- the result of VARPTR$()on a string variable
 
            Numeric variables n, x,
            y, b in the commands above can be:
        
        
            - 
                an integer literal, e.g. DRAW "U100"
- 
                a numeric variable name or array element varpreceded by=and followed by;.
                For example,DRAW "U=VAR;"orDRAW "U=A(1);"
- 
                the result of VARPTR$(var)preceded by=.  For example,DRAW "U=" + VARPTR$(VAR)
Notes
        
            - 
                The CLSstatement resets the step size to 1 pixel, angle to 0 degrees and position to the
                centre of the view region.
- 
                The value nin theTA,AandCcommand can be left out but only if the
                command is terminated by a semicolon.ndefaults to0.
- 
                In GW-BASIC, the numeric arguments of U,L,D,R,E,F,G,H, andCcan be in the range[-99999—99999];
                however, results for large numbers are unpredictable. This is not implemented in PC-BASIC.
Errors
        
            - 
                gml_stringhas a numeric value: Type mismatch.
- 
                gml_stringhas errors in the GML: Illegal function call.
- 
                A variable referenced in the GML string is of incorrect type: Type mismatch.
            
    
        EDIT
        
            EDIT {line_number|.}
        
        
            Displays the specified program line with the cursor positioned for editing.
            line_number must be a line that exists in the program, or a period (.) to
            indicate the last line stored.
        
        Errors
        
            - 
                No line_number is specified: Undefined line number.
            
- 
                More characters are written after the line number: Illegal function call.
            
- 
                line_numberis not in[0—65529]: Illegal function call.
- 
                The specified line number does not exist: Undefined line number.
            
    
        ELSE
        
            ELSE [anything]
        
        
            Unless part of an IF statement on the same line, anything after ELSE is ignored
            in the same way as after ' or :REM. No colon : preceding
            the ELSE statement is necessary. See IF for normal usage.
        
    
    
        END
        
            END
        
        
            Closes all files, stops program execution and returns control to the user.
            No message is printed. It is possible to resume execution at the next statement
            using CONT.
        
    
    
        ENVIRON
        
            ENVIRON command_string
        
        
            Sets a shell environment variable.
        
        Parameters
        
            command_string is a string expression of one of the following forms:
        
        
            - 
                
                    "VARIABLE=VALUE"
                
- 
                to set VARIABLEtoVALUE;
- 
                
                    "VARIABLE="
                
- 
                to unset VARIABLE.
Errors
        
            - 
                command_stringhas a numeric value: Type mismatch.
- 
                command_stringis not of the required form: Illegal function call.
    
        ERASE
        
            ERASE array_0 [, array_1] ...
        
        
            De-allocates arrays. The data stored in the
            arrays is lost.
        
        Parameters
        
            - 
                array_0, array_1 ...are names of existing arrays. The names must be
                specified without brackets.
Errors
        
            - 
                No array names are given: Syntax error.
            
- 
                array_0, array_1 ...do not exist: Illegal function call.
- 
                If an error occurs, the arrays named before the error occurred are erased.
            
    
        ERROR
        
            ERROR error_number
        
        
            Raises the error with number error_number.
        
        Parameters
        
            - 
                error_numberis an expression
                with a numeric value.
Errors
        
            - 
                error_numberhas a string value: Type mismatch.
- 
                error_numberis not in[-32768—32767]: Overflow.
- 
                error_numberis not in[1—255]: Illegal function call.
    
        FIELD
        
            FIELD [#] file_number [, width_0 AS name_0 [, width_1 AS name_1] ...]
        
        
            Assigns variables to the random-access record buffer. The record buffer is a
            region of memory of length defined by the OPEN statement; the default record
            length is 128 bytes. The FIELD statement assigns a portion of this region to
            one or more fixed-length string variables, so that the value of these strings
            is whatever happens to be in the record buffer at that location.
        
        Notes
        
            - 
                A FIELDstatement
                without any variables specified has no effect.
- 
                Another  FIELDstatement on the same file will specify an alternative mapping of the
                same file buffer; all mappings will be in effect simultaneously.
- 
                A subsequent assignment or LETorMID$statement onname_0 , name_1 ...will dis-
                associate the string variable from the field buffer.
- 
                Use LSET,RSETorMID$to copy values into aFIELDbuffer.
- 
                Use GETto read values from the file into the field
                buffer, changing the variables.
- 
                Use PUTto write the field buffer to the file.
Parameters
        
            - 
                file_numberis a numeric expression that yields the number of an open random-access file. The#is optional and has no effect.
- 
                width_0, width_1, ...are numeric
                expressions giving the length of the string variables
- 
                name_0 , name_1 ...are string variables.
Errors
        
            - 
                file_numberis not in[0—255]: Illegal function call.
- 
                file_numberis not the number of an open file:
                Bad file number.
- 
                file_numberis open under a mode other thanRANDOM:
                Bad file mode.
- 
                The statement ends in a comma: Missing operand.
            
- 
                No file number is specified: Missing operand.
            
- 
                The lengths in a FIELDstatement add up to a number larger than the
                record length of the field buffer: Field overflow.
- 
                name_0 , name_1 ...specify a non-string variable: Type mismatch.
    
        FILES
        
            FILES [filter_spec]
        
        
            Displays the files fitting the specified filter in the specified directory on a disk device. If
            filter_spec is not specified, displays all files in the current working
            directory.
        
        Parameters
        
            - 
                filter_specis a string expression that
                is much like a file specification, but optionally allows the file
                name part to contain wildcards.
Notes
        
            - 
                The filename filter may contain the following wildcards:
                
            
- 
                The filter
                will only match MS-DOS style filenames.
            
- 
                Matched character series do not stretch across directory separators \or extension separators.. To match all files with all extensions,
                use*.*.
- 
                Alternatively, if all files in a
                specified directory are required, end the directory name with a backslash \.
Errors
        
            - 
                filter_spechas a numeric value: Type mismatch.
- 
                filter_specis the empty string: Bad file name.
- 
                The specified filter does not match any files: File not found.
            
    
        FOR
        
            FOR loop_var = start TO stop [STEP step]
        
        
            Initiates a FOR—NEXT loop.
        
        
            Initially, loop_var is set to start. Then, the statements between the FOR
            statement and the NEXT statement are executed and loop_var is incremented by
            step (if step is not specified, by 1). This is repeated until loop_var
            has become greater than stop. Execution then continues at the statement
            following NEXT. The value of loop_var equals stop+step after the loop.
        
        
            start, stop and step are evaluated only once and the resulting
            values are used throughout the loop.
        
        Parameters
        
            - 
                loop_varis an integer or single-precision variable.
- 
                start,stopandstepare numeric expressions.
Errors
        
            - 
                No NEXTstatement is found to match theFORstatement: FOR without NEXT occurs at theFORstatement.
- 
                loop_varis a string variable orstart,stop, orendhas a string value:
                Type mismatch.
- 
                loop_varis a double-precision variable:
                Type mismatch.
- 
                loop_varis an array element: Syntax error .
- 
                loop_varis an integer variable and astart,stoporstepis outside the range[-32768, 32767]: Overflow .
    
        GET (files)
        
            GET [#] file_number [, record_number]
        
        
            Read a record from the random-access file file_number at position
            record_number.
            The record can be accessed through the FIELD
            variables or through INPUT$,
            INPUT or
            LINE INPUT.
        
        Parameters
        
            - 
                file_numberis a numeric expression that yields the number
                of an open random-access file. The#is optional and has no effect.
- 
                record_numberis a numeric expression in[1—33554432](2^25), and is interpreted as the record number.
Notes
        
            - 
                If the record number is beyond the end of the file, the file buffer is
                filled with null bytes.
            
- 
                The record number is stored as single-precision; this precision is not high enough to distinguish single
                records near the maximum value of 2^25.
Errors
        
            - 
                record_numberis not in[1—33554432]: Bad record number.
- 
                file_numberis not in[0—255]: Illegal function call.
- 
                file_numberis not the number of an open file:
                Bad file mode.
- 
                file_numberis open under a mode other thanRANDOM:
                Bad file mode.
- 
                file_numberis not specified: Missing operand.
    
        GET (communications)
        
            GET [#] com_file_number [, number_bytes]
        
        
            Read number_bytes bytes from the communications buffer opened under file
            number com_file_number.
            The record can be accessed through the FIELD
            variables or through INPUT$,
            INPUT or
            LINE INPUT.
        
        Parameters
        
            - 
                file_numberis a numeric expression that yields the number
                of a file open to aCOMdevice. The#is optional and has no effect.
- 
                number_bytesis a numeric expression between1and theCOMbuffer length, inclusive.
Notes
        
            - 
                If bytesis32768or greater, GW-BASIC hangs. This functionality is not implemented in PC-BASIC.
- 
                In GW-BASIC, Device I/O error is raised for overrun error, framing error,
                and break interrupt. Device fault is raised if DSR is lost during I/O.
                Parity error is raised if parity is enabled and incorrect parity is
                encountered. This is according to the manual; it is untested.
            
Errors
        
            - 
                bytesis less than 1: Bad record number
- 
                bytesis less than32768and greater than theCOMbuffer length: Illegal function call.
- 
                com_file_numberis not specified: Missing operand.
- 
                com_file_numberis not in[0—255]: Illegal function call.
- 
                com_file_numberis not the number of an open file:
                Bad file number.
- 
                If the serial input buffer is full, i.e. LOF(com_file_number) = 0, andLOC(com_file_number) = 255: Communication buffer overflow
- 
                If the carrier drops during GET, hangs until the Ctrl+Break key is pressed.
    
        GET (graphics)
        
            GET (x0, y0) - [STEP] (x1, y1), array_name
        
        
            Stores a rectangular area of the graphics screen in an array.
            The area stored is a rectangle parallel to the screen edges, bounded by the
            top-left and bottom-right coordinates x0,y0 and x1,y1. If STEP is
            specified, x1,y1 is an offset from x0,y0. The area is such that these
            corner points are inside it.
        
        
            The image stored in the array can then be put on the screen using PUT. For the
            purposes of GET, any array is considered a string of bytes. The byte size of an
            array can be calculated as number_elements * byte_size with byte_size equal to
            2 for integers (%), 4 for single (!) and 8 for double (#).
            Array byte size for
            string is 3, but string arrays are not allowed in GET. For calculating the
            number of elements, keep in mind that OPTION BASE 0 is the default; in which
            case an array with maximum index 10 has 11 elements. This works through in
            multidimensional arrays.
        
        
            The array format is as follows:
        
        
        Parameters
        
            - 
                array_nameis the name of a numeric array dimensioned with enough space to store the area.
- 
                x0,y0,x1,y1are numeric expressions.
Notes
        
            - 
                In PCjr/Tandy mode, in SCREEN 6,GETstores an area of twice the width
                of the specified rectangle.
Errors
        
            - 
                The array does not exist: Illegal function call.
            
- 
                array_namerefers to a string array: Type mismatch.
- 
                The area is too large for the array: Illegal function call.
            
- 
                x0, ...y1are string expressions: Type mismatch.
- 
                x0, ...y1are not in[-32768—32767]: Overflow.
- 
                x0, ...y1are outside the currentVIEWorWINDOW:
                Illegal function call
    
        GOSUB
        
            GO[ ]SUB line_number [anything]
        
        
            Jumps to a subroutine at line_number. The next
            RETURN statement jumps back to
            the statement after GOSUB. Anything after line_number until the end of the
            statement is ignored. If executed from a direct line, GOSUB runs the subroutine and
            the following RETURN returns execution to the direct line.
        
        Parameters
        
            - 
                line_numberis an existing line number literal.
- 
                Further characters on
                the line are ignored until end of statement.
            
Notes
        
            - 
                If no RETURNis encountered, no problem.
- 
                One optional space is allowed between GOandSUB; it will not be retained in
                the program.
Errors
        
            - 
                If line_numberdoes not exist: Undefined line number.
- 
                If line_numberis greater than65529, only the first 4 characters are
                read (e.g.6553)
    
        GOTO
        
            GO[ ]TO line_number [anything]
        
        
            Jumps to line_number.  Anything after line_number until the end of the
            statement is ignored. If executed from a direct line, GOTO starts execution of the program at the specified line.
        
        Parameters
        
            - 
                line_numberis an existing line number literal.
- 
                Further characters on
                the line are ignored until end of statement.
            
Notes
        
            - 
                Any number of optional spaces is allowed between GOandTO, but they will
                not be retained in the program.
- 
                If line_numberis greater than65529, only the first 4 characters are
                read (e.g.GOTO 65530is executed asGOTO 6553)
Errors
        
            - 
                line_numberdoes not exist: Undefined line number.
    
        IF
        
            IF truth_value [,] {THEN|GOTO} [compound_statement_true|line_number_true [anything]]
            [ELSE [compound_statement_false|line_number_false [anything]]]
       
        
            If truth_value is non-zero, executes compound_statement_true or jumps to line_number_true .
            If it is zero, executes compound_statement_false or jumps to line_number_false .
        
        Parameters
        
            - 
                truth_valueis a numeric expression.
- 
                line_number_falseandline_number_trueare existing line numbers.
- 
                compound_statement_falseandcompound_statement_trueare compound statements,
                consisting of at least one statement, optionally followed by further statements separated by colons:. The compound statements
                may contain nestedIF—THEN—ELSEstatements.
Notes
        
            - 
                The comma is optional and ignored.
            
- 
                ELSEclauses are optional; they
                are bound to the innermost freeIFstatement if nested. AdditionalELSEclauses that have no matchingIFare ignored.
- 
                All clauses must be on the same
                program line.
            
- 
               THENandGOTOare interchangeable; which one is chosen is independent
                of whether a statement or a line number is given.GOTO PRINT 1is fine.
- 
                As in GOTO, anything after the line number is ignored.
Errors
        
            - 
               If truth_valuehas a string value: Type mismatch.
- 
                truth_valueequals0andline_number_falseis a non-existing line number,
                ortruth_valueis nonzero andline_number_trueis a non-existing line number:
                Undefined line number.
    
        
        
            INPUT [;] [prompt {;|,}] var_0 [, var_1] ...
        
        
            Prints prompt to the screen and waits for the user to input values for the specified variables.
            The semicolon before the prompt, if present,
            stops a newline from being printed after the values have been entered.
            If the prompt is followed by a semicolon, it is printed with a trailing ?. If
            the prompt is followed by a comma, no question mark is added.
        
        Parameters
        
            - 
                promptis a string literal.
- 
                var_0, var_1, ...are variable names or fully indexed array elements.
Notes
        
            - 
                Values entered must be separated by commas. Leading and trailing whitespace
                is discarded.
            
- 
                String values can be entered with or without double quotes (").
- 
                If a string with a comma, leading or trailing whitespace is needed,
                quotes are the only way to enter it.
            
- 
                Between a closing quote and the comma at the end of the entry, only white-
                space is allowed.
            
- 
                If quotes are needed in the string itself, the first character must be
                neither a quote nor whitespace. It is not possible to enter a string that
                starts with a quote through INPUT.
- 
                If a given var_nis a numeric variable, the value entered must be
                number literal.
- 
                Characters beyond the 255th character of the screen line are discarded.
            
- 
                If user input is interrupted by Ctrl+Break,
                CONTwill re-execute theINPUTstatement.
Errors
        
            - 
                If the value entered for a numeric variable is not a valid numeric literal,
                or the number of values entered does not match the number of variables in
                the statement,
                ?Redo from start is printed and all values must be entered again.
            
- 
                A Syntax error that is caused after the prompt is printed is only raised
                after the value shave been entered. No values are stored.
            
    
        
        
            INPUT # file_num, var_0 [, var_1] ...
        
        
            Reads string or numeric variables from a text file or the FIELD buffer
            of a random access file.
        
        Parameters
        
            - 
                file_numis the number of a file open inINPUTmode or a random-access file open inRANDOMmode.
- 
                var_0, var_1, ...are variable names or fully indexed array elements.
Notes
        
            - 
                The #is mandatory. There may or may not be whitespace betweenINPUTand#.
- 
                String values can be entered with or without double quotes (").
- 
                Numeric values are terminated by  ,LF,CR,,.
- 
                Unquoted strings are terminated by LF,CR,,.
- 
                Quoted strings are terminated by the closing quote.
            
- 
                Any entry is terminated by EOFcharacter or its 255th character.
- 
                Leading and trailing whitespace is discarded.
            
- 
                If the entry cannot be converted to the requested type, a zero value is
                returned.
            
- 
                If file_numis open toKYBD:,INPUT#reads from the keyboard until a
                return or comma is encountered (as in a file). Arrow keys and delete are
                passed as their control characters (not scancodes!) preceded byCHR$(&hFF).
Errors
        
            - 
                Input is requested after the end of a text file has been reached or an
                EOFcharacter has been encountered: Input past end.
- 
                The last character of the field buffer is read: Field overflow.
            
- 
                file_numhas a string value: Type mismatch.
- 
                file_numis greater than32767: Overflow.
- 
                file_numis less than zero: Illegal function call.
- 
                file_numis not an open file: Bad file number.
- 
                file_numis not open forINPUTorRANDOM: Bad file mode.
- 
                file_numis open to aCOMport and this is the
                firstINPUT,LINE INPUTorINPUT$call on that port
                since the buffer has filled up completely (i.e.LOF(file_num)has become zero):
                Communication buffer overflow.
    
        IOCTL
        
            IOCTL [#] file_num, control_string
        
        
            Raises Illegal function call.
        
        Notes
        
            - 
                In GW-BASIC, IOCTLsends a control string to a device.
- 
                This statement is not implemented in PC-BASIC.
            
Errors
        
            - 
                file_numhas a string value: Type mismatch.
- 
                file_numis not in[-32768—32767]: Overflow.
- 
                file_numis not an open file: Bad file number.
- 
               Otherwise: Illegal function call
            
    
        KEY (macro list)
        
            KEY {ON|OFF|LIST}
        
        
            Turns the list of function-key macros on the bottom of the screen ON or OFF.
            If LIST is specified, prints a list of
            the 10 (or 12 with syntax=tandy) function keys
            with the function-key macros defined for those keys to the console.
        
        
            Most characters are represented by their symbol equivalent in the current codepage.
            However, some characters get a different representation, which is a symbolic representation
            of their effect as control characters on the screen.
        
        
    
    
        KEY (macro definition)
        
            KEY key_id, string_value
        
        
            Defines the string macro for function key key_id.
            Only the first 15 characters of string_value are stored.
        
        Parameters
        
            - 
                key_idis a numeric expression in the range[1—10](or[1—12]whensyntax=tandy).
- 
                string_valueis a string expression.
Notes
        
            - 
                If key_idis not in the prescribed range,
                the statement is interpreted as an
                event-trappingKEYstatement.
- 
                If string_valueis the empty string or
                the first character ofstring_valueisCHR$(0), the function key macro is switched off and
                subsequent catching of the associated function key withINKEY$is enabled.
Errors
        
            - 
                key_idis not in[-32768—32767]: Overflow.
- 
                key_idis not in[1—255]: Illegal function call.
- 
                key_idhas a string value: Type mismatch.
    
        KEY (event switch)
        
            KEY (key_id) {ON|OFF|STOP}
        
        
            Controls event trapping of the key with identifier key_id.
            Event trapping is switched ON or OFF. STOP suspends event trapping until
            a KEY() ON is executed. Up to one event can be triggered during
            suspension, provided that event handling was switched on prior to suspension.
            The event triggered during suspension is handled immediately after the next KEY() ON
            statement.
        
        Parameters
        
            key_id is a numeric expression in [1—20].
            Keys are:
        
        
        
            Keys 15 to 20 are defined using the event trapping
            KEY definition statement.
        
        Notes
        
            - 
                With syntax=tandy, key 11
                is F11 and key 12 is F12.
                Pre-defined keys 11—14 shift to 13—16.
Errors
        
            - 
                key_idis not in[-32768—32767]: Overflow.
- 
                key_idis not in[0—20]: Illegal function call.
- 
                key_idhas a string value: Type mismatch.
    
        KEY (event definition)
        
            KEY key_id, two_char_string
        
        
            Defines the key to trap for key_id.
        
        Parameters
        
            - 
                key_idis a numeric
                expression in[15—20](or[17—20]whensyntax=tandy).
- 
                two_char_stringis a string expression of length 2. The first character is interpreted as a modifier
                while the second character is interpreted as a scancode.
                The modifier character is a bitwiseORcombination of the following flags:
                
                For the unmodified key, the modifier character isCHR$(0).
Notes
        
            - 
                If key_idis not in the prescribed range, no error is raised; such values are ignored.
                In GW-BASIC strange things can
                happen in this case: screen anomalies and crashes suggestive of unintended
                memory access.
- 
                If key_idis in[1—10](or[1—12]whensyntax=tandy),
                the statement is interpreted as a
                function-key macro definition.
Errors
        
            - 
                key_idis not in[-32768—32767]: Overflow.
- 
                key_idis not in[1—255]: Illegal function call.
- 
                key_idhas a string value: Type mismatch.
- 
                two_char_stringis longer than two: Illegal function call.
- 
                two_char_stringhas a numeric value: Type mismatch.
    
        KILL
        
            KILL filter_spec
        
        
            Deletes one or more files on a disk device.
        
        Parameters
        
            - 
                The string expression filter_specis a
                valid file specification indicating the files to delete.
                Wildcards are allowed. SeeFILESfor a description
                of wildcards.
Notes
        
            - 
                Be very careful with the use of wildcards in this statement: the DOS matching rules may
                not be the same as what is usual on your operating system, which could result in
                unexpected files being deleted.
            
- 
                This statement may not delete hidden file and files that do not have short names
                which are legal DOS names. However, this behaviour is not guaranteed
                so you must not depend on it.
            
Errors
        
            - 
                filter_specis a numeric value: Type mismatch.
- 
                A file with a base name equal to that of a file matching filter_specis open: File already open
- 
                No file matches filter_spec: File not found
- 
                The user has no write permission: Permission denied
            
- 
                If a syntax error occurs after the closing quote, the file is removed anyway.
            
    
        LCOPY
        
            LCOPY [num]
        
        
            Does nothing.
        
        Parameters
        
            - 
                numis a numeric expression in[0—255].
Notes
        
            - 
                This statement does nothing in GW-BASIC. Presumably, it is left over from a
                statement in older versions of MS Basic that would copy the screen to the
                printer.
            
Errors
        
            - 
                numis not in[-32768—32767]: Overflow.
- 
                numis not in[0—255]: Illegal function call.
- 
                numhas a string value: Type mismatch.
    
        LET
        
            [LET] name = expression
        
        
            Assigns the value of expression to the variable or array element name.
        
        Parameters
        
            - 
                nameis a variable that may or may not already exist.
- 
                The
                type of expressionmatches that ofname: that is, all numeric types can
                be assigned to each other but strings can only be assigned to strings.
Errors
        
            - 
                nameandexpressionare not of matching types: Type mismatch.
    
        LINE
        
            LINE [[STEP] (x0, y0)] - [STEP]
            (x1, y1) [, [attr] [, [B [F]] [, pattern]]]
        
        
            Draws a line or a box in graphics mode. If B is not specified, a line is drawn
            from (x0, y0) to (x1, y1), endpoints inclusive.
            If B is specified, a
            rectangle is drawn with sides parallel to the screen and two opposing corners
            specified by (x0, y0) and (x1, y1). If the starting point is not given,
            the current graphics position is used as a staring point.  If STEP is
            specified, (x0, y0) is an offset from the current position and (x1, y1) is an
            offset from (x0, y0).
            LINE moves the current graphics position to the last given endpoint.
            If F is specified with B, the rectangle is filled with the specified attribute.
            F and B may be separated by zero or more spaces.
        
        Parameters
        
            - 
                attris a numeric expression in[0—255], which
                specifies the colour attribute of the line. If it is not given, the current
                attribute is used.
- 
                patternis a numeric expression in[-32768—32767].
                This is interpreted as a 16-bit binary pattern mask
                applied to consecutive pixels in the line: a 1 bit indicates a pixel
                plotted; a 0 bit indicates a pixel left untouched. The pattern starts at
                the most significant bit, which is applied to the topmost endpoint. If a
                box is drawn, the pattern is applied in the following counter-intuitive
                sequence:(x1, y1)—(x0, y1),(x1, y0)—(x0, y0),
                then(x1, y0)—(x1, y1),(x0, y0)—(x0, y1)ify0<y1andy0,y1reversed ify1<y0. When drawing a
                filled box,LINEignores the pattern.
Notes
        
            - 
                If a coordinate is outside the screen boundary, it is replaced with -1 (if
                less than 0) or the screen dimension (if larger than the screen dimension).
            
Errors
        
            - 
                The statement ends in a comma and it is the first or third: Missing operand. If it is the second: Syntax error.
            
- 
                Any of the coordinates is not in [-32768—32767]: Overflow.
- 
                Any of the parameters has a string value: Type mismatch.
            
    
        
        
            LINE INPUT [;] [prompt_literal {;|,}] string_name
        
        
            Displays the prompt given in prompt_literal and reads user input from the
            keyboard, storing it into the variable string_name. All input is read until
            Enter is pressed; the first 255 characters are stored. If the ; is given
            right after LINE INPUT, the Enter ending user input is not echoed to the
            screen.
        
        Parameters
        
            - 
                prompt_literalis a string literal. It makes no difference whether it is
                followed by a comma or a semicolon.
- 
                string_nameis a string variable or array element.
Notes
        
            - 
                If user input is interrupted by Ctrl+Break, CONTwill re-execute theLINE
                INPUTstatement.
- 
                Unlike INPUT,LINE INPUTdoes not end the prompt with?.
    
        
        
            LINE INPUT # file_num, string_name
        
        
            Reads string or numeric variables from a text file or the FIELD buffer
            of a random access file. All input is read until Enter is pressed; the first
            255 characters are stored. file_num must be the number of a file open in
            INPUT mode or a random-access file open in RANDOM mode.
        
        Parameters
        
            - 
                string_nameis a string variable or array element.
Notes
        
            - 
                The #is mandatory. There may or may not be whitespace betweenINPUTand#.
- 
                Input is only terminated by a CR.
- 
                If file_numis open toKYBD:,LINE INPUT#reads from the keyboard until a
                return or comma is encountered (as in a file). Arrow keys and delete are
                passed as their control characters (not scancodes!) preceded byCHR$(&hFF).
Errors
        
            - 
                Input is requested after the end of a text file has been reached or an
                EOFchar has been encountered: Input past end.
- 
                The last character of the field buffer is read: Field overflow.
            
- 
                file_numis not an open file: Bad file number.
- 
                file_numis less than zero: Illegal function call.
- 
                file_numis not in[-32768—32767]: Overflow.
- 
                file_numis not open forINPUTorRANDOM: Bad file mode.
- 
                file_numhas a string value: Type mismatch.
- 
                file_numis open to aCOMport and this is the
                firstINPUT,LINE INPUTorINPUT$call on that port
                since the buffer has filled up completely (i.e.LOF(file_num)has become zero):
                Communication buffer overflow.
    
        LIST
        
            LIST [line_number_0|.] [-[line_number_1|.]] [, file_spec [anything]]
        
        
            Prints the program to the screen or a file,
            starting with line_number_0 up to and
            including line_number_1.
            Also stops program execution and returns control to the user.
            If the LIST statement ends with a file specification, anything further is ignored.
            In all cases, any further
            statements in a compound after LIST will be ignored, both in a program and in direct mode.
        
        
            When listing to the screen, the same control characters are recognised as in the
            PRINT statement.
        
        Notes
        
            - 
                In GW-BASIC 3.23, LISTwill not show line numbers65531—65535inclusive.
                By default, PC-BASIC'sLISTdoes show these lines. However,
                showing them can be disabled with the optionhide-listing=65530.
Parameters
        
            - 
                line_number_0andline_number_1are
                line numbers in the range[0—65529]or a.to indicate the last line edited. The line numbers do not need to exist;
                they specify a range. If the range is empty, nothing is printed.
- 
                The string expression file_specis a
                valid file specification indicating the file to list to.
                If this file already exists, it will be overwritten.
Errors
        
            - 
                A line number is greater than 65529: Syntax error.
- 
                file_spechas a numeric value: Type mismatch.
- 
                file_specends in a colon but is not a device name or drive letter:
                Bad file number.
- 
                file_speccontains disallowed characters:
                Bad file number (onCAS1:);
                Bad file name (on disk devices).
    
        LLIST
        
            LLIST [line_number_0|.] [-[line_number_1|.]]
        
        
            Prints the program to the screen, starting with line_number_0 up to and
            including line_number_1.
            Also stops program execution and returns control to the user. Any further
            statements on a line after LLIST will be ignored, both in a program and in direct mode.
        
        Notes
        
            - 
                In GW-BASIC 3.23, LLISTwill not show line numbers65531—65535inclusive.
                By default, PC-BASIC'sLLISTdoes show these lines. However,
                showing them can be disabled with the optionhide-listing=65530.
Parameters
        
            - 
                line_number_0andline_number_1are  line numbers in the range[0—65529].
                or a.to indicate the last line edited. The line numbers do not need to exist;
                they specify a range. If the range is empty, nothing is printed.
Errors
        
            - 
                A line number is greater than 65529: Syntax error.
    
        LOAD
        
            LOAD file_spec [, R]
        
        
            Loads the program stored in a file into memory.
            Existing variables will be cleared and any program in memory will be erased. LOAD implies a
            CLEAR.
        
        
            If ,R is specified, keeps all data files open and runs the specified file.
        
        Parameters
        
            - 
                The string expression file_specis a valid file specification indicating
                the file to read the program from.
Errors
        
            - 
                file_spechas a numeric value: Type mismatch.
- 
                file_speccontains disallowed characters:
                Bad file number (onCAS1:);
                Bad file name (on disk devices).
- 
                The file specified in file_speccannot be found: File not found.
- 
                A loaded text file contains lines without line numbers:
                Direct statement in file.
            
- 
                A loaded text file contains lines longer than 255 characters:
                Line buffer overflow.
                Attempting to load a text file that has LFrather thanCR LFline endings may cause this error.
    
        LOCATE
        
            LOCATE [row] [, [col] [, [cursor_visible] [, [start_line] [, [stop_line] [,]]]]]
        
        
            Positions the cursor at row, col on the screen and changes the cursor shape and visibility.
            cursor_visible may be 0 or 1. If cursor_visible is 0, it makes
            the cursor invisible; if it is 1, makes the cursor visible. This works only while a program is running.
             The cursor shape is adjusted
             within a character cell to start from start_line and end on end_line where
            start_line and end_line are in [0—31]. If start_line or end_line is
            greater than the character cell height (15), substitute 15.
        
        Notes
        
            - 
                On emulated VGA cards, the cursor shape parameters are interpreted
                in a complicated way that is intended to maintain functional compatibility with CGA.
            
- 
                In GW-BASIC, cursor shape is preserved after pressing Ins twice. The insert-mode cursor is different from the usual half-block.
                In PC-BASIC, insert mode resets the cursor shape to default.
            
- 
                Cursor shape and visibility options have no effect in graphics mode.
            
- 
                Locate accepts a 5th comma at the end, which is ignored.
            
Errors
        
            - 
                Any parameter has a string value: Type mismatch.
            
- 
                Any parameter is not in [-32768—32767]: Overflow.
- 
                rowis outside the current view area: Illegal function call.
- 
                colis greater than the current width: Illegal function call.
- 
                cursor_visibleis not in[0, 1]([0—255]on Tandy/PCjr): Illegal function call.
    
        LOCK
        
            LOCK [#] file_number [, record_0]
        
        
            LOCK [#] file_number, [record_0] TO record_1
        
        
            Locks a file or part of a file against access by other users. On a RANDOM file,
            record_0 is the first record locked and record_1 is the last
            record locked. On any other kind of file record_0 and record_1 have no
            effect. If record_0 is not specified, it is assumed to be 1. If no records
            are specified, the whole file is locked.
        
        Parameters
        
            - 
                file_numberis a numeric expression in[0—255].
- 
                record_0andrecord_1are numeric expressions in[1—2^25-2].
Notes
        
            - 
                In GW-BASIC under MS-DOS, the LOCKcommand requiresSHARE.EXEto be loaded.
                The maximum number of locks is specified in the MS-DOSSHAREcommand. IfSHAREhas
                not been activated or all locks are used,LOCKraises Permission denied.
                PC-BASIC behaves as ifSHAREhas been activated with unlimited locks.
- 
                If file_numberis open forRANDOM,LOCKandUNLOCKstatements must match in terms ofrecord_0andrecord_1. An non-matchingUNLOCKwill raise
                Permission denied.
- 
                To check if another open file is the same file, PC-BASIC only looks at the base name
                of the file, i.e. its DOS name without directories. As a consequence, if a file "test.txt"
                is open and locked, an attempt to lock a file "dir\test.txt" will fail, even if these are
                different files. Conversely, if two file names are different but point to the same file in the
                file system (for example due to file system links), then these will be considered as different files by BASIC.
            
Errors
        
            - 
                Any parameter has a string value: Type mismatch.
            
- 
                file_numis not in[-32768—32767]: Overflow.
- 
                file_numis not in[0—255]: Illegal function call.
- 
                file_numis not an open file: Bad file number.
- 
                LOCK(part of) a file with the same name as a file already locked: Permission denied.
- 
                record_0orrecord_1is not in[1—2^25-2]: Bad record number.
    
    
        LSET
        
            LSET string_name = expression
        
        
            Copies a string value into an existing string variable or array element.
            The value will be left-justified and any remaining characters are replaced by
            spaces.
        
        Parameters
        
            - 
                string_nameis a string variable or array element.
- expressionis a string expression.
Notes
        
            - 
                If expressionhas a value that is longer than the length of the target variable,
                it is truncated at the tail to the length of the target variable.
- 
                If string_namehas not been allocated before, this statement has no effect.
- 
                Use LSET,RSETorMID$to copy values into aFIELDbuffer.
- 
                If LETis used on aFIELDvariable
                instead ofL|RSET, the variable is
                detached from the field and a new, normal string variable is allocated.
Errors
        
            - 
                string_nameis not a string variable: Type mismatch.
- 
                expressiondoes not have a string value: Type mismatch.
    
        MERGE
        
            MERGE file_spec
        
        
            Overlays the lines of a program from a plain-text program file into the existing program. The loaded
            lines overwrite existing lines if they have the same line number.
        
        Parameters
        
            - 
                The string expression file_specis a valid file specification indicating
                the file to read the program from.
Errors
        
            - 
                file_speccannot be found: File not found.
- 
                file_speccontains disallowed characters:
                Bad file number (onCAS1:);
                Bad file name (on disk devices).
- 
                file_specwas not saved as plain text: Bad file mode.
- 
                A loaded text file contains lines without line numbers:
                Direct statement in file.
            
- 
                A loaded text file contains lines longer than 255 characters:
                Line buffer overflow.
                Attempting to load a text file that has LFrather thanCR LFline endings may cause this error.
    
        MID$ (statement)
        
            MID$(string_name, position [, length]) = substring
        
        
            Replaces part of string_name with substring.
        
        Parameters
        
            - 
                string_nameis a valid string variable name.
- 
                positionis a numeric expression between 1 and the string length, inclusive.
- 
                lengthis a numeric expression in[0—255].
Notes
        
            - 
                No whitespace is allowed between MID$and(.
- 
                If substringis longer thanlength, only the firstlengthcharacters
                are used.
- 
                If substringis shorter thanlength, onlyLEN(substring)characters
                are replaced.
Errors
        
            - 
                positionis greater than the length ofstring_name:
                Illegal function call, except iflengthis specified as 0.
- 
                positionis not in[1—255]: Illegal function call.
- 
                lengthis not in[0—255]: Illegal function call.
- 
                positionorlengthare not in[-32768—32767]: Overflow.
    
        MKDIR
        
            MKDIR dir_spec
        
        
            Creates a new directory on a disk device.
        
        Parameters
        
            - 
                The string expression dir_specis a valid
                file specification that specifies the
                path of the new directory on a disk device.
Errors
        
            - 
                dir_specis not a string: Type mismatch.
- 
                The parent directory does not exist: Path not found.
            
- 
                The directory name already exists on that path: Path/File access error.
            
- 
                The user has no write permission: Permission denied.
            
    
        MOTOR
        
            MOTOR [num]
        
        
            Does nothing.
        
        Parameters
        
            - 
                numis a numeric expression in[0—255].
Notes
        
            - 
                In GW-BASIC, this statement turns on the cassette motor if numis nonzero or omitted, and turns it off ifnumis zero. This is not implemented in PC-BASIC.
Errors
        
            - 
                numhas a string value: Type mismatch.
- 
                numis not in[-32768—32767]: Overflow.
- 
                numis not in[0—255]: Illegal function call.
    
        NAME
        
            NAME old_name AS new_name
        
        
            Renames the disk file old_name into new_name.
        
        Parameters
        
            - 
                The string expressions old_nameandnew_nameare valid file specifications giving the path on a disk device to the old and new filenames,
                respectively.
Notes
        
        Errors
        
            - 
                old_nameornew_namehave number values: Type mismatch.
- 
                old_namedoes not exist: File not found.
- 
                A file with a base name equal to that of old_nameornew_nameis open: File already open.
- 
                new_nameexists: File already exists.
    
        NEW
        
            NEW
        
        
            Stops execution of a program, deletes the program in memory, executes
            CLEAR and RESTORE
            and returns control to the user.
        
    
    
        NEXT
        
            NEXT [var_0 [, var_1] ...]
        
        
            Iterates a FOR—NEXT loop: increments the loop variable and
            jumps to the FOR
            statement. If no variables are specified, next matches the most recent FOR
            statement. Several nested NEXT statements can be consolidated into one by
            using the variable list. If one or more variables are specified, their order
            must match the order of earlier FOR statements.
        
        Parameters
        
            - 
                var_0, var_1, ...are numeric variables which are loop counters in aFORstatement.
Errors
        
            - 
                No FORstatement is found to match theNEXTstatement and variables:
                NEXT without FOR.
- 
                var_0, var_1, ...are string variables: NEXT without FOR.
- 
                The (implicit or explicit) loop variable is an integer variable and is
                taken outside the range [-32768, 32767]when incremented after the final iteration: Overflow .
    
        NOISE
        
            NOISE source, volume, duration
        
        
            Generates various kinds of noise.
        
        Parameters
        
            - 
                sourceis a numeric expression in[0—7].
                It indicates the type of noise:
- 
                volumeis a numeric expression in[0—15].
- 
                durationis a numeric expression.
            Volume and duration are determined in the same way as for the
            SOUND statement; see there.
        
        Notes
        
            - 
                This statement is only available if
                syntax={pcjr|tandy}is set.
Errors
        
            - 
                SOUND ONhas not been executed: Illegal function call.
- 
                durationis not in[-65535—65535]: Illegal function call.
- 
                volumeis not in[0—15]: Illegal function call.
- 
                sourceis not in[0—7]: Illegal function call.
    
        ON (calculated jump)
        
            ON n {GOTO|GOSUB} line_number_0 [, line_number_1] ...
        
        
            Jumps to the nth line number specified in the list. If n is 0 or greater
            than the number of line numbers in the list, no jump is performed. If GOTO is specified,
            the jump is unconditional; if GOSUB is specified, jumps to a subroutine.
        
        Parameters
        
            - 
                nis a numeric expression in[0—255].
                The expression must not start with theSTRIG,PEN,PLAYorTIMERfunction keywords; if you need these functions, the expression must be bracketed.
- 
                line_number_0, line_number_1, ...are existing line numbers in the program.
Errors
        
            - 
                nhas a string value: Type mismatch.
- 
                nis not in[-32768—32767], Overflow .
- 
                nis not in[0—255]: Illegal function call.
- 
                The line number jumped to does not exist: Undefined line number.
            
    
        ON (event trapping)
        
            ON {COM(n)|KEY(n)|STRIG(n)|PEN|PLAY(n)|TIMER(x)}
            GOSUB line_number
        
        
            Defines an event trapping subroutine.
            The type of event is given by one of the following keywords:
        
        
        Notes
        
        Errors
        
            - 
                norxhas a string value: Type mismatch.
- 
                nis not in[-32768—32767]: Overflow.
- 
                norxis outside the specified range: Illegal function call.
    
        ON ERROR
        
            ON ERROR GOTO {line_number|0}
        
        
            Turns error trapping on or off. When line_number is set, any error causes the error handling
            routine starting at that line number to be called; no message is printed and program execution is not stopped. The
            error handling routine is ended by a RESUME statement.
            While in an error handling routine, events are paused and error trapping is
            disabled. After the RESUME statement, any triggered events are picked up in the following
            order: KEY, TIMER, PLAY - the order of the others is unknown.
            Unlike event trapping, error trapping remains active when no program is running.
            ON ERROR GOTO 0 turns off error trapping.
        
        Parameters
        
            - 
                line_numberis an existing line number in the program.
Notes
        
            - 
                It is not possible to start the error handler at line number 0.
Errors
        
            - 
                line_numberdoes not exist: Undefined line number.
    
        OPEN
        
            OPEN mode_char, [#] file_num, file_spec [, rec_len]
        
        
            OPEN file_spec [FOR {INPUT|OUTPUT|APPEND|RANDOM}]
                       [ACCESS {READ|WRITE|READ WRITE}]
                       [SHARED|LOCK {READ|WRITE|READ WRITE}]
                       AS [#] file_num [LEN = rec_len]
        
        
            Opens a data file on a device.
        
        Parameters
        
            - 
                The string expression file_specis a valid file specification.
- 
                file_numis a numeric expression in[1—max_files],
                wheremax_filesis the maximum file number (default 3).
- 
                rec_lenis a numeric expression in[1—128]: the record length.
- 
                mode_charis a string expression of which the first character is
                one of["I", "O", "A", "R"].
Access modes
        
            The FOR modes or mode_char are as follows:
        
        
        
            If no FOR mode or mode_char is specified, the file is opened for RANDOM.
        
        
            If both FOR and ACCESS are specified, any ACCESS mode is allowed for
            RANDOM but for the other modes the access must match as follows:
        
        
        Sharing and locks
        
            If neither SHARED nor LOCK are specified. Inside this process, a file may be opened multiple
            times for INPUT or RANDOM but only once for OUTPUT or APPEND, as long as it
            is again opened in default mode. It may not be opened in SHARED or any LOCK
            modes.
        
        
            If SHARED, LOCK READ, LOCK WRITE or LOCK READ WRITE is specified, whether
            two OPEN statements may access the same file depends on one's LOCK status
            and the other's ACCESS status and vice versa.
            For two OPEN statements as follows:
            
                OPEN "file" lock_1 AS 1
                
                OPEN "file" ACCESS acc_2 AS 2
            
            the following combinations are allowed:
        
        
        
            In GW-BASIC under MS-DOS with SHARE.EXE active, these locks should be enforced
            across a network as well as inside a single BASIC process. Without
            SHARED and LOCK, the file is locked exclusively
            for use by the GW-BASIC process. By contrast, in PC-BASIC,
            the locks are only implemented internally. Whether other processes may access
            the file will depend on the host OS.
        
        
            To check if another open file is the same file, PC-BASIC only looks at the base name
            of the file, i.e. its DOS name without directories. As a consequence, if a file "test.txt"
            is open and locked, an attempt to lock a file "dir\test.txt" will fail, even if these are
            different files. Conversely, if two file names are different but point to the same file in the
            file system (for example due to file system links), then these will be considered as different files by BASIC.
        
        File specifications
        
            A file specification file_spec
            is a non-empty string expression of the form
            "[device:]parameters",
            where device is a PC-BASIC device
            and the form of the parameters is specific to
            the type of device. If device is omitted,
            the current device (one of the disk devices or CAS1:)
            is used.
        
        
            - 
                Disk devices A:—Z:and@:
- 
                
                    parametersmust specify a valid file path of
                    the form[\][dirname\] ... filename.
 
                    PC-BASIC follows DOS file system conventions.
                    Directory names are separated with
                    backslashes \(even if the host OS separates paths with
                    forward slashes). File and directory names consist of a
                    8-character name and 3-character extension. Names are case insensitive.
                    Permissible characters for both filename and extension are the
                    printable ASCII characters in the range&h20–&h7Eexcluding the characters" * + . , / : ; < = > ? \ [ ] |.
                    Spaces are allowed but leading and trailing spaces are ignored.
                    The namesAUX,CON,PRNandNULare reserved as device aliases and are not legal names
                    for files or directories on a disk device.
 
                    A path starting with a backslash is interpreted as an absolute path,
                    starting at the root of the specified disk device. Otherwise, the
                    path is interpreted as relative to the current directory on the
                    specified device. The special directory name
                    ..refers to the parent directory of a preceding path, or the
                    parent directory of the current directory if no path is given.
                    The special directory name.refers to the same directory as
                    given by the preceding path, or the current directory if no preceding path is given.
 
                    If the file name provided does not contain any dots, the LOAD,SAVE,BLOAD,BSAVE,CHAIN,MERGE,RUN, andLISTstatements
                    append the default
                    extension.BAS. To refer
                    to a file name without an extension, the file specification should
                    end in a dot.. For other statements, appending a dot is allowed but not required.
 Compatibility notes
                    Unlike PC-BASIC, some versions of MS-DOS
                    allow certain characters in the range
                    &h7F–&hFF. However, their
                    permissibility and interpretation depends on the console code page,
                    which may be different from the display code page that affects GW-BASIC.
                    Depending on its console code page, MS-DOS will replace accented
                    letters by their unaccented uppercase variant.
                    Some DOS implementations will remove spaces from filenames;
                    notably, this is the case on DOSBox.
 
                    In order to allow access to files whose name on the host system does
                    not conform to DOS standards while maintaining compatibility with GW-BASIC,
                    PC-BASIC will follow these steps to match DOS-style file names to host file names:
                 
                    - 
                        Look for a file with the name as provided.
                        This can be a long file name which may contain non-permissible characters and which will be case sensitive if
                        your file system is.
                    
- 
                        If such a file is not found, it will truncate the name
                        provided to all-uppercase 8.3 format and look for an exact match.
                        The truncated name consists of the first 8 characters before the first dot,
                        followed by the first three characters after the first dot.
                        If the resulting file name contains non-permissible characters, an error will be raised.
                    
- 
                        Look for 8.3 names in mixed case which match the name
                        provided in a case-insensitive way. Such files are searched in lexicographic
                        order. File names longer than 8.3 will not be matched, unless their name is entered exactly.
                        On Windows, the name matched can be a short filename as well as a
                        long filename provided it is of 8.3 length — it may, for example, contain
                        spaces and thus not be a valid Windows short file name.
                    
 
                    If the file name provided ends in a single dot and contains no other dots,
                    PC-BASIC will first match the name as provided; if this is not found, it will match
                    the name as provided but without the single dot. The 8.3 format of such a file name will match
                    file names with and without the dot, in lexicographic order.
                 
                    If no matching file is found for an output file name, a new file will be
                    created with an all-uppercase 8.3 file name.
                 
- 
                Cassette device CAS1:
- 
                parameterscan be a file name of up to eight characters.
                Cassette file names are case sensitive, have no path or extension,
                may be empty and do not need to be unique. They may contain any
                character in the range&h20–&hFF.
                On the cassette device, when called in direct mode,OPEN,CHAIN,MERGE,LOADandBLOADwill print a message to the console
                for each file found while winding the tape. The message consists
                of the filename followed by a dot and the
                file type and concluded with a status message. The file type is one of
                the following:
                    - A
- Program file in text format
- B
- Program file in tokenised format
- D
- Data file
- M
- BSAVEmemory image
- P
- Program file in protected format
 If the file does not match the file specification and required file type,
                the status is Skipped; if the file matches, the status is
                Found. When called from a program, these statements do
                not print messages to the console.
                If thedevicewas specified explicitly,parametersmay also be empty. In this case the
                first file of the appropriate type is opened.
- 
                Console and parallel devices SCRN:,KYBD:, andLPTn:
- 
                These devices do not allow further device parameters.
            
- 
                Serial devices COMn:
- 
                
                    When opening a COMport, thefile_spechas the form"COMn:[speed[,parity[,data[,stop[,RS][,CS[n]][,DS[n]][,CD[n]][,LF][,PE]]]]]"The first four parameters after the device colon must be given
                    in the order specified but the named parameters
                    can be given in any order.
                    The meaning of the parameters is:
 
Notes
        
            - 
                If a COMport is opened forRANDOM, access is
                byte-for-byte rather than throughFIELDrecords;PRINT#andINPUT#access
                the port directly.rec_lensets the number of bytes read by theGETandPUTstatements.
- 
                For INPUT,OUTPUTandAPPENDmodes,LENmay be specified but is ignored.
- 
                If I/O is attempted contravening the FORmode specified,
                thePRINTorINPUTstatement will raise Bad file mode.
- 
                If RANDOMI/O is attempted contravening theACCESSmode specified, thePUTorGETstatement will raise Path/File access error.
- 
                The #is optional and has no effect.
Errors
        
            - 
                file_specis empty or a non-existent device: Bad file number.
- 
                FOR APPEND ACCESS WRITEis specified: Path/File access error.
- 
                FORandACCESSmismatch in other ways: Syntax error.
- 
                The COM:file_specparameters do not follow the specification:
                Bad file name.
- 
                The CAS1:file_speccontains disallowed characters:
                Bad file number.
- 
                A file with the same name is already open for OUTPUTorAPPEND: File already open.
                This is only raised forCOMn:,CASn:and disk devices.
- 
                rec_lenorfile_numhave string values: Type mismatch.
- 
                file_specormode_charhave number values: Type mismatch.
- 
                file_numis not in[-32768—32767]: Overflow.
- 
                file_numis not in[0—255]: Illegal function call.
- 
                file_numis not in[1—max_files]: Bad file number.
- 
                rec_lenis not in[-32768—32767]: Overflow.
- 
            
                rec_lenis not in[1—128]: Illegal function call.
- 
                mode_charis empty or the first character is not in["I", "O", "A", "R"]: Bad file mode.
    
        OPTION BASE
        
            OPTION BASE n
        
        
            Sets the starting index of all arrays to n.
        
        Parameters
        
            - 
                nis a literal digit0or1. Expressions are not allowed.
Notes
        
            - 
                If OPTION BASEhas not been called,
                the first array allocation defaults to starting index 0.
Errors
        
            - 
                nis not a digit0or1: Syntax error.
- 
                OPTION BASE 1is called but an array has already been allocated before: Duplicate definition.
- 
                OPTION BASEis called more than once with different starting index:
                Duplicate definition.
    
        OUT
        
            OUT port, value
        
        
            Sends a byte to an emulated machine port.
        
        
            The following machine ports are emulated in PC-BASIC:
        
        
        Notes
        
            - 
                Only a limited number of machine ports are emulated.
            
- 
                In GW-BASIC under MS-DOS, the sequence needed to set the colour plane mask is:
                
                    OUT &h3C4, 2
 OUT &h3C5, 2 ^ plane
The sequence needed to set the colour plane is:
                    OUT &h3CE, 4
 OUT &h3CF, plane
The initialOUTstatements currently have no effect in PC-BASIC.
Parameters
        
            - 
                portis a numeric expression in[-32768—65535].
- 
                valueis a numeric expression in[0—255].
Errors
        
            - 
                portorvaluehas a string value: Type mismatch.
- 
                portis not in[-32768—65535]: Overflow.
- 
                valueis not in[-32768—32767]: Overflow.
- 
                valueis not in[0—255]: Illegal function call.
    
        PAINT
        
            PAINT [STEP] (x, y) [, attrib [, border [, background]]]
        
        
            Flood-fills the screen with a colour or pattern, starting from the given seed point.
        
        Parameters
        
            - 
                x,yare numeric expressions in the range[-32768—32767]IfSTEPis specified,xyare offsets
                from the current position. If the seed point is outside the visible screen
                area, no flood fill is performed.
- 
                attribis an expression that specifies the fill attribute or pattern. If not
                specified, the current foreground attribute is used.
- 
                If attribhas a number value, it must be in[0—255]; it specifies the colour
                attribute used to fill.
- 
                If attribhas a string value, it specifies a tile pattern (see below).
- 
                borderis a numeric expression in[0—255]. It specifies the attribute
                of the fill boundary (see below).
- 
                backgroundis a string expression that represents a background tile
                pattern to ignore when determining boundaries (see below).
Tile patterns
        
            A tile pattern can be specified by a string of up to 255 characters. The
            interpretation of the string depends on the number of bits per pixel and on
            the current screen mode.
        
        
            - 
                1 bit per pixel (e.g. SCREEN 2)
- Here is an example:
                
                    
                        | 76543210 | Byte value |  
                        | 
                                *.......
                             | 
                                &h80
                             |  
                        | 
                                .*......
                             | 
                                &h40
                             |  
                        | 
                                ..*.....
                             | 
                                &h20
                             |  
                        | 
                                ...*....
                             | 
                                &h10
                             |  
                        | 
                                ....*...
                             | 
                                &h08
                             |  
                        | 
                                .....*..
                             | 
                                &h04
                             |  
                        | 
                                ......*.
                             | 
                                &h02
                             |  
 This diagonal stripe pattern can thus be produced with
                    PAINT (0, 0), CHR$(128)+CHR$(64)+CHR$(32)+CHR$(16)+CHR$(8)+CHR$(4)+CHR$(2)
                
- 
                SCREEN 7,8,9
- 
                The tile pattern is always 8 pixels wide. The first character in the
                pattern string contains the first bit of each of these 8 pixels, the
                second character contains the second bits, etc.
                For example, in a 2-bits-per-pixel mode, four colour attributes can be used in the pattern.
                To create a diagonal stripe pattern of the same shape, in attribute &h03, we now need a tile
                string that is twice as long:
                    
                        | Attribute bit | 76543210 | Byte value |  
                        | 0 | 
                                *.......
                             | 
                                &h80
                             |  
                        | 1 | 
                                *.......
                             | 
                                &h80
                             |  
                        | 0 | 
                                .*......
                             | 
                                &h40
                             |  
                        | 1 | 
                                .*......
                             | 
                                &h40
                             |  
                        | 0 | 
                                ..*.....
                             | 
                                &h20
                             |  
                        | 1 | 
                                ..*.....
                             | 
                                &h20
                             |  
                        | 0 | 
                                ...*....
                             | 
                                &h10
                             |  
                        | 1 | 
                                ...*....
                             | 
                                &h10
                             |  
                        | 0 | 
                                ....*...
                             | 
                                &h08
                             |  
                        | 1 | 
                                ....*...
                             | 
                                &h08
                             |  
                        | 0 | 
                                .....*..
                             | 
                                &h04
                             |  
                        | 1 | 
                                .....*..
                             | 
                                &h04
                             |  
                        | 0 | 
                                ......*.
                             | 
                                &h02
                             |  
                        | 1 | 
                                ......*.
                             | 
                                &h02
                             |  
 If the pattern string is truncated before all bits of the last line
                have been defined, the remaining bits will be zero.
- 
                SCREEN 1,3,4,5,6
- 
                Each row of the tile pattern represents a screen row. Colours are
                encoded in consecutive bits; the more bits per pixel, the narrower the
                pattern is. For 2 bits per pixel, the pattern is 4 pixels wide; for 4
                bits per pixel it is 2 pixels wide. The following pattern string encodes
                a diagonal dotted stripe in two colours:
                
                    
                        | 3210 | 76543210 | Byte value |  
                        | 2000 | 
                                *.......
                             | 
                                &h80
                             |  
                        | 1000 | 
                                .*......
                             | 
                                &h40
                             |  
                        | 0200 | 
                                ..*.....
                             | 
                                &h20
                             |  
                        | 0100 | 
                                ...*....
                             | 
                                &h10
                             |  
                        | 0020 | 
                                ....*...
                             | 
                                &h08
                             |  
                        | 0010 | 
                                .....*..
                             | 
                                &h04
                             |  
                        | 0002 | 
                                ......*.
                             | 
                                &h02
                             |  
 
            The tile pattern is anchored to the screen; imagine a grid starting at
            (0,0) and covering the screen. Whenever an area is tile-filled,
            the tiles are put into this grid. In this way, adjacent areas will have
            continuous tiling even if they were filled from different seed points.
        
        Boundaries
        
            A solid flood fill stops at pixels that have the same attribute as the fill
            or that have the specified border attribute, if specified.
            A tiling flood fill stops at the specified border attribute; if no border
            attribute is specified, it stops at the current foreground attribute.
            A tiling flood fill also stops at scan line intervals that are the same as
            the tiling pattern for that line, unless a background pattern is specified
            and the interval also equals the background pattern for that line.
        Errors
        
            - 
                In SCREEN 7,8,9, ifbackgroundequalsattribup to the length ofattrib: Illegal function call.
- 
                backgroundhas a number value: Illegal function call.
- 
                border,x, oryhave a string value: Type mismatch.
- 
                border,x, oryare not in[-32768—32767]: Overflow.
- 
                borderis not in[0—255]: Illegal function call.
- 
                attribis numeric and not in[-32768—32767]: Overflow.
- 
                attribis numeric and not in[0—255]: Illegal function call.
    
        PALETTE
        
            PALETTE [attrib, colour]
        
        
            Assigns a colour to an attribute. All pixels with that attribute will change
            colour immediately.
            If no parameters are specified, PALETTE resets to the initial setting.
        
        Parameters
        
            - 
                attribis a numeric expression between 0 and the current palette
                size, less one.
- 
                colouris a numeric expression between -1 and the maximum number of
                colours for the current screen mode, less one. Ifcolourequals -1,
                the palette remains unchanged.
Errors
        
            - 
                attriborcolourhas a string value: Type mismatch.
- 
                attriborcolouris not in[-32768—32767]: Overflow
- 
                attriborcolouris not in range: Illegal function call
    
        PALETTE USING
        
            PALETTE USING int_array_name {(|[} start_index {)|]}
        
        
            Assigns new colours to all attributes.
        
        Parameters
        
            - 
                int_array_nameis a single- or multidimensional
                array of integers (%) that will supply the
                new values for the palette.
- 
                start_indexis a numeric expression that
                indicates at which index in the array to start mapping to the palette.
Notes
        
            - 
                Array values are assigned to palette entries in the order in which they are stored in memory.
                See Arrays for details about the layout of arrays in memory.
            
- 
                If an array entry has value -1, the matching attribute is left unchanged.
Errors
        
            - 
                int_array_namehas not been allocated: Illegal function call.
                The array will not be automatically allocated.
- 
            int_array_nameis not an integer array: Type mismatch.
- 
            int_array_nameis too short: Illegal function call.
- 
            start_indexhas a string value: Type mismatch.
- 
            start_indexis not in[-32768—32767]: Overflow
- 
            start_indexis outside array dimensions: Subscript out of range
    
        PCOPY
        
            PCOPY src, dst
        
        
            Copies the screen page src to dst. All text and graphics on dst is
            replaced by those of src.
        
        Parameters
        
            - 
                srcanddstare numeric expressions between 0 and the current video
                mode's number of pages, less one.
Errors
        
            - 
                srcordsthas a string value: Type mismatch.
- 
                srcordstis not in[-32768—32767]: Overflow.
- 
                srcordstis out of range: Illegal function call.
    
        PEN (statement)
        PEN {ON|OFF|STOP}
        
            Controls event trapping and read access of the light pen (emulated through the mouse in PC-BASIC).
            PEN ON switches pen reading and trapping on.  PEN OFF switches it off.
            PEN STOP suspends PEN event trapping until PEN ON is
            executed. Up to one event can be triggered during suspension, provided that
            event handling was switched on prior to suspension. The event triggered during
            suspension is handled immediately after the next PEN ON statement.
        
    
    
        PLAY (event switch)
        
            PLAY {ON|OFF|STOP}
        
        
            - 
                ON: enablesON PLAYevent
                trapping of the music queue.
- 
                OFF: disables trapping.
- 
                STOP: halts trapping untilPLAY ONis used.
                Events that occur while trapping is halted will trigger immediately when
                trapping is re-enabled.
    
        PLAY (music statement)
        
            PLAY [mml_string_0] [, [mml_string_1] [, mml_string_2]]
        
        
            Plays the tune defined by the Music Macro Language strings mml_string_0, ....
        
        
            Unless syntax={tandy | pcjr} is set, only the single-voice syntax is available.
            The three separate MML strings correspond to the three voices of the PCjr/Tandy sound adapter.
            The notes in these strings are played synchronously.
        
        Parameters
        
            - 
                mml_string_0,mml_string_1,mml_string_2are string expressions in MML.
- 
                At least one parameter must be provided and the statement must not end in a comma.
            
Music Macro Language reference
        Notes and Pauses
        
        Timing commands
        
        Background-mode commands
        
            These commands affect SOUND,
            PLAY and BEEP
        
        
        Subroutine command
        
        Volume control
        
            Volume control is available on syntax={tandy | pcjr} only:
        
        
        MML Parameters
        
            Numeric variables n in the commands above can be:
        
        
            - 
                an integer literal, e.g. PLAY "L4G"
- 
                a numeric variable name or array element varpreceded by=and followed by;.
                For example,PLAY "L=VAR;G"orPLAY "L=A(1);G"
- 
                the result of VARPTR$(var)preceded by=.  For example,PLAY "L=" + VARPTR$(VAR) + "G"
            Note that only number literals may follow named notes and dereferencing variables or arrays is not allowed there.
            It is an error to write PLAY "G=VAR;" or PLAY "G=" + VARPTR$(VAR).
            Use PLAY "G4" or PLAY "L=VAR;G" or PLAY "L=" + VARPTR$(VAR) + "G" instead.
        
        Errors
        
            - 
                mml_stringhas a numeric value: Type mismatch.
- 
                mml_stringhas errors in the MML: Illegal function call.
- 
                A variable in an MML string is of incorrect type: Type mismatch.
            
- 
                No MML string is specified: Missing operand.
            
- 
                If SOUND ONhas not been executed, using the three-voice syntax
                will raise Syntax error.
    
        POKE
        
            POKE address, value
        
        
            Sets the value of the memory byte at
            segment * 16 + address to value,
            where segment is the current segment set with
            DEF SEG.
        
        Parameters
        
            - 
                addressis a numeric expression in[-32768—65535]. Negative values are
                interpreted as their two's complement.
- 
                valueis a numeric expression in[0—255].
Notes
        
            - 
                The memory is only partly emulated in PC-BASIC. See Memory model for supported addresses.
                Outside emulated areas of memory, this statement has no effect.
            
Errors
        
            - 
                addressorvaluehas a string value: Type mismatch.
- 
                addressis not in[-32768—65535]: Overflow.
- 
                valueis not in[-32768—32767]: Overflow.
- 
                valueis not in[0—255]: Illegal function call.
    
        PSET and PRESET
        
            { PSET | PRESET } [STEP] (x, y) [, attrib]
        
        
            Change the attribute of a pixel on the screen at position (x, y).
            If STEP is specified, (x, y) is an offset from the current position.
        
        
            If attrib is between 0 and the screen mode's palette size, the pixel is changed to
            attribute attrib. If attrib is larger than the palette size, the pixel's
            attribute is changed to the highest legal attribute value.
            If attrib is not specified, PSET changes the attribute to the current
            foreground attribute while PRESET changes it to zero.
        
        Parameters
        
            - 
                x,yare numeric expressions in[-32768—32767].
- 
                attribis a numeric expression in[0—255].
Errors
        
            - 
                xoryhas a string value: Type mismatch.
- 
                attrib,xoryor the physical coordinates they translate into are not in[-32768—32767]: Overflow.
- 
                attribis not in[0—255]: Illegal function call.
    
        PRINT and LPRINT
        
            {LPRINT|{PRINT|?} [# file_num,]} [expr_0|;|,|SPC(n)|TAB(n)] ...
            [USING format; uexpr_0 [{;|,} uexpr_1] ... [;|,]]
        
        
            Writes expressions to the screen, printer, or file. If LPRINT is used,
            output goes to LPT1:. If file_num is specified, output goes to the file
            open under that number. ? is a shorthand for PRINT.
        
        
            When writing a string expression to the screen, the following control characters have special meaning.
            Other characters are shown as their corresponding glyph in the current codepage.
        
        
        
            Expressions can optionally be separated by one or more of the following keywords:
        
        
        
            If the print statement does not end in one of these four separation tokens, a newline is
            printed after the last expression.
            String expressions can be separated by one or more spaces, which has the same
            effect as separating by semicolons.
        
        Format string syntax
        
            A USING declaration occurs at the end of an [L]PRINT[#] statement and writes a
            formatted string to the screen, printer or file. The following tables list the format tokens
            that can be used inside the format string.
        
        
        For string expressions:
        
        
            For numeric expressions, the format string specifies a width and alignment.
        
        
        
            The number of characters in the field must not exceed 24.
        
        
            Tokens preceding the number field:
        
        
        
            Tokens trailing the number field:
        
        
        
            Numeric expressions are always fully printed, even if they do not fit in the
            positions specified. If the number does not fit in the allowed space, a % is
            printed preceding it.
        
        
            - 
                If there are more expressions than format fields, the format string is
                wrapped around.
            
- 
                Expressions may be separated with semicolons or commas; the effect is the
                same.
            
- 
               If the USINGdeclaration ends in a comma or semicolon, no newline is printed at
                the end.
- 
               After a USINGdeclaration, other elements of thePRINTsyntax such asSPC(andTAB(can not
                be used.
Parameters
        
            - 
                expr_0, expr_1, ...are expressions of any type.
- 
                formatis a string expression that specifies the output format.
- 
                uexpr_0, uexpr_1, ...are expressions matching a token in the format string.
Notes
        
            - 
                If an error is raised, the output before the error was encountered is
                printed as normal.
            
- 
                In GW-BASIC, when formatting a number with a dollar sign, if the number is in the range [-10000—-32767]and does not fit in the width of the number field,
                the minus sign is omitted. This is not implemented in PC-BASIC.
Errors
        
            - 
                nhas a string value: Type mismatch.
- 
                nis not in[-32768—65535]: Overflow.
- 
                The format string contains no tokens: Illegal function call.
            
- 
                An expression doesn't match the corresponding format token type: Type mismatch.
            
- 
                A number field in the format string exceeds 24 characters: Illegal function call.
            
- 
                A number field in the format string contains no #characters: Illegal function call.
    
        PUT (files)
        
            PUT [#] file_number [, record_number]
        
        
            Writes a record to the random-access file file_number at position
            record_number.
        
        Parameters
        
            - 
                file_numberis a numeric expression that yields the number
                of an open random-access file. The#is optional and has no effect.
- 
                record_numberis a numeric expression in[1—33554432](2^25) and is interpreted as the record number.
Notes
        
            - 
                The record number is stored as single-precision; this precision is not high enough to distinguish single
                records near the maximum value of 2^25.
Errors
        
            - 
                record_numberis not in[1—33554432]: Bad record number.
- 
                file_numberis not in[0—255]: Illegal function call.
- 
                file_numberis not the number of an open file:
                Bad file mode.
- 
                file_numberis open under a mode other thanRANDOM:
                Bad file mode.
- 
                file_numberis not specified: Missing operand.
    
        PUT (communications)
        
            PUT [#] com_file_number [, number_bytes]
        
        
            Writes number_bytes bytes to the communications buffer opened under file
            number com_file_number. number_bytes is a numeric expression between 1
            and the COM buffer length, inclusive.
        
        Notes
        
            - 
                In GW-BASIC, Device I/O error is raised for overrun error, framing error,
                and break interrupt. Device fault is raised if DSR is lost during I/O. A
                Parity error is raised if parity is enabled and incorrect parity is
                encountered. This is according to the manual; it is untested.
            
Errors
        
            - 
                bytesis less than 1: Bad record number.
- 
                bytesis less than32768and greater than theCOMbuffer length: Illegal function call.
- 
                com_file_numberis not specified: Missing operand.
- 
                com_file_numberis not in[0—255]: Illegal function call.
- 
                com_file_numberis not the number of an open file:
                Bad file number.
- 
                The serial input buffer is full, i.e. LOF(com_file_number) = 0andLOC(com_file_number)=255: Communication buffer overflow.
    
        PUT (graphics)
        
            PUT (x0, y0), array_name [, {PSET|PRESET|AND|OR|XOR}]
        
        
            Displays an array to a rectangular area of the graphics screen.
            Usually, PUT is used with arrays that have been stored using GET. See GET for the
            format of the array.
        
        
            The keywords have the following effect:
        
        
        Parameters
        
            - 
                array_nameis a numeric array.
- 
                x0,y0are numeric expressions.
Errors
        
            - 
                The array does not exist: Illegal function call.
            
- 
                array_namerefers to a string array: Type mismatch.
- 
                x0,y0are string expressions: Type mismatch.
- 
                x0,y0are not in[-32768—32767]: Overflow.
- 
                x0,y0is outside the currentVIEWorWINDOW:
                Illegal function call
    
        RANDOMIZE
        
            RANDOMIZE [expr]
        
        
            Seeds the random number generator with expr.
            If no seed is specified, RANDOMIZE will prompt the user
            to enter a random seed. The user-provided value is rounded to an integer.
            The random seed is formed of the last two bytes of that integer or expr.
            If expr is a float (4 or 8 bytes), these are
            XORed with the preceding 2. The
            first 4 bytes of a double are ignored.
            The same random seed will lead to the same sequence of pseudorandom numbers
            being generated by the RND function.
        
        Parameters
        
            - 
                expris a numeric expression.
Notes
        
            - 
                For the same seed, PC-BASIC produces the same pseudorandom numbers as
                GW-BASIC 3.23.
            
- 
                The random number generator is very poor and should not be used for serious purposes.
                See RNDfor details.
Errors
        
            - 
                exprhas a string value: Illegal function call.
- 
                The user provides a seed outside [-32768—32767]at the prompt: Overflow.
    
        READ
        
            READ var_0 [, var_1] ...
        
        
            Assigns data from a DATA statement to variables. Reading starts at the current
            DATA position, which is the DATA entry immediately after the last one read by
            previous READ statements. The DATA position is reset
            to the start by the RUN
            and RESTORE statements.
        
        Parameters
        
            - 
                var_0,var_1are variables or array elements.
Errors
        
            - 
                Not enough data is present in DATAstatements: Out of DATA.
- 
                The type of the variable is not compatible with that of the data entry
                being read: a Syntax error occurs on the DATAline.
    
        REM
        
            {REM|'} [anything]
        
        
            Ignores everything until the end of the line. The REM statement is intended for
            comments. Everything after REM will be stored in the program unaltered and
            uninterpreted. ' (apostrophe) is an alias for :REM'; it can be placed at any
            point in the program line and will ensure that the rest of the line is ignored.
        
        
            Note that a colon : does not terminate the REM statement; the colon and everything
            after it will be treated as part of the comment.
        
    
    
        RENUM
        
            RENUM [new|.] [, [old|.] [, increment]]
        
        
            Replaces the line numbers in the program by a systematic enumeration starting
            from new and increasing by increment. If old is specified, line numbers
            less than old remain unchanged.
            new, old are line numbers; the dot . signifies the last line edited.
            increment is a line number but must not be a dot or zero.
        
        Notes
        
            - 
                Line numbers afer the following keywords will be renumbered:
                AUTO,EDIT,ELSE,ERL,DELETE,GOSUB,GOTO,LIST,LLIST,RENUM,RESTORE,RESUME,RETURN,RUN,THEN.
- 
                Any line numbers in CHAINstatements will not be
                renumbered; note that these line numbers refer to another program.
- 
                All arguments of RENUMorAUTOstatements in a program will be renumbered,
                including any line number offsets or increments, even though that does not make much sense.
- 
                A zero line number following the keywords ERROR GOTOwill not be renumbered.
- 
                If a referenced line number does not exist in the program, a
                message Undefined line ref in old_line
                is printed. Here, old_lineis the line number prior to renumbering. The referenced line number will be
                left unchanged, but the line's old line number will be renumbered.
Errors
        
            - 
                Any of the parameters is not in [0—65529]: Syntax error.
- 
                Any of the newly generated line numbers is greater than 65529:
                Illegal function call. The line numbers up to the error have not been
                changed.
- 
                incrementis empty or zero: Illegal function call.
- 
                oldis specified andnewis less than or equal to an existing line
                number less than old: Illegal function call.
    
        RESET
        
            RESET
        
        
            Closes all open files.
        
        Notes
        
            - 
                Official GW-BASIC documentation and many other sources state that
                RESETcloses all files on disk devices.
                However, in reality GW-BASIC 3.23 also closes files on tape
                and any other device, making this statement identical toCLOSEwith no arguments.
                PC-BASIC follows this behaviour.
    
        RESTORE
        
            RESTORE [line]
        
        
            Resets the DATA pointer.
            line is a line number. If line
            is not specified, the DATA pointer is reset to the first
            DATA entry in the program. If it is specified, the DATA pointer is
            reset to the first DATA entry in or after line.
        
        Errors
        
            - 
                lineis not an existing line number: Undefined line number.
    
        RESUME
        
            RESUME [0|NEXT|line]
        
        
            Continues normal execution after an error handling routine.
            If 0 or no option is specified, re-executes the statement that caused the
            error. If NEXT is specified, executes the statement following the one that
            caused the error. If line is specified, it must be a valid line number.
        
        Errors
        
            - 
                RESUMEis encountered outside of an error trapping routine:
                RESUME without error.
- 
                The program ends inside an error trapping routine without a RESUMEorENDstatement: No RESUME.
- 
                lineis not an existing line number: Undefined line number.
    
        RETURN
        
            RETURN [line]
        
        
            Returns from a GOSUB subroutine.
            If line is not specified, RETURN jumps back
            to the statement after the GOSUB that jumped into the subroutine.
            If line is specified, it must be a valid line number. RETURN jumps to that
            line (and pops the GOSUB stack).
            When returning from an error trapping routine, RETURN re-enables the event
            trapping which was stopped on entering the trap routine.
        
        Errors
        
            - 
                lineis not an existing line number: Undefined line number.
    
        RMDIR
        
            RMDIR dir_spec
        
        
            Removes an empty directory on a disk device.
        
        Parameters
        
            - 
                The string expression dir_specis a
                valid file specification that specifies the path and name of the directory.
Errors
        
            - 
                dir_spechas a numeric value: Type mismatch.
- 
                dir_specis an empty string: Bad file name.
- 
                No matching path is found: Path not found.
            
- 
                Directory to remove is not empty: Path/File access error.
            
    
        RSET
        
            RSET string_name = expression
        
        
            Copies a string value into an existing string variable or array element.
            The value will be right-justified and any remaining characters are replaced by
            spaces.
        
        Parameters
        
            - 
                string_nameis a string variable or array element.
- expressionis a string expression.
Notes
        
            - 
                If expressionhas a value that is longer than the length of the target variable,
                it is truncated at the tail to the length of the target variable.
- 
                If string_namehas not been allocated before, this statement has no effect.
- 
                Use LSET,RSETorMID$to copy values into aFIELDbuffer.
- 
                If LETis used on aFIELDvariable
                instead ofL|RSET, the variable is
                detached from the field and a new, normal string variable is allocated.
Errors
        
            - 
                string_nameis not a string variable: Type mismatch.
- 
                expressiondoes not have a string value: Type mismatch.
    
        RUN
        
            RUN [line_number [anything]|file_spec [, R]]
        
        
            Executes a program.
            Existing variables will be
            cleared and any program in memory will be erased. RUN implies a CLEAR
            If ,R is specified after file_spec, files are kept open; if not, all files are closed.
        
        Parameters
        
            - 
                line_numberis a valid line number in the current program.
                If specified, execution starts from this line number. The rest of theRUNstatement is ignored in this case.
- 
                The string expression file_spec, if specified,
                is a valid file specification indicating
                the file to read the program from.
Errors
        
            - 
                line_numberis not a line number in the current program: Undefined line number.
- 
                file_speccannot be found: File not found.
- 
                file_specis an empty string: Bad file number.
- 
                A loaded text file contains lines without line numbers:
                Direct statement in file.
            
    
        SAVE
        
            SAVE file_spec [, {A|P}]
        
        
            Stores the current program in a file.
        
        
            - 
                If ,Ais specified, the program will be saved in plain text format.
                In this case, program execution will stop and control will be returned to the user.
- 
                If ,Pis specified, the program will be saved in protected format.
                When a protected program is loaded in GW-BASIC, it cannot beLISTed orSAVEd in non-protected
                format.
- 
                If neither is specified, the program will be saved in tokenised format.
            
Parameters
        
            - 
                The string expression file_specis a valid file specification
                indicating the file to store to.
Errors
        
            - 
                file_spechas a number value: Type mismatch.
- 
                file_specis an empty string: Bad file number.
- 
                file_speccontains disallowed characters:
                Bad file number (onCAS1:);
                Bad file name (on disk devices).
- 
                hide-protectedis enabled, the current program is protected and,Pis not specified:
                Illegal function call.
    
        SCREEN (statement)
        
            SCREEN [mode] [, [colorburst] [, [apage] [, [vpage] [, erase]]]]
        
        
            Change the video mode, composite colorburst, active page and visible page. Video modes are described in the Video Modes section.
        
        Parameters
        
            - 
                modeis a numeric expression that sets the screen mode.
- 
                colorburstis a numeric expression. See notes below.
- 
                apageis a numeric expression that sets the active page.
- 
                vpageis a numeric expression that sets the visible page.
- 
                eraseis a numeric expression in the range[0, 1, 2].
                It is only legal withsyntax={pcjr, tandy}. See notes below.
Video modes
        The video modes are as follows:
        
            - SCREEN 0Text mode
- 
                80x25 or 40x25 characters of 8x16 pixels
 16 attributes picked from 64 colours
 Attributes 16-31 are blinking versions of 0-15
 4 pagesega
- SCREEN 1CGA colour
- 
                320x200 pixels
 40x25 characters of 8x8 pixels
 4 attributes picked from 16 colours; 2 bits per pixel
 1 pageega2 pagespcjrtandy
 
- SCREEN 2CGA monochrome
- 
                640x200 pixels
 80x25 characters of 8x8 pixels
 2 attributes picked from 16 colours; 1 bit per pixel
 1 pageega2 pagespcjrtandy
 
- SCREEN 3Low-res 16-colour- pcjr- tandy
- 
                160x200 pixels
 20x25 characters of 8x8 pixels
 16 attributes picked from 16 colours; 4 bits per pixel
 2 pages
 
- SCREEN 3Hercules monochrome- hercules
 
- 
                720x348 pixels
 80x25 characters of 9x14 pixels (with bottom line truncated by 2 px)
 2 attributes; 1 bit per pixel
 2 pages
 
- SCREEN 3—255Altissima risoluzione- olivetti
 
- 
                640x400 pixels
 80x25 characters of 8x16 pixels
 2 attributes of which one picked from 16 colours; 2 bits per pixel
 1 page
 
- SCREEN 4Med-res 4-colour- pcjr- tandy
 
- 
                320x200 pixels
 40x25 characters of 8x8 pixels
 4 attributes picked from 16 colours; 2 bits per pixel
 2 pages
 
- SCREEN 5Med-res 16-colour- pcjr- tandy
 
- 
                320x200 pixels
 40x25 characters of 8x8 pixels
 16 attributes picked from 16 colours; 4 bits per pixel
 1 page
 Note: a minimum of 32768 bytes of video memory must be
                reserved to use this video mode. Use the statement
                CLEAR ,,,32768!or the optionvideo-memory=32768.
 
- SCREEN 6High-res 4-colour- pcjr- tandy
 
- 
                640x200 pixels
 80x25 characters of 8x8 pixels
 4 attributes picked from 16 colours; 2 bits per pixel
 1 page
 Note: a minimum of 32768 bytes of video memory must be
                reserved to use this video mode. Use the statement
                CLEAR ,,,32768!or the optionvideo-memory=32768.
 
- SCREEN 7EGA colour- ega
- 
                320x200 pixels
 40x25 characters of 8x8 pixels
 16 attributes picked from 16 colours; 4 bits per pixel
 8 pages
 
- SCREEN 8EGA colour- ega
- 
                640x200 pixels
 80x25 characters of 8x8 pixels
 16 attributes picked from 16 colours; 4 bits per pixel
 4 pages
 
- SCREEN 9EGA colour- ega
- 
                640x350 pixels
 80x25 characters of 8x14 pixels
 16 attributes picked from 64 colours; 4 bits per pixel
 2 pages
 
- SCREEN 10EGA monochrome- ega- monitor=mono
- 
                640x350 pixels
 80x25 characters of 8x14 pixels
 4 attributes picked from 9 pseudocolours; 2 bits per pixel
 2 pages
 
NTSC Composite Colorburst
        
            On CGA, Tandy and PCjr, colorburst has the following effects, depending on the
            type of monitor - RGB (default) or composite:
        
        
        
            On SCREEN 2, colorburst has no effect; on a composite monitor, colour artifacts
            can be enabled on this screen through OUT (see there). On SCREEN 3 and up, colorburst has no effect.
        
        Erase
        
            By default, if the mode changes or the colorburst
            changes between zero and non-zero, the old page and the new page of the screen
            are cleared. On syntax={pcjr, tandy},
            the erase parameter can be used to change this behaviour.
            Its values are as follows:
        
        
        Notes
        - 
            At least one parameter must be specified.
        
- 
            Composite colour artifacts are emulated only crudely in PC-BASIC, and not at
            all in SCREEN 1.
Errors
        
            - 
                No parameters are specified: Missing operand.
            
- 
                Any parameter has a string value: Type mismatch.
            
- 
                Any parameter is not in [-32768—32767]: Overflow.
- 
                modeis not an available video mode number for your video card setting: Illegal function call.
- 
            vpage,apageare not between 0 and the number of pages for the
                chosen video mode, less one:  Illegal function call.
- 
                colorburstis not in[0—255]: Illegal function call.
- 
                eraseis not in[0, 1, 2]:
                Illegal function call.
    
        SHELL
        
            SHELL [command]
        
        
            Starts an operating system subshell on the console.
            If command is specified, the command is executed on the shell and execution
            returns to the program.
        
        
            To enable this statement, the shell option must be set to
            a valid command interpreter.
        
        Parameters
        
            - 
                commandis a string expression.
Notes
        
            - 
            Be careful when enabling this command, as it allows the running BASIC program full access to your files and operating system.
            
Errors
        
            - 
                shelloption is not specified: Illegal function call.
- 
                commandhas a number value: Type mismatch.
- 
                All output from the operating system subshell, including error messages, is displayed
                on the PC-BASIC screen.
            
    
        SOUND (tone)
        
            SOUND frequency, duration [, volume [, voice]]
        
        
            Produces a sound at frequency Hz for duration/18.2 seconds.
            On PCjr and Tandy, the volume and voice channel can additionally be specified.
        
        
            If PLAY "MB" has been executed, SOUND plays in the background. If PLAY "MF"
            has been executed, sound plays in the foreground and the interpreter blocks
            until the sound is finished. Foreground mode is default. Unlike PLAY, the
            sound played by the most recent SOUND statement always plays in the background,
            even if PLAY "MF" has been entered. In background mode, each SOUND statement
            counts as 1 toward the length of the queue reported by the PLAY function.
        
        Parameters
        
            - 
                frequencyis a numeric expression in[37—32767]or0(forsyntax={advanced | pcjr})
                or in[-32768—32767](forsyntax=tandy).
- 
                durationis a numeric expression in[0—65535].
- 
                volumeis a numeric expression in[-1—15]. 0 is silent, 15 is full
                volume; every step less reduces the volume by 2 dB. -1 is also full volume.
                (Forsyntax={pcjr | tandy}).
- 
                voiceis a numeric expression in[0—2], indicating which of the
                three tone voice channels is used for this sound. (Forsyntax={pcjr | tandy})
Notes
        
            - 
                On PCjr and Tandy, Frequencies below 110 Hz are played as 110 Hz.
            
- 
                If durationis zero, any active background sound is stopped and
                the sound queue is emptied.
- 
                If durationis zero,volumeandvoicemust not be specified.
- 
                If durationis less than.022but nonzero, the sound will be played in
                background and continue indefinitely until another sound statement is
                executed. This is also the behaviour for negativeduration.
- 
                If frequencyequals32767or0, a silence of lengthdurationis queued.
Errors
        
            - 
                Any argument has a string value: Type mismatch.
            
- 
                frequencyis not in its allowed range, anddurationis not zero:
                Illegal function call.
- 
                durationis zero and more than two arguments are specified:
                Syntax error.
- 
                syntax={ pcjr | tandy }is not set and more than two arguments are specified:
                Syntax error.
- 
                frequencyis not in[-32768—32767]:
                Overflow.
- 
                durationis not in[-65535—65535]:
                Illegal function call.
- 
                volumeis not in[0—15]:
                Illegal function call.
- 
                voiceis not in[0—2]:
                Illegal function call.
    
        SOUND (switch)
        
            SOUND {ON|OFF}
        
        
            Switches the external speaker on or off and toggles the availability of advanced sound capabilities on PCjr and Tandy. This includes 3-voice
            sound, noise generation and volume control. Clears the background music queue.
        
        Notes
        
            - 
                Only available with syntax={pcjr | tandy}.
- 
                On PC-BASIC, both the
                internal and the external speaker are emulated through the same sound
                system.
            
Errors
        
            - 
                This statement is used and syntax={ pcjr | tandy }is not set:
                Syntax error.
    
        STOP
        
            STOP
        
        
            Breaks program execution, prints a Break
            message on the console and returns control to the user. Files are not closed.
            It is possible to resume program execution at the next statement using
            CONT.
        
    
    
    
        STRIG (switch)
        
            STRIG {ON|OFF}
        
        
            Has no effect.
        
    
    
        STRIG (event switch)
        
            STRIG[ ](button) {ON|OFF|STOP}
        
        
            Switches event trapping of the joystick trigger button
            ON or OFF.
            STRIG (button) STOP suspends event trapping until
            STRIG (button) ON is executed. Up to one event can be triggered during
            suspension, provided that event handling was switched on prior to suspension.
            The event triggered during suspension is handled immediately after the next STRIG (button) ON
            statement.
        
        
        Parameters
        
            - 
                buttonis a numeric expression in[0, 2, 4, 6].
Errors
        
            - 
                buttonhas a string value: Type mismatch.
- 
                buttonis not in[-32768—32767]: Overflow.
- 
                buttonis not in[0, 2, 4, 6]: Illegal function call.
    
        SWAP
        
            SWAP var_0, var_1
        
        
            Exchanges variables var_0 and var_1.
        
        Notes
        
            - 
                The variables are exchanged by reference. If, for example,
                var_0is aFIELDvariable andvar_1is not, thenSWAPwill reverse those roles.
Parameters
        
            - 
                var_0andvar_1are variables or array elements of
                the same type.var_1must have been previously defined.
Errors
        
            - 
                var_1is undefined: Illegal function call.
                Note that no error is raised ifvar_0is undefined, and that after this error both variables will be defined.
- 
                The types of var_0andvar_1are not the same: Type mismatch.
    
        SYSTEM
        
            SYSTEM
        
        
            Exits the interpreter.
        
        Notes
        
            - 
                SYSTEMquits the PC-BASIC interpreter immediately without further interaction.
                Any unsaved program or data will be lost.
    
        TERM
        
            TERM
        
        
            Load and run the program defined by the term option.
            By default, as on the IBM PCjr, this is a
            built-in serial terminal emulator application.
            This statement is only available with
            syntax={pcjr|tandy}.
        
        Errors
        
            - 
                If termis not set,
                this statement raisesInternal error.
- 
                If syntaxis not set topcjrortandy, this keyword is not present.
                CallingTERMwill raise Syntax error.
    
        TIME$ (statement)
        
            TIME$ = time
        
        
            Sets the current BASIC time to time.
        
        Parameters
        
            - 
                Time is a string expression
                of the form "HH{:|.}mm{:|.}ss"where0 <= HH < 24,0 <= mm < 60and0 <= ss < 60.
                Each position may have one or two characters.
Notes
        
            - 
                PC-BASIC stores an offset to the system time and uses this for future
                calls to TIME$andDATE$functions in the same interpreter session.
                The system time is not changed, unlike GW-BASIC under MS-DOS.
Errors
        
            - 
                timehas a numeric value: Type mismatch.
- 
                timeis not of the correct form: Illegal function call.
    
        TIMER (statement)
        
            TIMER {ON|OFF|STOP}
        
        
            - 
                ON: enablesON TIMERevent
                trapping of the timer clock.
- 
                OFF: disables trapping.
- 
                STOP: halts trapping untilTIMER ONis used.
                Events that occur while trapping is halted will trigger immediately when
                trapping is re-enabled.
    
        TRON and TROFF
        
            {TRON|TROFF}
        
        
            Turns line number tracing on or off. If line number tracing is on, BASIC prints
            a tag [100] to the console when program line 100 is executed, and so forth.
        
        Notes
        
            - 
               Tracing is turned off by the NEWandLOADstatements.
    
        UNLOCK
        
            UNLOCK [#] file_number [, record_0]
        
        
            UNLOCK [#] file_number, [record_0] TO record_1
        
        
            Unlocks a file or part of it that has previously been locked with LOCK.
        
        Parameters
        
            - 
                file_numberis a numeric expression in[0—255].
- 
                record_0andrecord_1are numeric expressions in[1—2^25-2].
Errors
        
            - 
                Any parameter has a string value: Type mismatch.
            
- 
                file_numberis not in[-32768—32767]: Overflow.
- 
                file_numberis not in[0—255]: Illegal function call.
- 
                file_numberis not an open file: Bad file number.
- 
                If file_numberis open forRANDOM,LOCKandUNLOCKstatements must match in terms ofrecord_0andrecord_1. An non-matchingUNLOCKwill raise
                Permission denied.
- 
                record_0orrecord_1is not in[1—2^25-2]: Bad record number.
    
        VIEW
        
            VIEW [[SCREEN] (x0, y0)-(x1, y1) [, [fill] [, border]]]
        
        
            Defines a graphics viewport. Graphics drawn outside the viewport will
            not be shown. (x0, y0), (x1, y1) are absolute screen coordinates of two
            opposing corners of the area.
        
        
            Unless SCREEN is specified, after a VIEW statement the coordinate
            system is shifted such that (0, 0) becomes the top left coordinate of the viewport.
            If VIEW is called without arguments, the viewport is reset to the whole
            screen.
        
        Parameters
        
            - 
                fillis an attribute. The viewport will be
                filled with this attribute.
- 
                borderis an attribute. A border will be drawn
                just outside the viewport with this attribute.
Errors
        
            - 
                Any of the parameters has a string value: Type mismatch.
            
- 
                Any of the coordinates is not in [-32768—32767]: Overflow.
- 
                Any of the coordinate pairs is outside the physical screen: Illegal function call.
            
    
        VIEW PRINT
        
            VIEW PRINT top_row TO bottom_row
        
        
            Defines the text scrolling area of the screen. LOCATE statements,
            cursor movement and scrolling will be limited to the scrolling area.
        
        Parameters
        
            - 
                top_rowandbottom_roware
                numeric expressions in[1—24].
Notes
        
            - 
                If syntax={pcjr | tandy}andKEY OFFis set,bottom_rowmay be 25.
                Otherwise, screen row 25 cannot be part of the
                scrolling area.
Errors
        
            - 
                top_roworbottom_rowis not in[1—24]: Illegal function call.
    
        WAIT
        
            WAIT port, and_mask [, xor_mask]
        
        
            Waits for the value of (INP(port)
            XOR xor_mask) AND
            and_mask to become nonzero.
            Event handling is suspended until WAIT returns.
            If xor_mask is not specified, it defaults to 0.
        
        Notes
        
            - 
                A limited number of machine ports are emulated in PC-BASIC.
                See INP.
Errors
        
            - 
                Any parameter has a string value: Type mismatch.
            
- 
                portis not in[-32768—65535]: Overflow.
- 
                and_maskorxor_maskare not in[0—255]: Type mismatch.
    
        WEND
        
            WEND
        
        
            Iterates a WHILE—WEND loop: jumps to the matching
            WHILE statement, where its
            condition can be checked.
        
        Notes
        
            - 
               WHILE—WENDloops can be nested.WENDjumps to the most recentWHILEstatement that has not been closed by anotherWEND.
Errors
        
            - 
                All previous WHILEstatements have been closed by anotherWENDor noWHILEstatement has been executed before:
                WEND without WHILE.
    
        WHILE
        
            WHILE expr
        
        
            Initiates a WHILE—WEND loop.
            If expr evaluates to zero, WHILE jumps
            to the statement immediately after the matching
            WEND. If not, execution continues.
        
        Parameters
        
            - 
            expris a numeric expression.
Errors
        
            - 
                No matching WENDis found: WHILE without WEND.
- 
                exprhas a string value: Type mismatch.
    
        WIDTH (console)
        
            WIDTH num_columns [, [num_rows] [,]]
        
        
            Sets the screen width to 20, 40 or 80 columns.
        
        Notes
        
            - 
                When changing screen width in graphics mode, the video mode is changed.
                The following changes occur:
 SCREEN 1(40)  ↔SCREEN 2(80)
 SCREEN 7(40)  ↔SCREEN 8(80)
 SCREEN 7(40)  ←SCREEN 9(80)
 
- 
                Screen width value 20 is only allowed on Tandy and PCjr. Changing to this width
                changes to SCREEN 3. Additionally, the following changes occur:
 SCREEN 3(20)  →SCREEN 1(40)
 SCREEN 3(20)  →SCREEN 2(80)
 SCREEN 4(40)  →SCREEN 2(80)
 SCREEN 5(40)  ↔SCREEN 6(80)
 
Parameters
        
            - 
                num_columnsis either a literal20,40or80or a numeric expression in parentheses.
                The trailing comma is optional and has no effect.
- 
                num_rowsis optional and must equal 25. Ifsyntax={pcjr | tandy}is set,num_rowsmay be in[0—25]but its value is ignored.
Errors
        
            - 
                num_columnsis a string expression: Type mismatch.
- 
                num_columnsis not in[-32768—32767]: Overflow.
- 
                num_columnsis not in[0—255]: Illegal function call.
- 
                num_columnsis not a literal and not bracketed: Illegal function call.
- 
                num_rowsis not in its accepted range: Illegal function call.
    
        WIDTH (devices and files)
        
            WIDTH {#file_num,|device_name,|LPRINT} num_columns
        
        
            Sets the line width for a file or a device.
            When a write operation passes beyond the column width, a CR LF sequence is
            inserted.
        
        
            If a device is specified, it does not need to have a file open to it; the width setting will
            be the default width next time a file is opened to that device.
        
        
            If device_name is "LPT1:" or LPRINT
            is specified, the device width setting affects LPRINT
            and LLIST.
        
        
            If device_name is "SCRN:", "KYBD:", or omitted, the screen width is changed.
            In this case, num_columns must be one of 20, 40 or 80.
            See the notes at WIDTH (console) for side effects.
        
        Parameters
        
            - 
                file_numis a numeric expression which is the number of an open file.
- 
                device_nameis a string expression that is one of"KYBD:","SCRN:","LPT1:","LPT2:","LPT3:","COM1:","COM2:","CAS1:"
- 
                num_columnsis a numeric expression.
Errors
        
            - 
                device_nameis not one of the allowed devices: Bad file name.
- 
                device_nameis"SCRN:","KYBD:"andnum_columnsis not 20, 40 or
                80: Illegal function call.
- 
                file_numornum_columnsare strings: Type mismatch.
- 
                file_numornum_columnsare not in[-32768—32767]: Overflow.
- 
                file_numornum_columnsare not in[0—255]:    Illegal function call.
- 
                file_numis not an open file: Bad file mode.
    
        WINDOW
        
            WINDOW [[SCREEN] (x0, y0)-(x1, y1)]
        
        
            Define logical coordinates for the viewport.
            If SCREEN is not specified,
            the bottom left of the screen is mapped to the lower coordinates;
            the top right of the screen is mapped to the higher coordinates.
            If SCREEN is specified,
            the top left of the screen is mapped to the lower coordinates;
            the bottom right of the screen is mapped to the higher coordinates.
        
        
            If WINDOW is called without arguments, the logical coordinates are
            reset to the viewport coordinates.
        
        Parameters
        
            - 
                x0,y0,x1,y1are numeric expressions.
Errors
        
            - 
                Any of the coordinates have a string value: Type mismatch.
            
- 
                x0 = x1ory0 = y1: Illegal function call.
    
        WRITE
        
            WRITE [# file_num,] [expr_0 [{,|;} expr_1] ... ]
        
        
            Writes values to a file or the screen in machine-readable form. Values are
            separated by commas and the line is ended with a CR LF sequence. Strings are
            delimited by double quotes ". No padding spaces are inserted.
        
        
            When writing to the screen, the same control characters are recognised as for the
            PRINT statement.
        
        Parameters
        
            - 
                expr_0, expr_1, ...are expressions whose value is to be printed.
Errors
        
            - 
                file_numhas a string value: Type mismatch.
- 
                file_numis open forINPUT: Bad file mode.