Quick Links: [Home] [Menu] [BASIC] [TEXT] [TELCOM] [Diff] [Tech Ref] [Files] [Links] [Y2K]
This file is formatted in a fixed-width font with 60 characters or less per line so that the file may be easily split up into NEC-friendly chunks and viewed easily in T-Word with ROM-View80 set to 60 characters per line.
---------------------------------------------------- NEC PC-8201A N82-BASIC Reference PART 2 ---------------------------------------------------- This file is part of a multiple file set of tech ref information for the NEC PC-8201A laptop computer. PART 1: Intro to N82 BASIC PART 2: Keywords AND through XOR ---------------------------------------------------- Compiled by: David Firth Westerville, Ohio djfirth@freenet.columbus.oh.us ---------------------------------------------------- If you find misspellings, errors, or omissions, please bring them to my attention and they will be corrected. PART 2 Revision history: v1.00 07/04/1998 Initial compilation v1.01 07/16/1998 Angle brackets to square brackets because of html ---------------------------------------------------- Key: This reference uses abbreviations and symbols from the N82 BASIC Reference, (c)1983 by NEC Home Electronics. Angle brackets have been changed to square brackets during html conversion. [variable] Items enclosed in triangle [numeric] brackets are to be replaced in [string] programs by the appropriate [file] variables, etc. that you're [device] using. {} Items inside curly brackets are optional. () Parentheses are part of the BASIC code and must be included. Spaces in commands are always optional except for spaces in strings between double quotes. Commands are BASIC keywords that do not return values. Functions are BASIC keywords that return values. Functions are often used in variable assignment, as shown in the use guidelines. However, functions are often used within other commands without an intermediate variable assignment. Logical operators are functions that operate on one or two integer operands. Program control commands are used for looping, calling. ----------------------------------------------------------- AND --- Type: Logical Operator Use: [operand] AND [operand] The AND operator converts both operands to 16-bit signed integers and then performs a logical AND between each bit in the two numbers. Bit 0 of operand 1 and operand 2 are ANDed to get bit 0 of the result, and so forth. The truth table for AND is: A B R 0 0 0 0 1 0 1 0 0 1 1 1 ASC --- Type: Function Use: [variable] = ASC([string]) ASC returns the ASCII code associated with the first character of a string variable. ATN --- Type: Function Use: [variable] = ATN([numeric]) ATN returns the trigonometric arctangent of an angle. The angle must be in radians. The result is in the range -pi/2 to pi/2 radians. BEEP ---- Type: Command Use: BEEP This command is equivalent to printing the ASCII BEL character, CHR$(7). It sounds the speaker for approx 0.12 seconds. BLOAD ----- Type: Command Use: BLOAD"{[device]:}[file]" BLOAD is a binary load command that loads machine code programs. The file name of the resulting program will have a .CO extension. [device] defaults to the cassette port if no other device is specified. The starting address of the program is embedded in the .CO file (see BSAVE). BLOAD? ------ Type: Command Use: BLOAD?"{[device]:}[file]" BLOAD? verifies that the machine code program in memory (may have been previously loaded with BLOAD) matches the program in the storage device. A response of "Ok" means the programs match. A response of "BAD" means the programs do not match. BSAVE ----- Type: Command Use: BSAVE"{[device]:}[file]",[start],[length] {,[execute]} BSAVE is a binary save command that stores machine code programs, copying a block of memory to a storage device. The file name of the resulting program will have a .CO extension. [device] defaults to the cassette port if no other device is specified. The starting address of the program is embedded in the .CO file, and the user may specify a different execution address than starting address. CDBL ---- Type: Function Use: [variable] = CDBL([numeric]) Converts a numeric value or expression to a double precision real number. CHR$ ---- Type: Function Use: [string variable] = CHR$([numeric]) CHR$ returns a character corresponding to the ASCII character having a particular numeric value. CINT ---- Type: Function Use: [integer variable] = CINT([numeric]) Converts a numeric value or expression to an integer value, -32768 to 32767. CLEAR ----- Type: Command Use: CLEAR {[string area size]}{,[ramtop]} CLEAR performs several important memory management tasks. When no parameters are specified, CLEAR causes variable initialization within BASIC. When the string area size is given, BASIC adjusts the working space size for string variables (since this space is not avail for BASIC programs, only as much string space as required should be used). When ramtop is specified, the top of memory available to BASIC is artificially limited. This is useful for machine code programming, where the block of memory between ramtop and the system data area may be used safely for machine code. CLOAD ----- Type: Command Use: CLOAD "[file]" Loads a program from cassette. CLOAD? ------ Type: Command Use: CLOAD? "[file]" CLOAD? verifies that the program in memory (may have been previously loaded with CLOAD) matches the program in the storage device. A response of "Ok" means the programs match. A response of "BAD" means the programs do not match. CLOSE ----- Type: Command Use: CLOSE {{#}[file number]}{,{#}[file number]} ... CLOSE writes out data in the file buffer and ends possible file i/o to designated files. If no file numbers are specified, all files are closed. CLS --- Type: Command Use: CLS Clears the LCD screen. If function key display is enabled, function key labels will remain displayed. COM ON/OFF/STOP --------------- Type: Command Use: COM ON COM OFF COM STOP Enables and disables processing of communications (RS232). COM ON sets up BASIC's interrupt service routine. COM OFF and COM STOP keep BASIC from processing incoming characters. CONT ---- Type: Command Use: CONT Continues program execution at the place of the halt if no program modifications have been made. COS --- Type: Function Use: [variable] = COS([numeric]) COS returns the trigonometric cosine of an angle. The angle must be in radians. CSAVE ----- Type: Command Use: CSAVE "[file]" Saves a program to cassette. CSRLIN ------ Type: Function Use: [variable] = CSRLIN Returns the current line number of the cursor, 0 through 6 or 7 (depending on whether function key labels are enabled). 0 is the top line. DATA ---- Type: Command Use: DATA [constant] {,[constant]} ... DATA holds a series of constants in memory for later retrieval via READ commands. Multiple DATA statements may appear in a single program. Constants may be numeric or string data types (strings appear in data statements without quotes). DATE$ ----- Type: Command or Function Use: DATE$ = "[year]/[month]/[day]" [string variable] = DATE$ When used as a command, DATE$ sets the system clock to a particular date (time is changed separately with TIME$). When used as a function, DATE$ returns the current date setting of the system clock as a string. DEFINT/SNG/DBL/STR ------------------ Type: Command Use: DEFINT [character range] DEFSNG [character range] DEFDBL [character range] DEFSTR [character range] Defines ranges of variable names as particular data types. Using these commands at the beginning of a program can speed execution, since BASIC then knows exactly how to treat a variable based upon the name. Variable names not DEFined are assumed to be single precision real numbers. Ranges can be specified as single letters separated by commas, or letter ranges (two single letters separated by a hyphen). DIM --- Type: Command Use: DIM [variable name] ([max size]{,[max size]}...) Allocates memory for arrays. Arrays not DIMensioned are limited to 10 elements. EDIT ---- Type: Command Use: EDIT {[line to begin edit]}{-[line to end edit]} Envokes the system TEXT editor for the whole program (no line numbers specified) or selected lines. END --- Type: Command Use: END Terminates the program, closes files, and returns BASIC to direct mode. EOF --- Type: Function Use: EOF([file number]) EOF returns true if the file pointer for the current file is currently at the end of the file, the point at which no more records may be read. This function is most commonly used in an IF statement. It must be placed in the program's loop structure at the beginning of the loop (called a DOWHILE configuration). Numerically, true is anything not equal to 0 and false=0. EQV --- Type: Logical Operator Use: [variable] = [numeric] EQV [numeric] The EQV operator converts both operands to 16-bit signed integers and then performs a logical EQV between each bit in the two numbers. Bit 0 of operand 1 and operand 2 are EQVed to get bit 0 of the result, and so forth. The truth table for EQV is: A B R 0 0 1 0 1 0 1 0 0 1 1 1 ERL --- Type: Function Use: ERL ERL returns the line number where an error occurred. In direct mode, ERL returns 65535. ERR --- Type: Function Use: ERR ERR returns the error code of the last error detected by BASIC. ERROR ----- Type: Command Use: ERROR [byte] ERROR simulates an error with ERR code [byte]. The code must be in the range 0 to 255. EXEC ---- Type: Command Use: EXEC [start address] EXEC transfers computer control to a machine code routine stored at the start address. Data may be transferred to the machine code routine in one of three registers by POKEing values into one of the following locations. Similarly, values may be returned from the machine code routine by PEEKing the following locations. A = 63911 H = 63913 L = 63912 Control is returned to BASIC via a RET instruction. EXP --- Type: Function Use: EXP([numeric expression]) Returns the value of e (2.71828) raised to the value of the specified numeric expression. The maximum power allowed is approximately 87. FILES ----- Type: Command Use: FILES FILES displays the files available in RAM. Files with .BA extensions are BASIC programs. Files with .DO extensions are text files, and files with .CO extensions are machine code programs. A BASIC file marked with a star (*) is the currently loaded BASIC program. FIX --- Type: Function Use: [variable] = FIX([numeric]) FIX returns the integer portion of a real number. FOR..TO..STEP...NEXT -------------------- Type: Loop control structure Use: FOR [variable] = [initial] TO [final] {STEP [increment]} NEXT {[variable]} {,[variable]} ... The FOR..NEXT loop structure is the only predefined formal loop structure in N82 BASIC. It declares a variable as a counter, sets an initial value, and executes the code between the FOR statement and the NEXT statement once per loop cycle. At the end of each cycle, BASIC increments the counter by 1 (default) or by a STEP value. When the counter]final, the loop stops and execution continues with the statement following the NEXT statement. The variable after NEXT may be omitted. BASIC will assign NEXT to the last variable used in a FOR statement. Multiple variables may be NEXTed by listing them with commas between each variable. The innermost loop counter should be first. If the STEP increment is 0, the loop will be infinite. If the STEP increment is negative, the loop will count down (initial must be ] final). If the initial condition is untrue (a positive STEP increment with initial]final for example), BASIC will not loop. The commands will be executed once as if they were normal commands with no FOR..NEXT loop. FRE --- Type: Function Use: FRE([numeric]) FRE([string]) FRE returns the amount of free memory for one of BASIC's several memory areas. The memory area checked depends upon the type of value represented by the given parameter. To check the amount of program memory available, use a numeric value, variable, or expression. To check the amount of string memory available, use a string character or variable. GOSUB..RETURN ------------- Type: Control Use: GOSUB [line number] RETURN When BASIC encounters a GOSUB statement, it transfers program control to the specified line number. The line number may be implicitly stated, calculated, or contained in a variable. Subroutines should end with RETURN. When BASIC encounters RETURN, it transfers program control back to the statement immediately following the calling GOSUB. Since BASIC searches the program sequentially for the starting line number of the subroutine, program speed may be increased by placing subroutines at the beginning of the program: 1 GOTO 3000 xxxx REM Subroutine 1 xxxx xxxx RETURN xxxx REM Subroutine 2 xxxx xxxx RETURN 3000 REM Begin main program xxxx xxxx END GOTO ---- Type: Control Use: GOTO [line number] GO TO [line number] GOTO transfers program control to a line number. The line number may be implicitly stated, calculated, or contained in a variable. A much maligned control command, GOTO has borne the brunt of programmer whining for several decades. Programmer perfectly happy with JMP commands in assembler language hypocritically denounce GOTO. However, GOTO is an important command in N82 BASIC. By using GOTO, the programmer can build DO..WHILE and REPEAT..UNTIL style structures. IF..THEN..ELSE IF..GOTO..ELSE -------------- Type: Control Use: IF [expression] THEN [clause] {ELSE [clause]} IF [expression] GOTO [clause] {ELSE [clause]} IF..THEN statements allow decision making within a program. BASIC evaluates the expression to see if it is true; if so, program control transfers to the statement(s) or the line number in the THEN clause. If the expression is false, program control transfers to the line number or statement in the optional ELSE clause. Clauses: [expression] may be [arithmetic expression] OR [logical expression] OR [relational expression] [then clause] may be [statement] OR [multiple statement] OR [line number] [goto clause] may be [line number] [else clause] may be [statement] [line number] When IF..THEN..ELSE statements ar nested, an ELSE will refer back to the most recently executed IF statement. IMP --- Type: Logical operator Use: [operand] IMP [operand] IMP returns a false value only when the first operand is true and the second operand is false. A B R 0 0 1 0 1 1 1 0 0 1 1 1 INKEY$ ------ Type: Function Use: [string variable] = INKEY$ INKEY$ returns the character value of a key pressed by the user. If no key is currently pressed, the function returns a null string. INKEY$ is usually called in a loop. INP --- Type: Function Use: [byte] = INP([byte]) INP returns the value of the byte at a particular hardware input port. INPUT ----- Type: Function Use: INPUT {"[prompt]";}[variable]{,[variable}... INPUT returns values or strings from the user via the keyboard. An optional prompt string may be displayed. INPUT$ ------ Type: Function Use: [string variable] = INPUT$([integer]{,{#} [file number]} ) INPUT$ returns a character string of a specified length from either the keyboard (no file number specified) or a RAM file. INPUT# ------ Type: Function Use: INPUT# [file number],[variable] {,[variable]...} INPUT# returns the values for the specified variables from a RAM file. INSTR ----- Type: Function Use: [variable] = INSTR( {[numeric],} [string], [substring]) INSTR returns the position of the [substring] within the [string]. The optional [numeric] is a starting position from which to begin the search. INT --- Type: Function Use: [numeric] = INT([numeric]) INT returns the integer portion of a real number. KEY --- Type: Command Use: KEY [key number],[string] KEY sets the command assigned to a function key. KILL ---- Type: Command Use: KILL "[file name]" Erases a file. N82 BASIC is case sensitive for file names, and the name must include the extension. LEFT$ ----- Type: Function Use: [variable] = LEFT$([string],[numeric]) LEFT$ returns the first [numeric] characters of the [string]. LEN --- Type: Function Use: [varable] = LEN([string]) LEN returns the length of the string. LET --- Type: Command Use: {LET} [variable] = [expression] Assigns a value to a variable. LET is an unusual command, since the keyword LET is optional. To save memory, most programmers omit the keyword. The keyword is allowed for compatibility with other Microsoft BASICs. LINE INPUT ---------- Type: Command Use: LINE INPUT {"[prompt]";} [string variable] Allows input of up to a 255 character string. An optional prompt string may be displayed. LIST/LLIST ---------- Type: Command Use: LIST {[start line]} {,[end line]} LLIST {[start line]} {,[end line]} Lists program line(s) to screen (LIST) or printer (LLIST). If no line numbers are specified, BASIC lists the entire program. LOAD ---- Type: Command Use: LOAD " {[device]:} [file name] " {,R} Loads a .BA or a .DO file from a device. Standrd devices are CAS, RAM, and COM. For .BA programs, the optional ",R" instructs BASIC to run the program immediately after loading. Aftermarket DOS programs may add a device for the disk drive. LOCATE ------ Type: Command Use: LOCATE [x],[y] Places cursor at a specific x,y coordinate in text mode. Valid x values are 0-39. Valid y values are 0-6 (fkeys on) or 0-7 (fkeys off). LOG --- Type: Function Use: [variable] = LOG([numeric]) Returns the natural logarithm (base e) of a number. LPOS ---- Type: Function Use: [variable] = LPOS( [dummy numeric] ) Returns the position of the "print head" within the printer buffer. The dummy numeric must be specified. For simplicity, use 0. MAXFILES -------- Type: Command Use: MAXFILES = [numeric] Sets the maximum number of files that may be open in BASIC. MENU ---- Type: Command Use: MENU Exits BASIC. MERGE ----- Type: Command Use: MERGE " {[device]:} [file name] " MERGEs a program from RAM or an external device with the program currently in BASIC. The lines in the program being read into BASIC have precedence if BASIC finds identical line numbers. MID$ ---- Type: Function Use: [string] = MID$([string],[first]{,[num chars]}) MID$ returns a specified number of characters from any position within a string. When [num chars] is omitted, MID$ returns all characters from [position] through the end of the string. MOD --- Type: Logical operator Use: [variable] = [operand] MOD [operand] MOD returns the integer remainder of a divide of two integers. The second operand may not be 0. MOTOR ----- Type: Command Use: MOTOR [integer] MOTOR turns on and off the cassette port relay. MOTOR 0 opens the relay contacts (off) and MOTOR 1 through MOTOR 255 close the relay contacts (on). NAME ---- Type: Command Use: NAME "[file name]" AS "[new file name]" Renames a file in RAM. NEW --- Type: Command Use: NEW Closes all open files and clears the program from BASIC's working memory. No RAM files are erased, including the RAM file copy of any program that was open in BASIC when the user issues the command. NOT --- Type: Logical operator Use: [variable] = NOT [operand] NOT inverts the bits in the operand. 0 becomes 1 and 1 becomes 0. ON ... GOTO ON ... GOSUB ------------ Type: Program control Use: ON [expression] GOTO [line] {,[line]} ... ON [expression] GOSUB [line] {,[line]} ... Transfers control to a calculated line number specified in the command. The integer portion of the numeric expression determines which of the listed line numbers BASIC transfers control to. If INT([expression])=1, then BASIC uses the first line number. If 2, the second, etc. ON COM GOSUB ------------ Type: Program control Use: ON COM GOSUB [line] If COM ON is true, then BASIC calls the subroutine at [line] when a character appears at the serial port. ON ERROR GOTO ------------- Type: Program control Use: ON ERROR GOTO [line] Transfers control to a particular [line] when BASIC encounters a trappable error condition. If [line] = 0 then BASIC removes the error trap routine. See RESUME. OPEN ---- Type: Command Use: OPEN " {[device]:} [file name] " FOR [input/output/append] AS {#} [file number] OPENs a sequential file in BASIC for INPUT, OUTPUT, or APPEND mode. The file number is a byte used in subsequent file commands instead of the file name. The number of open files cannot exceed the MAXFILES setting. OPEN "COM" ---------- Type: Command Use: OPEN "COM: [stat]" FOR [input/output] AS {#} [file number] Sets the communication parameters of the serial port and assigns a file number and mode for serial communications. [stat] is a configuration string for the serial port, made up of six single character codes in the form [CPBSXI]: C = Comm baud rate 1 = 75 6 = 2400 2 = 110 7 = 4800 3 = 300 8 = 9600 4 = 600 9 = 19200 5 = 1200 P = Parity N = no I = ignore E = even O = odd B = Data bits 6, 7, 8 S = Stop bits 1, 2 X = xon/xoff X = use xon/xoff N = no I = shift in/out S = use shift in N = no and out ctrl OR -- Type: Logical operator Use: [variable] = [operand] OR [operand] The OR operator converts both operands to 16-bit signed integers and then performs a logical OR between each bit in the two numbers. Bit 0 of operand 1 and operand 2 are ANDed to get bit 0 of the result, and so forth. The truth table for OR is: A B R 0 0 0 0 1 1 1 0 1 1 1 1 OUT --- Type: Command Use: OUT [port],[byte] OUT writes the value of a data byte to the i/o port at [address]. PEEK ---- Type: Function Use: PEEK ( [address] ) PEEK returns the value of a data byte stored at a RAM [address]. POKE ---- Type: Command Use: POKE [address],[data] POKE stores the value of a data byte at a RAM [address]. POS --- Type: Function Use: POS ( [dummy expression] ) POS returns the current cursor position, column 0-39. The [dummy expression] doesn't matter. Use 0. POWER ----- Type: Command Use: POWER [timer] POWER OFF POWER CONT POWER performs two functions: shuts down the computer via program/user command or sets up the automatic power system. [timer] is a number from 10 through 255. Assume about 6 per second, so 6 = 1 second and 12 = 2 seconds, etc. CONT means "continuous" power. In this mode the PC-8201A will not power off automatically. OFF shuts off the machine immediately. PRESET ------ Type: Command Use: PRESET ( [horiz],[vert] {,[function]} ) PRESET resets the dot at position [horiz],[vert]. [horiz] must be in the range 0-239 and [vert] must be in the range 0-63. [function] is an unusual parameter. It must be in the range 0-255. If odd, the function does nothing. If even, BASIC makes PRESET work like PSET. PRINT/LPRINT ------------ Type: Command Use: PRINT {"} { [expression] ... } {"} LPRINT {"} { [expression] ... } {"} PRINT outputs expressions to the screen. PRINT by itself outputs an empty line. Literal strings must be enclosed in the "optional" double quotes. Expressions must be separated by either a comma (,) or a semicolon (;). A comma places spaces between the parameters. A semicolon between parameters places the two in the output stream with no separation. LPRINT is identical except that the output goes to the printer port instead of the LCD. PRINT USING/LPRINT USING ------------------------ Type: Command Use: PRINT USING [formatting string]; [numeric expression] LPRINT USING [formatting string]; [numeric expression] Formatted output command using a special formatting string string. This is one of the most often misunderstood commands. After learning the formatting codes, the formatted output in newer versions of Microsoft Windows products won't look so odd! The formatting code is a string of characters, each character representing a symbol to include or how to display a digit. In general, there is one symbol for each digit that you wish to display and additional symbols for the decimal point, dollar signs, negative sign, etc. The number of symbols for the place values sets the fixed point precision for the displayed value. If insufficient digits are given for the mantissa, BASIC displays the value with a trailing % sign. Symbols: # Displays one digit. If the numeric value doesn't fill all the # symbols, BASIC displays the value with leading spaces. . Decimal point. Sets location of the radix. Only one decimal point may be specified. A second "decimal point" is used by BASIC to end one field and start another, useful in some multiple variable applications. , Comma. May be placed in the code string anywhere after the first # and before the decimal point. Tells BASIC to punctuate the result with a comma every 3 digits to separate hundreds from thousands, etc. + Leading sign. Place at the beginning or at the end of the code string to tell BASIC to use leading sign indicators. This is a default. - Trailing sign. Place at the end of the code string to specify trailing negative signs for negative numbers. Useful for sending data files to some mainframe apps that require trailing signs. ^ Exponent. Place four of them at the end of the code string to specify using E+xx notation (one for each space required). ** Double asterisk. Place at the beginning of the code string to tell BASIC to use leading asterisks. N82 BASIC does not support the following symbols valid in other versions of Microsoft BASIC: 0 (leading 0), $$ (double dollar sign for floating $), [[[[ (exponential), ! (exclamation, print only 1st char), %% or \\ (used to include a string of spaces). PSET ---- Type: Command Use: PSET ( [horiz],[vert] {,[function]} ) PSET sets the dot at position [horiz],[vert]. [horiz] must be in the range 0-239 and [vert] must be in the range 0-63. [function] is an unusual parameter. It must be in the range 0-255. If even, the function does nothing. If odd, BASIC makes PSET work like PRESET. READ ---- Type: Command Use: READ [variable list] READ is used with DATA to include data values into a program. READ gets the next avail DATA value and assigns the variable that value. REM --- Type: Comment Use: REM [comment] ' [comment] All text in a line from REM forward to the end of the line will be ignored by BASIC during execution. REM may be abbreviated by using an apostrophe ('). RENUM ----- Type: Command Use: RENUM {[new line #]} {,[old line #]} {,[step]} RENUMbers the BASIC program. If no line numbers of step value is given, BASIC renumbers, outputting a program whose first line is 10 using a step of 10 between each line. RENUM is smart enough to renumber GOTO, GOSUB, ON..GOTO, ON..GOSUB, THEN, RESTORE. RENUM will not resequence lines. Line numbers may not be greater than 65529. RESTORE ------- Type: Command Use: RESTORE {[line number]} Resets the data pointer for READ/DATA. If a line number is given, the next READ will read from the first DATA item on the specified line. If [line number] is omitted, READ will read from the first DATA statement in the program. RESUME ------ Type: Command Use: RESUME {[0]} RESUME [NEXT] RESUME [line number] Used to resume program execution after an error. There are three forms: RESUME or RESUME 0 causes BASIC to resume where the error occurred. RESUME NEXT causes BASIC to resume with the statement immediately following where the error occurred. RESUME [line number] causes BASIC to resume at the specified line number. RETURN ------ Type: Program control Use: RETURN {[line number]} RETURN is usually used with no parameter to return control to the statement immediately after a calling GOSUB or interrupt routine. The optional line number overrides BASIC's normal return sequence and transfers control to the specified line number. The difference between a RETURN [line number] and a GOTO at the end of a subroutine call (neither is a very good way to transfer program control) is that the RETURN [line number] removes the normal return address from the stack. RIGHT$ ------ Type: Function Use: [string] = RIGHT$ ([string],[numeric]) RIGHT$ returns the rightmost [numeric] characters of the source string. RND --- Type: Function Use: [numeric] = RND ([seed]) RND calculates a random number between 0 and 1 given a numeric seed value. The method used for all Microsoft BASICs this author can find documented is linear congruence, a well documented algorithm that yields good results from little code overhead. The [seed] can take three forms: RND ([negative number]) Causes BASIC to start a new RND sequence using the specified seed. RND ([positive number]) Causes BASIC to return the next random number in the current sequence. RND (0) Returns the last result. The user may gain good results by calulating the number of seconds since midnight (some Microsoft BASICs do this via the TIMER function), making it negative, and using this number as the seed. The seed should be negative for the first RND call and positive thereafter. RUN --- Type: Command Use: RUN {[line number]} RUN " {[device]:} [file name] " {,R} RUNs the current or specified program from the beginning or from the specified line number. According to the N82 BASIC manual, the optional {,R} parameter will open all data files. The usefulness of this trick escapes me. SAVE ---- Type: Command Use: SAVE " {[device]:} [file name] " {,A} SAVEs the current program in BASIC to the specified file name. If the file name is a duplicate, the file in BASIC overwrites the file in RAM. If the file name ends in .BA or does not have an extension BASIC will save it as a tokenized BASIC (.BA) program. If the given extension is .DO or the optional {,A} parameter is given, BASIC saves the program as an ASCII file suitable for upload/download via TELCOM. A program may not be saved twice with the same file name without BASIC generating a "?FC Error". SCREEN ------ Type: Command Use: SCREEN {[dummy]},[fkey switch] Sets the screen mode as 8 lines without displayed function keys or 7 lines with displayed function keys. A function key switch of 0 means 8 line mode. Non-zero means 7 line mode. Note that the comma before the fkey switch is required, though the numeric dummy (usually 0) is not required. SGN --- Type: Function Use: [variable] = SGN ([numeric]) Returns a 1 is the number is positive, 0 if the number is 0, and -1 if the number is negative. SIN --- Type: Function Use: SIN ([numeric]) SIN returns the trigonometric sine of an angle. The angle must be in radians. SOUND ----- Type: Command Use: SOUND [tone],[length] Produces a sound of specified tone and length from the piezoelectric speaker. The length is in the range 0-255, with each unit being 0.02 seconds. The tone is in the range 0-16383, and may be taken from the following chart: OCTAVE: 1 2 3 4 5 6 C - 9394 4697 2348 1171 587 C# - 8866 4433 2216 1103 554 D - 8368 4184 2092 1045 523 D# 15800 7900 3950 1975 987 493 E 14912 7456 3728 1864 932 466 F 14064 7032 3516 1758 879 439 F# 13284 6642 3321 1660 830 415 G 12538 6269 3134 1567 783 - G# 11836 5918 2954 1479 733 - A 11172 5586 2793 1396 693 - A# 10544 5272 2636 1316 653 - B 9952 4968 2486 1244 622 - According to the N82 BASIC manual, 5586 = 440 Hz. SPACE$ ------ Type: Function Use: [string] = SPACE$ ([numeric]) Returns a string of spaces equal to the integer portion of the [numeric]. [numeric] must be in the range 0-250. SQR --- Type: Function Use: [variable] = SQR ([positive numeric]) Returns the square root of [positive numeric]. STOP ---- Type: Command Use: STOP Halts the running BASIC program and returns to direct mode without closing the program file like END. If the program is not altered by the user while STOPped, the program may be continued with CONT. While STOPped, the user may examine variables. Useful for debugging. STR$ ---- Type: Function Use: [string] = STR$ ([numeric]) Converts the [numeric] to its string representation. STRING$ ------- Type: Function Use: [string] = STRING$ ([numeric],"[character]") [string] = STRING$ ([numeric],[ASCII code]) Returns a string of specified length made up of the repeated specified character. [numeric] must be in the range 0-250. TAB --- Type: Function Use: TAB ([numeric]) Used within PRINT and LPRINT for formatting text. Inserts a series of spaces to take the output stream to the position specified by [numeric]. The position in the putput stream is left to right, so TAB statements in a single PRINT/LPRINT to the right of another TAB where the second [numeric] is less than the first [numeric] are ignored. TAN --- Type: Function Use: [variable] = TAN ([numeric]) TAN returns the trigonometric tangent of an angle. The angle must be in radians. TIME$ ----- Type: Command or Function Use: TIME$ = "[hour]:[min]:[sec]" [string variable] = TIME$ When used as a command, TIME$ sets the system clock to a particular time (date is changed separately with DATE$). When used as a function, TIME$ returns the current time setting of the system clock as a string. VAL --- Type: Function Use: [variable] = VAL ([numeric string]) Returns the numeric value of the string. The string must be the string representation of a valid number, otherwise VAL returns 0. The symbols plus (+), minus (-), the decimal point (.), and the digits 0-9 are valid characters. VAL processes the [numeric string] left to right until either (1) the end of the string or (2) the first non-numeric character. XOR --- Type: Logical operator Use: [variable] = [operand] XOR [operand] The XOR operator converts both operands to 16-bit signed integers and then performs a logical XOR between each bit in the two numbers. Bit 0 of operand 1 and operand 2 are XORed to get bit 0 of the result, and so forth. The truth table for XOR is: A B R 0 0 0 0 1 1 1 0 1 1 1 0 ---------------------------------------------------- END ----------------------------------------------------
Original author of this page: David Firth.
This page best viewed on ANY browser. This author strongly supports access by persons with limited-capability and text-only browsers. Content is better than flash & dazzle.