📄 basic-man.txt
字号:
variables. Reading past the end the last DATA statement generates an error. restore { LINENUM } The RESTORE statement causes the next READ to use the first DATA statement in the program. If a LINENUM is given then the DATA statement on or after that particular line is used next. rem or "`" A remark or comment statement. Ignored by the program during execution, however a REM statement can be the target of a GOTO or GOSUB. open STRINGEXPR for { input|output|append } as # FNUM Open a file. The { input|output|append } parameter specifies whether the file is to be read, written or appended. If STRINGEXPR is "stdin" for input or "stdout" for output then the console will be used instead of a file. A "file not found" error will occur if a non-existant file is specified in an OPEN for input statement. FNUM must be an integer value between 0 and 8. open STRINGEXPR for random as # FNUM len = VAL Opens a random access file. Only GET and PUT statement are allowed to read and write random access files. open ... else goto LINENUM See OPEN command. LINENUM is the line to which control is transferred if an error in opening a file occurs. The variable ERL is set to the line number on which the file open error occured. close # FNUM Close a file. Releases the file descriptor and flushes out all stored data. def fnNAME ( VAR { , VAR } ) = EXPR Define a user definable function. Obsolete. Example: 10 def fnplus(x,y) = x+y 20 print fnplus(3,5) : rem prints 8 option base { 0 | 1 } mat origin { 0 | 1 } Sets the matrix index origin to either 0 or 1 for all MAT statements, including fill. Defaults to 1. mat ARRAY-VAR = EXPR Fills a 1 or 2 dimensional array with a constant value given by EXPR. Lower bound = mat origin mat ARRAY-VAR = idn ( { EXPR } ) Fills a 2 dimensional array with an identity matrix. The array must have been previously dimensioned. mat ARRAY-VAR = ARRAY-VAR Copys a 2 dimensional array. The dimensions must match. mat ARRAY-VAR = ARRAY-VAR { + | * } { EXPR | ARRAY-VAR } Adds or multiplies a 2 dimensional array by either an expression or another array. The dimensions must be appropriate for matrix addition or matrix multiplication. mat ARRAY-VAR = ( EXPR ) { + | - | * } ARRAY-VAR Adds, subtracts or multiplies a 2 dimensional array by an expression. Note that the parenthesis around the expression are required. mat ARRAY-VAR = transpose ARRAY-VAR Transposes a 2 dimensional array. The dimensions of the first array must correspond to the transpose of the dimensions of the second array. mat ARRAY-VAR = invert ARRAY-VAR mat ARRAY-VAR = invert ARRAY-VAR else LINENUM Inverts a 2 dimensional square array. If LINENUM is specified, control is transferred to LINENUM if the matrix is singular. Note that the default array origin is (1,1). mat print ARRAY-VAR mat print ARRAY-VAR ; mat print #n, ARRAY-VAR mat print using STRINGVAL ; ARRAY-VAR Prints a 1 or 2 dimensional array. A trailing semicolon will try to pack the data without tabs. The format STRINGVAL in MAT PRINT USING applies to each element seperately. type CLASSNAME Creates a structure definition type. Each field requires a separate line. Legal types are string, integer, longint and double. The definition must conclude with an END TYPE statement. Use the DIM AS NEW statement to create records containing the structure specified by a TYPE statement. Example: 300 type person 310 name as string * 32 : rem = 31 chars length 320 age as integer : rem 2 byte integers 330 weight as double : rem 8 byte doubles 340 end type 400 dim friend1 as new person 410 friend1.name = "Mark" : friend1.age = 13 420 print friend1.name, friend1.age class CLASSNAME { extends SUPERCLASSNAME } Creates a class definition. Class definitions can then be used to create objects with member functions (also called methods.) Classes inherit members from superclasses (single inheritance.) Example: CLASS bar y AS integer z AS PRIVATE double ' private data s AS PUBLIC string ' public keyword optional SUB blah(v) ' public member function this.y = v + 7 END SUB END CLASS DIM b AS NEW bar ' create object b CALL b.blah(1) ' send message "blah(1)" to b CLASS and TYPE definitions are global, and cannot be nested inside other class definitions or subroutines. dim VAR { ( INT ) } as new CLASSNAME Create a record (TYPED-VAR) or object using a previously defined structure definition type created by TYPE...END TYPE or CLASS..END CLASS. Optionally creates an array of records or objects. option degrees Changes the trigonometric functions to use degrees instead of radians for all parameters and return results. erase VAR Un-dimensions a dimensioned array. Frees memory. { let } mid$( STRINGVAR, EXPR1, EXPR2 ) = STRINGEXPR Replace the sub-string in STRINGVAR, starting at character position EXPR1, with character length EXPR2, with the (EXPR2 in length) string STRINGEXPR. { let } field$( STRINGVAR, VAL { ,STRINGVAL } ) = STRINGEXPR Replace the N-th field of STRINGVAR with STRINGEXPR. poke ADDR_EXPR, DATA_EXPR { , SIZE_VAL } Poke a byte into a memory location. Unreasonable addresses can cause bus or segmentation errors. Use a optional SIZE_VAL of 2 or 4 to poke short or long integers to properly aligned addresses. push VAR { , VAR ... } Pushes one or more expressions or variables onto an internal stack. Expressions can be returned using the POP function; variables can be returned by using the POP statement. pop VAL POP statement (see also POP function). Pops VAL variables off the internal stack, restoring the value of those variables to their pushed values. exec(STRINGEXPR) Executes STRINGEXPR as a statement or command. e.g. exec("print " + "x") will print the value of x. NUMERIC FUNCTIONS sgn(VAL) Returns the sign of the parameter value. Returns 1 if the value is greater than zero , zero if equal to zero. -1 if negative. abs(x) Returns the absolute value of x. int(x) int(x,0) Returns the integer value of x. Truncates toward minus infinity. The absolute value of x must be less than 2^31-1. The usage int(x, 0) truncates towards zero instead of minus infinity. floor(x) Returns the integer value of x. Truncates toward negative infinity. sqr(x) Returns the square root of x. log(x) Returns the natural logarithm of x. log10(x) Returns the logarithm base 10 of x. exp(x) Returns e^x. e=2.7182818... sin(x) cos(x) atn(x) Trigonometric functions: sin, cosine and arctangent. atn(x,y) 4 quadrant arctangent pi Returns pi, 3.141592653589793... rnd ( EXPR ) Returns an integer pseudo-random number between 0 and int(EXPR)-1 inclusive. If EXPR is 1, then returns a rational number between 0 (inclusive) and 1. If EXPR is negative then EXPR seeds the random number generator. randomize EXPR Seeds the random number generator with the integer EXPR. The pseudo-random number generator should return the same sequence when seeded with the same start value. The actual sequence may be system dependant. len( STRINGEXPR ) Returns the length of the string STRINGEXPR. len( TYPED-VAR ) Returns the length, in bytes, of a typed record (one created by DIM AS). val( STRINGEXPR | EXPR ) Value of the expression contained in a STRINGEXPR or EXPR. STRINGEXPR may be a string literal, variable, function, or expression. For example, VAL("1 + sqr(4)") yields 3. asc( STRINGEXPR ) Returns the ascii code for the first character of STRINGEXPR. A null string returns zero. instr(a$, b$ { , VAL } ) Returns the position of the substring b$ in the string a$ or returns a zero if b$ is not a substring. VAL is an optional starting position in a$ ubound( VAR [, EXPR ] ) If VAR is a dimensioned array, returns the maximum legal subscript of the first dimension of that array, else returns 0. Use EXPR to return other dimensions. isarray( VAR ) If VAR is a dimensioned array, returns the number of dimensions, otherwise returns 0. fgetbyte( FILENUM ) Reads one byte from the open file specified by FILENUM and returns an unsigned numeric value [0..255]. eof(FILENUM) Returns true if the the last INPUT statement, INPUT$ or FGETBYTE function call which referenced the text file specified by FILENUM tried to read past the end of file. (Note that reading the last line of a file will not read past the eof mark. A subsequent read is needed to set the EOF flag to true. Reading past the end-of-file will not report an error.) pop POP function (see also POP statement). Pops one variable value off the stack and returns that value (string or numeric). (POP can be used as either a statement (with a parameter) or a function (no parameter). Note that the POP function, unlike the POP statement, does not restore the value of the variable pushed, but only returns the pushed value. This use of the POP statement is different from the Applesoft usage.) peek( ADDR { , SIZE_VAL } ) Returns the value of the byte in memory at address ADDR. If SIZE_VAL is 2 or 4, returns the value of the 16-bit or 32-bit word respectively (if correctly aligned). If SIZE_VAL is 8, returns the value of the numeric variable located at ADDR. (peek(varptr(x),8) == x) varptr( VAR | STRINGVAR ) Returns the memory address of a variable. fn bigendian() Returns 1 if words are stored in memory in bigendian byte order, 0 if in little endian byte order fn bswap16( VAL ) Returns a byte swapped 16-bit value. fn bswap32( VAL ) Returns a byte swapped 32-bit value. erl Returns the line number of the last error. Zero if the error was in immediate mode. The variable errorstatus$ gives the error type. timer Returns a numeric value of elapsed of seconds from the computers internal clock. STRING FUNCTIONS x$ + y$ String concatenation. String concatenation (and the MID$, LEN and INSTR functions) can handle strings of up to 32766 characters in length (if the memory available to the program permits). chr$(VAL) Returns the ascii character corresponding to the value of VAL. str$( VAL { , EXPR } ) Returns a string representation corresponding to VAL. If EXPR is present then the string is padded to that length. format$( VAL , STREXPR ) Returns the string representation of VAL formatted according to the format string STREXPR. The format string STREXPR uses the same formatting syntax as the PRINT USING statement.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -