| Previous | Contents | Index | 
The DIMENSION statement creates and names a static, dynamic, or virtual array. The array subscripts determine the dimensions and the size of the array. You can specify the data type of the array and associate the array with an I/O channel.
 
| DIM #1, STRING vir_array(100) = 12 OPEN "STATS.BAS" FOR OUTPUT as #1, VIRTUAL | 
| %BASIC-W-STRLENINC, virtual array string VIR_ARRAY length increased from 12 to 16 | 
| DIM #1, A(10) DIM #1, B(10) | 
| !Nonvirtual, Nonexecutable DIM STRING name_list(20 TO 100), BYTE age(100) | 
| !Virtual DIM #1%, STRING name_list(500), REAL amount(10,10) | 
| !Executable DIM DOUBLE inventory(base,markup) . . . DIM DOUBLE inventory (new_base,new_markup) | 
The ECHO function causes characters to be echoed at a terminal that is opened on a specified channel.
 
Chnl-exp must specify a terminal.
| 
DECLARE INTEGER Y,                     & 
        STRING pass_word 
Y = NOECHO(0%) 
SET NO PROMPT 
INPUT "Enter your password: ";pass_word 
Y = ECHO(0%) 
IF pass_word = "Darlene" 
THEN 
    PRINT CR+LF+"YOU ARE CORRECT !" 
END IF 
 | 
Output
| Enter your password? YOU ARE CORRECT ! | 
The EDIT$ function performs one or more string editing functions, depending on the value of its integer argument.
 
None
| Value | Edit Performed | 
|---|---|
| 1 | Discards each character's parity bit (bit 7) | 
| 2 | Discards all spaces and tabs | 
| 4 | Discards all carriage returns <CR>, line feeds <LF>, form feeds <FF>, deletes <DEL>, escapes <ESC>, and nulls <NUL> | 
| 8 | Discards leading spaces and tabs | 
| 16 | Converts multiple spaces and tabs to a single space | 
| 32 | Converts lowercase letters to uppercase letters | 
| 64 | Converts left bracket ([) to left parenthesis [(] and right bracket (]) to right parenthesis [)] | 
| 128 | Discards trailing spaces and tabs (same as TRM$ function) | 
| 256 | Suppresses all editing for characters within quotation marks; if the string has only one quotation mark, BASIC suppresses all editing for the characters following the quotation mark | 
| DECLARE STRING old_string, new_string old_string = "a value of 32 converts lowercase letters to uppercase" new_string = EDIT$(old_string,32) PRINT new_string | 
Output
| A VALUE OF 32 CONVERTS LOWERCASE LETTERS TO UPPERCASE | 
The END statement marks the physical and logical end of a main program, a program module, or a block of statements.
 
None
| 
10   INPUT "Guess a number";A% 
     IF A% = 24 
     THEN 
            PRINT, "YOU GUESSED IT!" 
     END IF 
     IF A% < 24 
     THEN 
            PRINT, "BIGGER IS BETTER!" 
     GOTO 10 
     END IF 
 
     IF A% > 24 
     THEN 
            PRINT, "SMALLER IS BETTER!" 
            GOTO 10 
     END IF 
 
     END PROGRAM 
 | 
The ERL function returns the number of the BASIC line where the last error occurred.
 
The value of int-var returned by the ERL function is a LONG integer.
| 
10 DECLARE LONG int_exp 
   WHEN ERROR USE error_routine 
20 INPUT "Enter an integer expression";int_exp 
30 PRINT DATE$(int_exp) 
   END WHEN 
   HANDLER error_routine 
   IF ERL = 20 
   THEN 
        PRINT "Invalid input...try again" 
        RETRY 
   ELSE 
        PRINT "UNEXPECTED ERROR" 
        EXIT HANDLER 
   END IF 
   END HANDLER 
   END PROGRAM 
 | 
Output
| Enter an integer expression? ABCD Error occurred on line 20 Enter an integer expression? 0 07-Feb-00 | 
The ERN$ function returns the name of the main program, subprogram, or DEF function that was executing when the last error occurred.
 
None
| 
10 DECLARE LONG int_exp 
   !This module's name is DATE 
   WHEN ERROR IN 
   INPUT "Enter an number";int_exp 
   USE 
      PRINT "Error in module ";ERN$ 
      RETRY 
   END WHEN 
   PRINT Date$(int_exp) 
   END 
 | 
Output
| Enter a number? ABCD Error in module DATE Enter a number? 0 07-Feb-00 | 
The ERR function returns the error number of the current run-time error.
 
The value of int-var returned by the ERR function is always a LONG integer.
If the ERR function is used before an error occurs or after an error is handled, the results are undefined.
| 
10 DECLARE LONG int_exp 
   WHEN ERROR USE error_routine 
20 INPUT "Enter an integer expression";int_exp 
   PRINT DATE$(int_exp) 
   END WHEN 
   HANDLER error_routine: 
        PRINT "Error number";ERR 
        IF ERR = 50  THEN PRINT "DATA FORMAT ERROR" 
        ELSE PRINT "UNEXPECTED ERROR" 
        END IF 
        RETRY 
   END HANDLER 
        END 
 | 
Output
| Enter an integer expression? ABCD Error number 50 DATA FORMAT ERROR Enter an integer expression? 0 07-Feb-00 | 
The ERT$ function returns explanatory text associated with an error number.
 
Int-exp is a BASIC error number. The error number should be a valid BASIC error number.
| 
10 DECLARE LONG int_exp 
   WHEN ERROR USE error_routine 
20 INPUT "Enter an integer expression";int_exp 
   PRINT DATE$(int_exp) 
   END WHEN 
   HANDLER error_routine 
        PRINT "Error number";ERR 
        PRINT ERT$(ERR) 
        RETRY 
   END HANDLER 
   END 
 | 
Output
| Enter an integer expression? ABCD Error number 50 %Data format error Enter an integer expression? 0 07-Feb-00 | 
| Previous | Next | Contents | Index |