|
DataMuseum.dkPresents historical artifacts from the history of: CP/M |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about CP/M Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - metrics - download
Length: 150784 (0x24d00) Types: TextFile Names: »D6«
└─⟦e61e7d03c⟧ Bits:30005867/disk01.imd Dokumenter (RCSL m.m.) └─⟦this⟧ »D6«
6M_A_T_R_I_X_ _M_A_N_I_P_U_L_A_T_I_O_N_ 6.1M_a_t_r_i_x_ _o_p_e_r_a_t_i_o_n_s_ RC BASIC includes a special set of statements which allows the user to manipulate two-dimensional arrays (see Ch. 2) as matrices. Among the available matrix operations are the following: Addition, subtraction, and multiplication. Scalar multiplication. Formation of a zero matrix (all elements set to 0). Formation of a constant matrix (all elements set to 1). Formation of an identity matrix (major diagonal elements set to 1, remaining elements set to 0). Calculation of the inverse of a matrix. Calculation of the determinant of a matrix. Transposition of a matrix. Input/output of a matrix via the user"s terminal. All of the above operations are described in the present chapter, while matrix file input/output statements are described in Chapter 8. A_l_l_ _s_t_a_t_e_m_e_n_t_s_ _i_n_v_o_l_v_i_n_g_ _m_a_t_r_i_x_ _o_p_e_r_a_t_i_o_n_s_ _a_r_e_ _i_n_t_r_o_d_u_c_e_d_ _b_y_ _t_h_e_ r_e_s_e_r_v_e_d_ _w_o_r_d_ _M_A_T_._ 6.2D_i_m_e_n_s_i_o_n_i_n_g_ _m_a_t_r_i_c_e_s_ A matrix is dimensioned as a two-dimensional array by means of the DIM statement (see Ch. 3). Thus the statement 10 DIM MATRIXA(10,20) defines a matrix variable named MATRIXA, which has 10 rows and\f 20 columns (or a total of 10 x 20 = 200 elements). A previously dimensioned matrix may be redimensioned by means of a new DIM statement, provided that the total number of elements does not exceed the previously declared total number of elements. Matrix elements are stored by rows in ascending memory locations. As a one-dimensional array containing i elements is considered a l x i matrix, t_h_e_ _m_a_t_r_i_x_ _o_p_e_r_a_t_i_o_n_s_ _d_e_s_c_r_i_b_e_d_ _i_n_ _t_h_e_ _f_o_l_l_o_w_i_n_g_ s_e_c_t_i_o_n_s_ _a_l_s_o_ _a_p_p_l_y_ _t_o_ _o_n_e_-_d_i_m_e_n_s_i_o_n_a_l_ _a_r_r_a_y_s_._ T_6.3M_a_t_r_i_x_ _a_s_s_i_g_n_m_e_n_t_ _s_t_a_t_e_m_e_n_t_ F_o_r_m_a_t_ MAT mvar1' = mvar2' mvar1, mvar2': matrix variables. &_ U_s_e_ As a statement or command to copy the elements of one matrix to another matrix. R_e_m_a_r_k_s_ 1. The matrices must have been dimensioned before the statement is executed. 2. The number of elements in mvar2' must not exceed the number of elements in mvar1'. 3. After the assignment, mvar1' will have the same dimensions and values as mvar2'. \f T_ E_x_a_m_p_l_e_ C_o_m_m_e_n_t_ 0010 DIM MATA(3,2),MATB(2,3) 0020 FOR I=1 TO 3 0030 FOR J=1 TO 2 0040 LET MATA(I,J)=I*10+J 0050 NEXT J 0060 NEXT I 0070 PRINT "MATA : " 0080 MAT PRINT MATA 0090 PRINT "13'10'MATB : " 0100 MAT PRINT MATB 0110 MAT MATB=MATA 0120 PRINT "13'10'NEW MATB : " 0130 MAT PRINT MATB MATA : 11 12 21 22 31 32 MATB : 0 0 0 0 0 0 NEW MATB : Note that the dimensions of 11 12 MATB have been changed. 21 22 &_ 31 32 T_ 6.4M_a_t_r_i_x_ _a_d_d_i_t_i_o_n_/_s_u_b_t_r_a_c_t_i_o_n_ _s_t_a_t_e_m_e_n_t_ F_o_r_m_a_t_ + MAT mvar1' = mvar2' - mvar3' mvar1, mvar2, mvar3' : matrix variables. &_ U_s_e_ As a statement or command to perform the scalar addition or subtraction of two matrices. \f R_e_m_a_r_k_s_ 1. The matrices must have been dimensioned before the statement is executed. 2. mvar2' and mvar3' must have the same dimensions. 3. The number of elements in mvar2' (and mvar3') must not exceed the number of elements in mvar1'. 4. The arithmetic is performed element by element with the resultant value assigned to the element in mvar1'. 5. mvar1' may appear on both sides of the equal sign. 6. After the addition or subtraction, mvar1' will have the same dimensions as mvar2' (and mvar3'). T_E_x_a_m_p_l_e_ C_o_m_m_e_n_t_ 0010 DIM MATA(3,2),MATB(3,2) 0020 FOR I=1 TO 3 0030 FOR J=1 TO 2 0040 LET MATA(I,J)=I*10+J 0050 LET MATB(I,J)=2*(I*10+J) 0060 NEXT J 0070 NEXT I 0080 PRINT "MATA : " 0090 MAT PRINT MATA 0100 PRINT "13'10'MATB : " 0110 MAT PRINT MATB 0120 MAT MATB=MATA+MATB MATB appears on both sides 0130 PRINT "13'10'MATA + MATB :" of the equal sign. &_0140 MAT PRINT MATB \f T_MATA : 11 12 21 22 31 32 MATB : 22 24 42 44 62 64 MATA + MATB : 33 36 The addition of MATA and 63 66 MATB is performed element &_ 93 96 by element. T_ 6.5M_a_t_r_i_x_ _m_u_l_t_i_p_l_i_c_a_t_i_o_n_ _s_t_a_t_e_m_e_n_t_ F_o_r_m_a_t_ mvar2' MAT mvar1' = (expr') * mvar3' mvar1, mvar2, mvar3': matrix variables. expr': a numeric expression (parenthesized). &_ T_U_s_e_ As a statement or command to perform the multiplication of one matrix either by another matrix or by a scalar (the value of a numeric expression). &_ R_e_m_a_r_k_s_ 1. The matrices must have been dimensioned before the statement is executed. 2. The number of columns in mvar2' must match the number of rows in mvar3'. 3. If mvar2' is an n x p matrix (i.e. with n rows and p columns) and mvar3' is a p x m matrix, then mvar1' will be an n x m matrix. \f 4. mvar1' may not appear on the right-hand side of the equal sign, unless it is a scalar multiplication. 5. mvar2' and mvar3' may represent the same matrix (i.e. a square matrix, in which the number of rows matches the number of columns). 6. The product of mvar2' and mvar3' is calculated as follows: Each row of mvar2' is multiplied by each column of mvar3' such that the corresponding elements are multiplied and their products added together to provide the resultant value assigned to the element in mvar1' (see Example). Row number i of mvar2' * column number j of mvar3' will, accordingly, result in element number (i,j) of mvar1'. 7. If a matrix is multiplied by a scalar, each element in mvar3' is multiplied by expr' to give the corresponding element value in mvar1'. In this case, the number of elements in mvar3' must not exceed the number of elements in mvar1'. After the multiplication, mvar1' will have the same dimen- sions as mvar3'. T_E_x_a_m_p_l_e_ 0010 DIM MATA(3,2),MATB(2,3),MATC(3,3) 0020 FOR I=1 TO 3 0030 FOR J=1 TO 2 0040 LET MATA(I,J)=I*10+J 0050 LET MATB(J,I)=I*20+J 0060 NEXT J 0070 NEXT I 0080 PRINT "MATA : " 0090 MAT PRINT MATA 0100 PRINT "13'10'MATB : " 0110 MAT PRINT MATB 0120 MAT MATC=MATA*MATB 0130 PRINT "13'10'MATA * MATB :" 0140 MAT PRINT MATC &_ \f T_MATA :C_o_m_m_e_n_t_ 11 12 21 22 31 32 MATB : 21 41 61 22 42 62 MATA * MATB : DDD21UUU 495 955 1415 495 = (11 12) x DDD22UUU 925 1785 2645 1355 2615 3875 = (11 x 21) + (12 x 22) &_ T_6.6D_E_T_(_X_)_ _f_u_n_c_t_i_o_n_ F_o_r_m_a_t_ var' = DET(expr') var': a numeric variable. expr': a numeric expression (required, but not used). &_ U_s_e_ As a function to return the determinant of the last matrix inverted by a MAT INV statement (see Sect. 6.10). R_e_m_a_r_k_s_ 1. The DET(X) function requires an argument, although the argument does not affect the resulting determinant and the function does not affect the argument. 2. For calculation of the determinant of a matrix, see Section 6.10. T_E_x_a_m_p_l_e_ See the MAT INV statement (Sect. 6.10). &_ \f T_6.7M_A_T_ _C_O_N_ _s_t_a_t_e_m_e_n_t_ F_o_r_m_a_t_ MAT mvar' = CON mvar': a matrix variable. &_ U_s_e_ As a statement or command to initialize a matrix such that all elements are set to one. R_e_m_a_r_k_s_ 1. The matrix must have been dimensioned before the statement is executed. 2. All elements of mvar' are set to one regardless of any previously assigned values. 3. The resulting matrix is often called a constant matrix. \f T_E_x_a_m_p_l_e_ 0010 DIM MATA(3,2) 0020 FOR I=1 TO 3 0030 FOR J=1 TO 2 0040 LET MATA(I,J)=I*10+J 0050 NEXT J 0060 NEXT I 0070 PRINT "MATA : " 0080 MAT PRINT MATA 0090 MAT MATA=CON 0100 PRINT "13'10'NEW MATA :" 0110 MAT PRINT MATA MATA : 11 12 21 22 31 32 NEW MATA : 1 1 1 1 1 1 &_ T_6.8M_A_T_ _I_D_N_ _s_t_a_t_e_m_e_n_t_ F_o_r_m_a_t_ MAT mvar' = IDN mvar': a matrix variable. &_ U_s_e_ As a statement or command to initialize a matrix such that all elements (i,i) are set to one and the remaining elements are set to zero. R_e_m_a_r_k_s_ 1. The matrix must have been dimensioned before the statement is executed. 2. If mvar' is an n x p matrix (i.e. with n rows and p\f columns), then all elements (i,i), 1 = i = minimum (n,p), are set to one and the remaining elements are set to zero (see Example). 3. If mvar' is a square matrix (i.e. where n = p), then the resulting matrix will be the identity matrix, in which all elements of the major diagonal are set to one and the remaining elements are set to zero (see Example). T_E_x_a_m_p_l_e_ 0010 DIM MATA(3,2),MATB(6,6) 0020 FOR I=1 TO 3 0030 FOR J=1 TO 2 0040 LET MATA(I,J)=I*10+J 0050 NEXT J 0060 NEXT I 0070 PRINT "MATA : " 0080 MAT PRINT MATA 0090 MAT MATA=IDN 0100 PRINT "13'10'NEW MATA :" 0110 MAT PRINT MATA 0120 MAT MATB=IDN 0130 PRINT "13'10'MATB :" 0140 MAT PRINT MATB; &_ T_MATA : 11 12 21 22 31 32 NEW MATA : 1 0 0 1 0 0 MATB : 1 0 0 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0 0 0 1 0 &_ 0 0 0 0 0 1 \f T_ 6.9M_A_T_ _I_N_P_U_T_ _s_t_a_t_e_m_e_n_t_ F_o_r_m_a_t_ MAT INPUT mvar1' ,mvar2', ... ,mvar-n' mvar1, mvar2, mvar-n': matrix variables. &_ U_s_e_ As a statement or command to assign numeric values entered from the user"s terminal during program execution to the elements of one or more matrices. R_e_m_a_r_k_s_ 1. The matrices must have been dimensioned before the statement is executed. 2. When a MAT INPUT statement is executed, the system outputs a question mark (?) as an initial prompt. 3. The user responds by typing a list of numeric data items, each of which is separated from the next by a comma. The last item is followed by a carriage return. 4. If the data list is terminated (by pressing the RETURN key) before values have been assigned to all of the matrix elements, the system will output / ? as a prompt, indicating that further items are expected. T_6.10M_A_T_ _I_N_V_ _s_t_a_t_e_m_e_n_t_ F_o_r_m_a_t_ MAT mvar1' = INV(mvar2') mvar1, mvar2': matrix variables. &_ U_s_e_ As a statement or command to invert a matrix and assign the resultant element values to another matrix. \f R_e_m_a_r_k_s_ 1. The matrices must have been dimensioned before the statement is executed. 2. The inverse, B, of a matrix, A, is defined such that the products of A x B and B x A are both equal to the identity matrix. 3. mvar2' must be a square matrix. 4. The determinant (see Remark 6) of mvar2' must not equal zero. 5. After the inversion of a matrix, the determinant of that matrix can be obtained by means of the DET(X) function (see Sect. 6.6). 6. M_a_t_r_i_x_ _d_e_t_e_r_m_i_n_a_n_t_s_ In order to calculate the inverse of a matrix, one must first calculate the determinant of that matrix. The calculation of the determinant of a 2 x 2 matrix is described in the following. For larger matrices, consult a mathematics text. The determinant of a 2 x 2 matrix a b a b c d is written as c d . The determinant is the scalar (a x d) - (b x c) i.e. multiplication along the diagonals and subtraction of the product of the second diagonal from the product of the major diagonal. &_\f T_ 6.11M_A_T_ _P_R_I_N_T_ _s_t_a_t_e_m_e_n_t_ F_o_r_m_a_t_ ; MAT PRINT mvar' , mvar' ... ; mvar': a matrix variable. &_ U_s_e_ As a statement or command to output the values of the elements of one or more matrices on the user"s terminal. R_e_m_a_r_k_s_ 1. The matrices must have been dimensioned before the statement is executed. 2. If a semicolon is used after a matrix variable in the argument list, the elements of that matrix will be output with c_o_m_p_a_c_t_ _s_p_a_c_i_n_g_, i.e. each element will be output starting from the next character position. (N_o_t_e_: A blank space is always printed after an element and a blank space is reserved for the plus sign, even though this sign is not printed). 3. If a comma or carriage return is used after a matrix variable in the argument list, the elements of that matrix will be output with z_o_n_e_ _s_p_a_c_i_n_g_, i.e. each element will be output starting from the leftmost position of a print zone. The width of the print zones can be set by means of the TAB command (see Ch. 9). 4. The values of the elements are output by rows in ascending order. If a row cannot be contained on a single print line, a carriage return and line feed are output and the row is continued on the next print line. \f T_E_x_a_m_p_l_e_ C_o_m_m_e_n_t_s_ 0010 TAB=10 0020 PAGE=72 0030 DIM MATA(3,2),MATB(2,3),ARRAY(10) 0040 FOR I=1 TO 3 0050 FOR J=1 TO 2 0060 LET MATA(I,J)=I*10+J 0070 LET MATB(J,I)=J*10+I 0080 NEXT J 0090 NEXT I 0100 PRINT "13'10'" 0110 MAT PRINT MATA,MATB 0120 PRINT "13'10'" 0130 MAT PRINT MATA;MATB; 0140 PRINT "13'10'" 0150 MAT PRINT MATA,MATB; 0155 TAB=5 0160 PRINT "13'10'" 0170 MAT PRINT ARRAY 0180 MAT ARRAY=CON 0190 PRINT "13'10'" 0200 MAT PRINT ARRAY; &_ T_ 11 12 Statement 110. 21 22 Zone spacing 31 32 is used (comma or carriage 11 12 13return as sepa- 21 22 23rator). 11 12 Statement 130. 21 22 Compact spacing 31 32 is used (semi- colon as sepa- 11 12 13rator). &_ 21 22 23 T_ 11 12 Statement 150. 21 22 31 32 11 12 13 &_ 21 22 23 T_ 0 0 0 0 0 0 0 0 0 0 Statement 170. &_ 1 1 1 1 1 1 1 1 1 1 Statement 200. \f T_ 6.12M_A_T_ _R_E_A_D_ _s_t_a_t_e_m_e_n_t_ F_o_r_m_a_t_ MAT READ mvar' ,mvar' ... mvar': a matrix variable. &_ U_s_e_ As a statement or command to read in numeric values from the list defined by one or more DATA statements (see Ch. 3) and to assign the values to the elements of one or more matrices. R_e_m_a_r_k_s_ 1. The matrices must have been dimensioned before the statement is executed. 2. Values are assigned to matrix elements by rows in ascending order. T_E_x_a_m_p_l_e_ 0010 DIM MATA(3,2),MATB(2,3) 0020 DATA 1,2,3,4,5,6,7,8,9 0030 MAT READ MATA 0040 PRINT "MATA :" 0050 MAT PRINT MATA 0060 RESTORE 0070 MAT READ MATB 0080 PRINT "13'10'MATB :" 0090 MAT PRINT MATB &_ T_MATA : 1 2 3 4 5 6 MATB : 1 2 3 4 5 6 &_ \f T_6.13M_A_T_ _T_R_N_ _s_t_a_t_e_m_e_n_t_ F_o_r_m_a_t_ MAT mvar1' = TRN(mvar2') mvar1, mvar2': matrix variables. &_ U_s_e_ As a statement or command to transpose a matrix and assign the resultant element values to another matrix. R_e_m_a_r_k_s_ 1. The matrices must have been dimensioned before the statement is executed. 2. A matrix is transposed by reversing the row and column assignments of the matrix elements, i.e. row number 1 in mvar2' becomes column number 1 in mvar1' and column number 1 in mvar2' becomes row number 1 in mvar1'. 3. If mvar2' is an n x m matrix, mvar1' will be an m x n matrix. 4. mvar1' and mvar2' must be two distinct matrices. T_6.14M_A_T_ _Z_E_R_ _s_t_a_t_e_m_e_n_t_ F_o_r_m_a_t_ MAT mvar' = ZER mvar': a matrix variable. &_ U_s_e_ As a statement or command to initialize a matrix such that all elements are set to zero. \f R_e_m_a_r_k_s_ 1. The matrix must have been dimensioned before the statement is executed. 2. All elements of mvar' are set to zero regardless of any previously assigned values. 3. The resulting matrix is often called a zero matrix. T_E_x_a_m_p_l_e_ 0010 DIM MATA(3,2) 0020 FOR I=1 TO 3 0030 FOR J=1 TO 2 0040 LET MATA(I,J)=I*10+J 0050 NEXT J 0060 NEXT I 0070 PRINT "MATA : " 0080 MAT PRINT MATA 0090 MAT MATA=ZER 0100 PRINT "13'10'NEW MATA :" 0110 MAT PRINT MATA MATA : 11 12 21 22 31 32 NEW MATA : 0 0 0 0 0 0 &_ F_\f 7L_O_G_I_C_A_L_ _D_I_S_C_S_ _A_N_D_ _R_E_L_A_T_E_D_ _C_O_M_M_A_N_D_S_ 7.1I_n_t_r_o_d_u_c_t_i_o_n_ An RC BASIC d_i_s_c_ _f_i_l_e_ (see the introduction to Chapter 8) comprises a number of consecutive blocks in a l_o_g_i_c_a_l_ _d_i_s_c_. Any system device may in principle contain logical discs, but in practice only such read/write devices as flexible discs and moving-head disc files are used for this purpose. (Note that here a moving-head disc file is considered a device). Logical discs are created in a device by means of a s_p_e_c_i_a_l_ f_o_r_m_a_t_t_i_n_g_ _p_r_o_g_r_a_m_ (described in the separate publication RC BASIC System Logical Disc Formatting Program Operating Guide). A device, i.e. a flexible disc or moving-head disc file, containing logical discs (LD"s) is structured as follows: device formatted with logical discs block 1 n LD LD LD subcatalogs main catalog The m_a_i_n_ _c_a_t_a_l_o_g_ describes the l_o_g_i_c_a_l_ _d_i_s_c_s_ contained in the device. Each main catalog entry has the following structure: \f T_ USERS Number of logical disc users. KEY Protection key of the logical disc. Not used. LENGTH Number of blocks allocated to the logical disc. NAME Name of the logical disc (1 to 8 &_ characters). The s_u_b_c_a_t_a_l_o_g_ in each logical disc describes the f_i_l_e_s_ contained in that logical disc. Each subcatalog entry has the following structure: T_ USERS Number of file users. Last block written in the file LAST BLOCK (sequential access)or number of records in the file (random access). Last byte written in the last block LAST BYTE (sequential access) or record length in bytes (random access). LENGTH Number of blocks allocated to the file. NAME Name of the file (1 to 8 characters). & A subcatalog always contains an entry in which NAME is <_F_R_E_E_ and LENGTH indicates the number of unused blocks in the logical T_disc, for example: LD user file free blocks <FREE entry number indicated subcatalog by LENGTH field &_ in <FREE entry entry describing user file \f A user can connect his terminal to o_n_e_ _l_o_g_i_c_a_l_ _d_i_s_c_ at a time. This is done by means of the CONNECT command, which gives him r_e_a_d_ _a_c_c_e_s_s_, possibly together with other users, to the files in that logical disc. If, however, the user correctly specifies the p_r_o_t_e_c_t_i_o_n_ _k_e_y_ of a logical disc in the CONNECT command, the logical disc is reserved for writing and he becomes its e_x_c_l_u_s_i_v_e_ _u_s_e_r_. He may now CREATE, DELETE, RENAME, or write to files in that logical disc, and no other user may connect his terminal to it. CONNECT and other commands related to the use of logical discs are described in the remaining sections of this chapter, while CREATE, DELETE, RENAME, and other statements related to the use of files are described in Chapter 8. T_7.2 C_O_N_N_E_C_T_ F_o_r_m_a_t_ CONNECT ldname' ,expr' ldname': a logical disc expressed as a string literal or by means of a variable. xpr': a numeric expression which evaluates to the protection key. U_s_e_ As a command or statement to connect the user"s terminal to a logical disc. R_e_m_a_r_k_s_ 1. If the user CONNECTs without specifying a protection key, he may only read from the logical disc ldname'. 2. If the user specifies a protection key and the value is correct, he becomes the exclusive user of ldname' and may now write to as well as read from ldname', whereas no other user may CONNECT his terminal to ldname'. 3. If a CONNECT command is given from a terminal which is already connected to a logical disc, a RELEASE command (see Sect. 7.7) will be automatically executed. \f T_E_x_a_m_p_l_e_s_ * CONNECT "DISC1" * CONNECT "SUBAREA",637 10 CONNECT LDNAME<,KEY &_ T_ 7.3C_O_P_Y_ F_o_r_m_a_t_ COPY "ldname':filename1'","filename2'" ldname': a logical disc. filename1': a file in ldname' to be copied. filename2': a file in the logical disc to which the terminal is connected. &_ U_s_e_ As a command to copy a file from any logical disc to a file in the logical disc to which the user"s terminal is connected. R_e_m_a_r_k_s_ 1. A file can be copied to a logical disc only if the user correctly specified the protection key of that logical disc in the CONNECT command (see Sect. 7.2). 2. The COPY command copies the file filename1' in the logical disc ldname' (provided that ldname' is not reserved for writing by another user) to a file, filename2', in the logical disc to which the terminal is connected. 3. If filename2' does not exist, a file will be created with the name filename2'. T_ E_x_a_m_p_l_e_ * COPY "LIB:PROG1","PROG2" &_ \f T_7.4I_N_I_T_ F_o_r_m_a_t_ INIT device' device': a device expressed as a string literal. &_ U_s_e_ As a command to initialize the main catalog in a device containing logical discs. R_e_m_a_r_k_s_ 1. The INIT command can only be given from the master terminal. 2. Users may CONNECT their terminals to logical discs in device' as soon as the INIT command has been executed. 3. When the INIT command is executed, the UNIT ID is output on the master terminal. (For a description of the UNIT ID, see the NEW function in the separate publication RC BASIC System Logical Disc Formatting Program Operating Guide.) T_E_x_a_m_p_l_e_ C_o_m_m_e_n_t_ * INIT "<FD0" FORMATTING EXAMPLE 77.02.09 UNIT ID. &_ T_7.5 L_O_C_K_ F_o_r_m_a_t_ LOCK device' device': a device expressed as a string literal. &_ U_s_e_ As a command to lock a device, when changing discs or closing down the system, so that no user can CONNECT his terminal to a logical disc in that device. \f R_e_m_a_r_k_s_ 1. The LOCK command can only be given from the master terminal. 2. When the LOCK command has been executed, no user can CONNECT his terminal to a logical disc in device'. Connected users may continue to access device' until they RELEASE their terminals (see Sect. 7.7). 3. When the LOCK command is executed, a 4-digit number is output on the master terminal indicating the number of users whose terminals are still connected to logical discs in device'. 4. IMPORTANT: The device, i.e. the flexible or moving-head disc that contains the logical discs, must n_e_v_e_r_ be removed from its drive unit until it has been LOCKed and the number of users is 0. T_E_x_a_m_p_l_e_ C_o_m_m_e_n_t_ * LOCK "<FD0" Do not remove the disc from drive 0001 unit 0, as the number of device users is 1. Ask the user who is still connected to RELEASE his terminal and then LOCK the device once more before removing the disc. &_ T_ 7.6 L_O_O_K_U_P_ F_o_r_m_a_t_ LOOKUP "<LPT" U_s_e_ As a command to return a listing of the files (names and attributes) in the logical disc, if any, to which the user"s terminal is connected at the moment. \f R_e_m_a_r_k_s_ 1. The first column in the listing contains the name of each file. 2. The second column indicates whether the file is a sequential access file (S) or a random access file (R). 3. The third column gives the number of the last block written in the file (sequential access) or the number of records in the file (random access). 4. The fourth column gives the number of the last byte written in the last block (sequential access file) or the record length in bytes (random access file). 5. The fifth column indicates the number of blocks allocated to the file. The number of bytes per block will depend on the device that contains the logical disc. If the device is a flexible disc, there are 128 bytes per block. If the device is a moving-head disc file, there are 512 bytes per block. 6. The listing will always include the file <FREE, where the fifth column indicates the number of unused blocks in the logical disc. 7. If the LOOKUP "<LPT" form of the command is used, the listing will be output with headings on the line printer. 8. The listing will be interrupted, if the user presses the ESCape key. T_E_x_a_m_p_l_e_ C_o_m_m_e_n_t_ * LOOKUP SORT.SR S 00006 00077 00006 SORT.SV S 00005 00080 00010 The length in u_s_e_d_ _b_y_t_e_s_ INDATA S 00002 00040 00002 of the file SORT.SV is LAES.SV S 00002 00008 00002 (5-1) x 128 + 80. DATA.BN S 00001 00061 00030 <FREE 65479 00000 00444 &_ \f T_7.7 R_E_L_E_A_S_E_ F_o_r_m_a_t_ RELEASE U_s_e_ As a command or statement to disconnect the user"s terminal from the logical disc, if any, to which it is connected. R_e_m_a_r_k_s_ 1. If the terminal is not connected to a logical disc, the RELEASE command will have no effect. 2. If a CONNECT command (see Sect. 7.2) is given from a terminal which is already connected to a logical disc, a RELEASE command will be automatically executed. 3. If any of the files in the logical disc are open, the error message 0115: OPEN FILES ON LD will be output and the terminal will not be disconnected. E_x_a_m_p_l_e_ * RELEASE 100 RELEASE &_ T_7.8 U_S_E_R_S_ F_o_r_m_a_t_ USERS device' device': a device expressed as a string literal. &_ U_s_e_ As a command to return the number of users whose terminals are connected to any logical disc in a device at the moment. \f R_e_m_a_r_k_s_ 1. The USERS command is intended as an aid in closing down the system (see the LOCK command, Sect. 7.5). 2. If the number of device users is 0, device' can be LOCKed and the disc containing device' can be removed from its drive unit. T_E_x_a_m_p_l_e_ C_o_m_m_e_n_t_ * USERS "<FD0" See the LOCK command. 0001 &_ \f 8F_I_L_E_S_ _A_N_D_ _R_E_L_A_T_E_D_ _S_T_A_T_E_M_E_N_T_S_ 8.1 I_n_t_r_o_d_u_c_t_i_o_n_ The present section describes the file concept itself, while statements related to the use of files are described in the remaining sections of this chapter. For the catalog structure in RC BASIC, i.e. l_o_g_i_c_a_l_ _d_i_s_c_s_, see the introduction to Chapter 7. 8.1.1 D_i_s_c_ _f_i_l_e_s_ _a_n_d_ _d_e_v_i_c_e_s_ Several of the statements described in the following sections have filename' as an argument. A filename may be the name of a disc file or the name of a device. In many respects, a disc file and a device are one and the same, and most of the explanations in this chapter apply to both. Devices, however, cannot be CREATEd, DELETEd, or RENAMEd. A device, moreover, is used either for input or for output, whereas a disc file can be used for both. 8.1.2 S_t_a_n_d_a_r_d_ _d_e_v_i_c_e_s_ _a_n_d_ _r_e_s_e_r_v_e_d_ _n_a_m_e_s_ The system devices which can be used in RC BASIC are listed below. The names in parentheses should be used when the device is referenced as a file. Line printer (<LPT) Paper tape punch (<PTP) Paper tape reader (<PTR) Card reader (<CDR or <MCDR) Flexible disc (<FD0, <FD1) The card reader has two names, as it can be used in two different ways. The flexible disc is referenced directly when the INIT, LOCK, and USERS commands are executed (see Ch. 7); otherwise, discs are only referenced indirectly, by a d_i_s_c_ filename. \f b_T_8.1.3 B_l_o_c_k_ _s_i_z_e_s_e An RC BASIC disc file comprises a number of consecutive blocks in a logical disc. Each disc file is described separately by an entry in the subcatalog of the logical disc (see Ch. 7). The size of the blocks in the file depends on the type of device &_used to contain the logical disc and, hence, the file. If the device is a flexible disc, the block size is 128 bytes. If the device is a moving-head disc file, the block size is 512 bytes. One byte (8 bits) corresponds to one character, so that a string containing 10 characters will occupy 10 bytes, whereas numeric data will occupy 4 bytes per item. b_8.1.4 F_i_l_e_n_a_m_e_s_ _a_n_d_ _f_i_l_e_ _s_i_z_e_s_e A disc file can be CREATEd with a name and a size. A filename may contain from 1 to 8 characters. All characters are legal, but the first character in a d_i_s_c_ filename must not be a dollar sign (<). The size of a file is the number of blocks allocated to the file, expressed as a number greater than or equal to zero. A disc file can also be DELETEd or RENAMEd. b_8.1.5 H_o_w_ _f_i_l_e_s_ _a_r_e_ _u_s_e_d_e Files can be used for many purposes. The user can SAVE/LOAD/ CHAIN/RUN or LIST/ENTER a program to or from a file (see Chs. 3 and 9). A file can also be used for data. In order to read data from or write data to a file, the user must first OPEN the file. The data can be in binary or ASCII (character) format. When the file is OPENed, the user must specify one of the following modes: Mode 0 for binary input from or binary output to a random access file (READ FILE or WRITE FILE statement). Mode 1 for binary input from a sequential access file (READ FILE statement). Mode 2 for binary output to a sequential access file, when data is to be appended to previously written data (WRITE FILE statement). Mode 3 for binary output to a sequential access file (WRITE FILE statement). \f Mode 4 for binary input (only) from a random access file (READ FILE statement). Mode 9 for ASCII input from a sequential access file (INPUT FILE statement). Mode 11 for ASCII output to a sequential access file (PRINT FILE statement). When the user no longer needs to access a file, he should CLOSE it. b_8.1.6 R_a_n_d_o_m_ _a_c_c_e_s_s_ _f_i_l_e_s_e The data in a random access file is organized in individual records, which can be accessed directly. If a random access file is to be used for both reading and writing, it must be OPENed in mode 0. This can be done only if the user correctly specified the protection key of the logical disc in the CONNECT command (see Ch. 7). If a random access file is to be used for reading only, it can be OPENed in mode 4. In this case, the user does not have to specify the protection key of the logical disc in the CONNECT command. b_8.1.7 S_e_q_u_e_n_t_i_a_l_ _a_c_c_e_s_s_ _f_i_l_e_s_e The data in a sequential access file can only be accessed in a sequential manner. When a sequential access file is OPENed, the system positions to the beginning of the file and the data is read or written starting from there. If, however, a sequential access file is OPENed in mode 2, the system will position after the last item written to the file, so that data can be appended to previously written data. Sequential access files can be OPENed in mode 1, 2, 3, 9, or 11. If a file is OPENed for reading (writing), it must be CLOSEd and OPENed again before it can be used for writing (reading). b_8.1.8 W_r_i_t_e_ _p_r_o_t_e_c_t_i_o_n_e A d_i_s_c_ file can be accessed only if the user has CONNECTed his terminal to the logical disc that contains the file (see Ch. 7). If a disc file is to be CREATEd, DELETEd, RENAMEd, or written to, the user must correctly specify the protection key of the logical disc in the CONNECT command. The remaining sections of this chapter contain separate descriptions of the CREATE, DELETE, and RENAME statements,\f statements related to file input/output, and the EOF(X) function. For the use of these statements as keyboard commands, see Appendix C. CONNECT and other commands related to the use of logical discs are described in Chapter 7. T_ 8.2 C_L_O_S_E_ _F_I_L_E_ F_o_r_m_a_t_ CLOSE FILE(file') file': a numeric expression which evaluates to a user file number that was previously associated with a filename in an OPEN FILE statement (see Sect. 8.11). &_ U_s_e_ As a statement or command to dissociate a filename and a user file number so that the file no longer can be referenced. R_e_m_a_r_k_s_ 1. The CLOSE FILE statement may be used to close a file so that it can be re-opened by an OPEN FILE statement with a new mode argument. 2. The CLOSE form of the statement closes all open files. T_E_x_a_m_p_l_e_s_ 100 CLOSE FILE(1) 200 CLOSE FILE(X+3) 300 CLOSE &_ \f T_8.3 C_R_E_A_T_E_ F_o_r_m_a_t_ &_CREATE filename',size',recl' filename': the name (1 to 8 characters) of the disc file to be created, expressed as a string literal or by means of a variable. size': a numeric expression specifying either the length of the file in blocks (sequential access file) or the number of records in the file (random access file). recl': a numeric expression specifying the record length in bytes. recl' should be specified if, and only if, the file is to be used as a random access file. U_s_e_ As a statement or command to create a file in the logical disc to which the user"s terminal is connected. R_e_m_a_r_k_s_ 1. A file can be created only if the user correctly specified the protection key of the logical disc in the CONNECT command (see Ch. 7). 2. For files created in a logical disc contained in a flexible disc, the block size is 128 bytes. For files created in a logical disc contained in a moving-head disc file, the block size is 512 bytes. 3. If the user does not know how large a file will be, he can specify size' equal to 0 when he creates it. This will re- serve the remainder of the logical disc to which the terminal is connected. The file can then be used for output, and when it is CLOSEd (see Sect. 8.2), the system will truncate it. size' must be positive, if the file is a random access file. 4. No more than one file created with size' equal to 0 can be used, unless the files in question have already been CLOSEd once.\f 5. If recl' is specified, the file can (only) be used as a random access file. (See also the OPEN FILE, READ FILE, and WRITE FILE statements.) recl' must be positive and less than or equal to the block size of the device (i.e. flexible disc or moving-head disc file) containing the logical disc in which the file is created. 6. A random access file will be organized such that each physical block in the device will contain an integral number of records. T_E_x_a_m_p_l_e_ _1_ C_o_m_m_e_n_t_ _(_1_)_ 120 LET NAME<="PROC1.SR" 130 CREATE NAME<,17 140 CREATE "PROC2.SR",0 CREATE used as a statement. &_ T_E_x_a_m_p_l_e_ _2_ C_o_m_m_e_n_t_ _(_2_)_ * CREATE "DATAFILE",15,52 CREATE used as a command. &_ T_8.4 D_E_L_E_T_E_ F_o_r_m_a_t_ DELETE filename' filename': the name of the disc file to be deleted, expressed as a string literal or by means of a variable. &_ U_s_e_ As a statement or command to delete a file in the logical disc to which the user"s terminal is connected. R_e_m_a_r_k_s_ 1. A file can be deleted only if the user correctly specified the protection key of the logical disc in the CONNECT command (see Ch. 7). 2. A file can be deleted only if all other files in the logical disc are closed.\f 3. N_o_t_e_: The deletion of a file may require some time. The figure below shows a logical disc containing four files. FILE 1 was created first and FILE 4 was created last. If, for example, FILE 2 is deleted, then FILE 3 and FILE 4 will be moved so that there will be no gaps in the logical disc. If the user wishes to delete more than one file, he should always delete starting with the file most recently created, as this will minimize the time required to move the files. T_ FILE 1 FILE 2 FILE 3 FILE 4 T_8.5 E_O_F_(_X_)_ _f_u_n_c_t_i_o_n_ F_o_r_m_a_t_ EOF(file') file': a numeric expression which evaluates to the number of a user file opened for reading (i.e. in mode 1 or 9). &_ U_s_e_ As a function to detect the end of data when transferring data from a file. R_e_m_a_r_k_s_ 1. The EOF(X) function returns an integer indicating whether or not the last READ FILE or INPUT FILE statement included an end of file delimiter. 2. If an end of file condition was detected, the function returns a value of +1; otherwise, a value of 0 is returned. E_x_a_m_p_l_e_ See the examples under READ FILE (Sect. 8.14).\f T_8.6 I_N_P_U_T_ _F_I_L_E_ F_o_r_m_a_t_ var'var' INPUT FILE(file') , svar' ,svar' ... &_ file': a numeric expression which evaluates to the &_ number of a user file opened in mode 9. var, svar': a list of one or more numeric or string variables which are assigned values read from a sequential access file. U_s_e_ As a statement or command to read data in ASCII format from a s_e_q_u_e_n_t_i_a_l_ _a_c_c_e_s_s_ _f_i_l_e_ for the variables in the argument list. R_e_m_a_r_k_s_ 1. Each variable in the argument list must be of the same type (numeric or string) as the corresponding data item in the data file. 2. The data file must be formatted such that commas or carriage returns are used to separate numeric data items and quotation marks or carriage returns are used to separate string data items. 3. If the length of a string in the data file is greater than the length of the corresponding string variable in the argument list, the last part of the string will be skipped. T_E_x_a_m_p_l_e_ 40 OPEN FILE(1,9)"INFILE" . . 70 INPUT FILE(1)Z,Y,X,A<,B< &_ \f T_8.7 M_A_T_ _I_N_P_U_T_ _F_I_L_E_ F_o_r_m_a_t_ &_MAT INPUT FILE(file') , mvar' ,mvar' ... file': a numeric expression which evaluates to the number of a user file opened in mode 9. mvar': a matrix variable. U_s_e_ As a statement or command to read data in ASCII format from a s_e_q_u_e_n_t_i_a_l_ _a_c_c_e_s_s_ _f_i_l_e_ for the matrix variables in the argument list. R_e_m_a_r_k_s_ 1. The matrices must have been dimensioned before the statement is executed (see Ch. 6). 2. Values are assigned to the matrix elements by rows in ascendingorder. 3. The data file must be formatted such that commas or carriage returns are used to separate the data items. T_8.8 M_A_T_ _P_R_I_N_T_ _F_I_L_E_ F_o_r_m_a_t_ &_MAT PRINT FILE(file') , mvar' ,mvar' ... file': a numeric expression which evaluates to the number of a user file opened in mode 11. mvar': a matrix variable. U_s_e_ As a statement or command to write matrix data in ASCII format to a s_e_q_u_e_n_t_i_a_l_ _a_c_c_e_s_s_ _f_i_l_e_._\f R_e_m_a_r_k_s_ See the MAT PRINT statement (Ch. 6). T_8.9 M_A_T_ _R_E_A_D_ _F_I_L_E_ F_o_r_m_a_t_ MAT READ FILE(file',recno') , mvar' ,mvar' ... &_ file': a numeric expression which evaluates to the number of a user file opened in mode 0, 1, or 4. recno': a numeric expression which evaluates to the number (' 0) of a record to be read from a random access file. mvar': a matrix variable. U_s_e_ As a statement or command to read data in binary format from a sequential access file or record of a random access file for the matrix variables in the argument list. R_e_m_a_r_k_s_ 1. The matrices must have been dimensioned before the statement is executed (see Ch. 6). 2. Values are assigned to the matrix elements by rows in ascending order. 3. If the attempt is made to read a record (from a random access file) which is longer than the record length specified for the file, the error message 0117: RECORD TOO LONG will appear. F_ \f T_ 8.10 M_A_T_ _W_R_I_T_E_ _F_I_L_E_ F_o_r_m_a_t_ MAT WRITE FILE(file',recno') , mvar' ,mvar' ... file': a numeric expression which evaluates to the number of a user file opened in mode 0 or 3. recno': a numeric expression which evaluates to the number (' 0) of a record to be written to a random access file. mvar': a matrix variable. U_s_e_ As a statement or command to write matrix data in binary format to a sequential access file or record of a random access file. R_e_m_a_r_k_s_ 1. The matrices must have been dimensioned before the statement is executed (see Ch. 6). 2. The values of the matrix elements are output by rows in ascending order. 3. If the attempt is made to write a record (to a random access file) which is longer than the record length specified for the file, the error message 0117: RECORD TOO LONG will appear. T_8.11 O_P_E_N_ _F_I_L_E_ F_o_r_m_a_t_ OPEN FILE(file',mode') , filename' file': a numeric expression which evaluates to a number in the range 0 to 7 (the number of a user file). This number is associated with filename' and used whenever the file is referenced in other file input/output &_ statements. \f mode': a numeric expression which evaluates to a number and specifies how the file is to be used (see Remarks). filename': a disc file or a device expressed as a string literal or by means of a variable. U_s_e_ As a statement or command to associate a disc file or a device with a user file number and to specify how the file is to be used. R_e_m_a_r_k_s_ 1. One of the following modes must be specified: Mode 0 for binary input from or binary output to a random access file (READ FILE or WRITE FILE statement). Mode 1 for binary input from a sequential access file (READ FILE statement). Mode 2 for binary output to a sequential access file, when data is to be appended to previously written data (WRITE FILE statement) Mode 3 for binary output to a sequential access file (WRITE FILE statement). Mode 4 for binary input (only) from a random access file (READ FILE statement). Mode 9 for ASCII input from a sequential access file (INPUT FILE statement). Mode 11 for ASCII output to a sequential access file (PRINT FILE or PRINT FILE USING statement). 2. A disc file must have been CREATEd (see Sect. 8.3) before it can be opened. 3. Random access files can only be opened in mode 0 or 4. 4. When a sequential access file is opened in mode 1, 3, 9, or 11, the system will position to the beginning of the file. When a sequential access file is opened in mode 2, the system\f will position after the last item written to the file, so that data can be appended to previously written data. T_ E_x_a_m_p_l_e_ _1_ C_o_m_m_e_n_t_ _(_1_)_ 10 NAME<="DATA1" 20 OPEN FILE(0,0)NAME< 30 OPEN FILE(1,11)"DATA2" OPEN FILE used as a statement. &_ T_E_x_a_m_p_l_e_ _2_ C_o_m_m_e_n_t_ _(_2_)_ * OPEN FILE(6,9)"<PTR" OPEN FILE used as a command. &_ T_8.12 P_R_I_N_T_ _F_I_L_E_ F_o_r_m_a_t_ expr' , expr' , PRINT FILE(file') , slit' ; slit' ... ; svar' svar' &_ file': a numeric expression which evaluates to the number of a user file opened in mode 11. expr, slit, svar':a list of one or more numeric or rela- tional expressions, string literals, or string variables the values of which are written to a sequential access file. U_s_e_ As a statement or command to write data in ASCII format to a s_e_q_u_e_n_t_i_a_l_ _a_c_c_e_s_s_ _f_i_l_e_. R_e_m_a_r_k_s_ 1. The PRINT FILE statement is used to output data to an ASCII device, such as a line printer, or to a disc file for subsequent off-line printing. 2. Each item in the argument list must be separated from the next item by a comma or a semicolon. The argument list itself must be terminated by a carriage return. \f 3. Output formatting is the same as that described under the PRINT statement (see Ch. 3). T_E_x_a_m_p_l_e_ 10 OPEN FILE(2,11)"DATAFILE" 20 PRINT FILE(2)"RESULTS:" 30 PRINT FILE(2)X 2,X 3,X 4 &_ T_8.13 P_R_I_N_T_ _F_I_L_E_ _U_S_I_N_G_ F_o_r_m_a_t_ expr' expr' PRINT FILE(file') , USING format', slit' , slit' ..., svar' ; svar' ; &_ file': a numeric expression which evaluates to the number of a user file opened in mode 11. format': a string literal or string variable that specifies the format (see Remarks) forout- putting the items in the argument list. expr': a numeric or relational expression. slit': a string literal. svar': a string variable. U_s_e_ As a statement to output the values of items in the argument list using a specified format. R_e_m_a_r_k_s_ See the PRINT FILE statement (Sect. 8.12) and the PRINT USING statement (Ch. 3). \f T_8.14 R_E_A_D_ _F_I_L_E_ F_o_r_m_a_t_ var'var' READ FILE(file',recno'), svar' , svar' ... &_ file': a numeric expression which evaluates to the number of a user file opened in mode 0, 1, or 4. recno': a numeric expression which evaluates to the number (' 0) of a record to be read from a random access file. var, svar':a list of one or more numeric or string variables which are assigned values read sequentially from a randomly accessed record or sequentially from a file. U_s_e_ As a statement or command to read data in binary format from a sequential access file or record of a random access file for the variables in the argument list. R_e_m_a_r_k_s_ 1. Each variable in the argument list must be of the same type (numeric or string) as the corresponding data item in the data file. 2. One can, however, read string data items into numeric variables. (For each numeric variable, four bytes will be read.) This facility can be used to copy a file (see Ex. 2). N_o_t_e_: If the total number of bytes in the file is not divisible by 4, the error message 0107: END OF FILE may appear. 3. The EOF(X) function (see Sect. 8.5) can be used to detect an end of file condition in the file (see Examples). 4. If the attempt is made to read a record (from a random access file) which is longer than the record length specified for the file, the error message 0117: RECORD TOO LONG will appear. \f E_x_a_m_p_l_e_ _1_ C_o_m_m_e_n_t_ _(_1_)_ 0010 OPEN FILE(0,1)"DATA" This program uses the file 0020 DIM TEXT<(25) DATA, which is created in 0030 READ FILE(0)TEXT< the program shown as an 0040 PRINT TEXT< example of the WRITE FILE 0050 READ FILE(0)A statement (see Sect. 8.16). 0060 WHILE NOT EOF(0) DO 0070 PRINT A; 0080 READ FILE(0)A 0090 ENDWHILE 0100 CLOSE THIS IS A DATA FILE 1 2 3 4 5 6 7 8 9 10 &_ T_E_x_a_m_p_l_e_ _2_ C_o_m_m_e_n_t_ _(_2_)_ 0010 CREATE "DATA1",5 This program copies the file 0020 OPEN FILE(0,1)"DATA" DATA to a new file, DATA1. 0030 OPEN FILE(1,3)"DATA1" 0035 READ FILE(0)A 0040 WHILE NOT EOF(0) DO 0050 WRITE FILE(1)A 0060 READ FILE(0)A 0070 ENDWHILE 0080 CLOSE &_ T_8.15 R_E_N_A_M_E_ F_o_r_m_a_t_ &_RENAME filename1',filename2' &_ filename1': the name of the disc file to be renamed. filename2': the new name of filename1'. Both arguments are expressed as string literals or by means of variables. U_s_e_ As a statement or command to rename a file in the logical disc to which the user"s terminal is connected.\f R_e_m_a_r_k_s_ A file can be renamed only if the user correctly specified the protection key of the logical disc in the CONNECT command (see Ch. 7). T_E_x_a_m_p_l_e_ _1_ C_o_m_m_e_n_t_ _(_1_)_ 20 RENAME NAME<,"PROC3.SR" RENAME used as a statement. &_ T_E_x_a_m_p_l_e_ _2_ C_o_m_m_e_n_t_ _(_2_)_ * RENAME "DATAFILE","FILE-3" RENAME used as a command. &_ T_8.16 W_R_I_T_E_ _F_I_L_E_ F_o_r_m_a_t_ expr' expr' WRITE FILE(file',recno') , slit' , slit' ... svar' svar' &_ file': a numeric expression which evaluates to the number of a user file opened in mode 0 or 3. recno': a numeric expression which evaluates to the number (' 0) of a record to be written to a random access file. expr, slit, svar': a list of one or more numeric or relational expressions, string literals, or string variables the values of which are written sequentially to a randomly accessed record or sequentially to a file. U_s_e_ As a statement or command to write data in binary format to a sequential access file or record of a random access file. \f R_e_m_a_r_k_s_ 1. A_ _n_u_m_e_r_i_c_ _d_a_t_a_ _i_t_e_m_ _i_s_ _w_r_i_t_t_e_n_ _a_s_ _f_o_u_r_ _b_y_t_e_s_._ _A_ _s_t_r_i_n_g_ _d_a_t_a_ i_t_e_m_ _i_s_ _w_r_i_t_t_e_n_ _a_s_ _a_ _n_u_m_b_e_r_ _o_f_ _b_y_t_e_s_ _c_o_r_r_e_s_p_o_n_d_i_n_g_ _t_o_ _t_h_e_ l_e_n_g_t_h_ _o_f_ _t_h_e_ _s_t_r_i_n_g_._ _T_h_e_ _s_t_r_i_n_g_ _i_s_ _t_e_r_m_i_n_a_t_e_d_ _b_y_ _a_ _N_U_L_ c_h_a_r_a_c_t_e_r_ _(_s_e_e_ _A_p_p_._ _D_)_._ 2. The result of a relational expression is written as one numeric item, the value of which is 1, if the expression is true (e.g. 3 ' 0), or 0, if the expression is false (e.g. 0 ' 3). 3. If the attempt is made to write a record (to a random access file) which is longer than the record length specified for the file, the error message 0117: RECORD TOO LONG will appear. T_E_x_a_m_p_l_e_ 0010 CREATE "DATA",5 0020 OPEN FILE(1,3)"DATA" 0030 WRITE FILE(1)"THIS IS A DATA FILE" 0040 FOR I=1 TO 10 0050 WRITE FILE(1)I 0060 NEXT I &_0070 CLOSE FILE(1) F_\f 9S_Y_S_T_E_M_ _C_O_M_M_A_N_D_S_ 9.1I_n_t_r_o_d_u_c_t_i_o_n_ The statements and functions that are used for writing programs in RC BASIC are described in preceding chapters. RC BASIC, how- ever, may also be used interactively to perform such functions as: Maintenance of RC BASIC source programs Desk calculator functions Dynamic program debugging File input/output The present chapter describes commands for program development and execution. Commands derived from RC BASIC statements, for desk calculator functions, program debugging, and file input/output, are described in Appendix C. Commands used in conjunction with batch mode are described in Appendix B. 9.2C_o_m_m_a_n_d_ _t_o_ _d_e_l_e_t_e_ _p_r_o_g_r_a_m_ _s_t_a_t_e_m_e_n_t_s_ F_o_r_m_a_t_ line n1',line n2' line n1' line n1', ,line n2' line n1': the first statement to be deleted. line n2': the last statement to be deleted. U_s_e_ As a command to delete one or more statements in a program. \f R_e_m_a_r_k_s_ The variations of the command have the following effects: line n1',line n2' Deletes all lines with line n1' = line number = line n2'. line n1' Deletes only the single line with line number = line n1'. line n1', Deletes all lines with line n1' = line number. ,line n2' Deletes all lines with line number = line n2'. T_E_x_a_m_p_l_e_ C_o_m_m_e_n_t_ * LIST 0010 PRINT 0020 PRINT 0030 PRINT 0040 PRINT 0050 PRINT 0060 PRINT 0070 PRINT 0080 PRINT 0090 PRINT 0100 PRINT * 20,40 Lines 20-40 (= 20, 30, 40) * LIST are deleted. 0010 PRINT 0050 PRINT 0060 PRINT 0070 PRINT 0080 PRINT 0090 PRINT 0100 PRINT &_ \f T_* 60 Line 60 is deleted. * LIST 0010 PRINT 0050 PRINT 0070 PRINT 0080 PRINT 0090 PRINT &_0100 PRINT T_ * 90, Lines 90-9999 (= 90, 100) * LIST are deleted. 0010 PRINT 0050 PRINT 0070 PRINT 0080 PRINT * ,70 Lines 1-70 (= 10, 50, 70) * LIST are deleted. 0080 PRINT * &_ T_ 9.3A_U_T_O_ F_o_r_m_a_t_ line n1' STEP AUTO , line n2' STEP line n1' , line n2' line n1': the initial line number in a program. line n2': the increment between line numbers in a program. &_ U_s_e_ As a command to provide automatic line numbers in a program, thereby making it easier to enter programs from a terminal. \f R_e_m_a_r_k_s_ 1. The terminal is released from AUTO mode by pressing the ESCape key. 2. AUTO can be used as a command for a file that contains statements; the statements can then be read into the current program storage area by means of the ENTER command (see Sect. 9.7). 3. The variations of the command have the following effects: AUTO Assigns numbers to a program starting with the default line number 0010 and with a default increment of 10 between line numbers. AUTO line n1' Assigns numbers to a program starting with line number line n1' and incrementing by line n1' between line numbers. STEP AUTO , line n2' Assigns numbers to a program starting with the default line number 0010 and incrementing by line n2' between line numbers. STEP AUTO line n1' , line n2'Assigns numbers to a program starting with line number line n1' and incrementing by line n2' between line numbers. \f T_E_x_a_m_p_l_e_ C_o_m_m_e_n_t_ * AUTO 0010 LET I=1 0020 An empty line is ignored. 0020 LET TOOLONGNAME=5 ERR : 0011 NAME TOO LONG 0020 LET Y=X If an error occurs, the line is 0030 repeated. &_* T_9.4B_A_T_C_H_/_B_A_T_C_H_ _"_<_L_P_T_"_ F_o_r_m_a_t_ BATCH "<LPT" & U_s_e_ As a command to place the terminal in batch mode and cause the system to start reading cards from the mark-sense card reader. R_e_m_a_r_k_s_ 1. Output from the jobs executed, i.e. listings, output from PRINT statements (see Ch. 3), and error messages, will appear on the terminal or, if the BATCH "<LPT" form of the command is used, on the line printer. 2. For a complete description of the batch mode of operation, see Appendix B. T_9.5B_Y_E_ F_o_r_m_a_t_ BYE &_ U_s_e_ As a command or statement to log the terminal off the system. \f R_e_m_a_r_k_s_ Accounting information is output prior to the log-off. T_E_x_a_m_p_l_e_ C_o_m_m_e_n_t_ * BYE TERMINAL 00 LOGGED OFF TIME USED: 00.00.11 77.03.17, 09.06.45: TERMINAL 00 IDLE The now idle terminal can be re-activated by pres- sing the ESCape key. &_ T_9.6C_O_N_/_C_O_N_L_ F_o_r_m_a_t_ CON CONL &_ U_s_e_ As a command to continue execution of the current program after the execution of a STOP statement (see Ch. 3) in the program, after the ESCape key has been pressed, or after an error has occurred. R_e_m_a_r_k_s_ 1. Output from PRINT statements (see Ch. 3) will appear on the terminal or, if the CONL form of the command is used, on the line printer. 2. The CON/CONL command is equivalent to a RUN/RUNL line no.' command (see Sect. 9.15) where line no.' is equivalent to the statement immediately following the statement at which the program stopped. 3. If a run-time error is encountered in the program, the user may correct the error and then give a CON/CONL command to begin execution from the statement where the error occurred. \f T_E_x_a_m_p_l_e_C_o_m_m_e_n_t_ * LIST 0010 DEF FNF(X)=2 X+2*X+2 0020 DATA 5,6,0 0030 PRINT " X ";"FNF(X)" 0040 READ X 0050 WHILE X'0 DO 0060 PRINT X;FNF(X) 0070 READ X 0080 ENDWHILE 0090 PRINT "13'10'SUPPLY NEW DATA (LINE 20)" 0100 STOP 0110 RESTORE 0020 0120 GOTO 0030 &_ T_* RUN X FNF(X) 5 44 6 78 SUPPLY NEW DATA (LINE 20) STOP AT 0100 * 20 DATA 1,2,3,4,5,6,7,8,9,0 New data is * CON supplied to the X FNF(X) program before 1 6execution con- 2 10 tinues. 3 16 4 26 5 44 6 78 7 144 8 274 9 532 SUPPLY NEW DATA (LINE 20) STOP AT 0100 &_* \f T_9.7E_N_T_E_R_ F_o_r_m_a_t_ ENTER filename' filename': a disc file or a device expressed as a string literal or by means of a variable. &_ U_s_e_ As a command or statement to merge the statement lines from the disc file or the device specified by filename' into the current program storage area. R_e_m_a_r_k_s_ 1. If an error is detected during the reading of a statement, the statement will be echoed on the terminal and an error message output (see App. A). 2. Only those statements in the current program that have line numbers equivalent to the line numbers of the ENTERed statements will be deleted. If, therefore, the current program (or a part of it) is not to be used, a NEW command (see Sect. 9.11) should be given prior to the ENTER command. T_E_x_a_m_p_l_e_ _1_ C_o_m_m_e_n_t_ _(_1_)_ * NEW The user"s program storage area is * ENTER "<PTR" cleared. The program on paper tape * ENTER "PROG.SR" and the program in file PROG.SR * LIST "<PTP" are merged. The resulting program is listed on paper tape. &_ \f T_E_x_a_m_p_l_e_ _2_ C_o_m_m_e_n_t_ _(_2_)_ * LIST The current program and the 0010 PRINT program on paper tape are merged. 0020 PRINT 0030 PRINT 0040 PRINT * ENTER "<PTR" * LIST 0010 PRINT I 0015 PRINT I 0020 PRINT 0025 PRINT I 0030 PRINT 0040 PRINT I 0050 PRINT I * &_ T_9.8E_O_J_ Used only in batch mode. For description, see Appendix B. &_ T_9.9L_I_S_T_ F_o_r_m_a_t_ line n1' TO LIST , line n2' filename' TO line n1' , line n2' line n1': the first statement to be listed. line n2': the last statement to be listed. filename': a disc file or a device expressed as a string literal. &_ \f U_s_e_ As a command to output part or all of the currently loaded program in ASCII to the disc file or the device specified by filename' or, if filename' is not specified, to the terminal. R_e_m_a_r_k_s_ 1. The variations of the command have the following effects: LIST Lists the entire program starting from the lowest numbered statement. LIST line n1' Lists only the single statement at line number line n1'. TO LIST , line n2' Lists from the lowest numbered statement through line number line n2'. TO LIST line n1' , line n2' Lists from line number line n1' through line number line n2'. 2. When the filename' argument is included, the LIST command causes the specified lines to be written to the disc file or the device named filename'. 3. A file of statements created by the LIST command can be read back into the current program storage area by means of the ENTER command (see Sect. 9.7). 4. If the statements are listed to a disc file, a new file named filename' is created in the logical disc to which the terminal is connected (see Ch. 8). If filename' already exists, the statements are written to this file. If filename' is too small, the error message 0107: END OF FILE will be output when the end of medium condition is detected. 5. If no program is currently loaded, the LIST command will not cause an error message, but the output of a prompt (*) on the\f terminal. T_E_x_a_m_p_l_e_s_ C_o_m_m_e_n_t_s_ * LIST The entire program will be listed on the terminal. * LIST "<LPT" The entire program will be listed on the line printer. * LIST 100,500 "PROG1.SR" Lines 100 through 500 will be listed to the file PROG1.SR. * LIST 50 Line 50 will be listed on the terminal. &_ T_9.10L_O_A_D_ F_o_r_m_a_t_ LOAD filename' filename': a disc file or a device expressed as a string literal. &_ U_s_e_ As a command to load a previously SAVEd program in binary format from the disc file or the device specified by filename' into the user"s program storage area. R_e_m_a_r_k_s_ 1. The LOAD command executes an implicit NEW command (see Sect. 9.11), thereby clearing any currently loaded program from core memory. 2. When a previously SAVEd program (see Sect. 9.16) has been LOADed, it can be LISTed (see Sect. 9.9), modified, or RUN (see Sect. 9.15). \f T_E_x_a_m_p_l_e_s_ C_o_m_m_e_n_t_s_ * LOAD "<PTR" filename' is a device (paper tape reader). * LOAD "PROG1.SV" filename' is a disc file. &_ T_ 9.11N_E_W_ F_o_r_m_a_t_ NEW &_ U_s_e_ As a command or statement to clear all currently stored program statements and variables from core memory and to close any open files (see Ch. 8). R_e_m_a_r_k_s_ 1. The user should clear his program storage area by means of a NEW command(or statement) before entering a new program so that statement lines from previous programs will not be executed along with the new program. 2. A NEW statement may appear as the last executable statement in a program, thereby clearing the program from core memory after program execution. 3. When used with an ON-ERR or ON-ESC statement (see Ch. 3), the NEW statement can be used to prevent unauthorized access to a program. \f T_E_x_a_m_p_l_e_ C_o_m_m_e_n_t_ * LIST 0010 LET NUMBER=5; I=0 0020 WHILE I=NUMBER DO 0030 PRINT NUMBER; 0040 LET NUMBER=NUMBER+1; I=I+2 0050 ENDWHILE 0060 NEW NEW used as a statement. * RUN 5 6 7 8 9 10 END AT 0060 * LIST This LIST command shows that the program has been cleared. &_* T_ 9.12P_A_G_E_ F_o_r_m_a_t_ PAGE=expr' expr': a numeric expression in the range 0 = expr' = 132. &_ U_s_e_ As a command or statement to set the right-hand margin of the terminal. R_e_m_a_r_k_s_ 1. The default page width (length of a print line) is 72 columns. 2. If the page width is set to zero, the system will regard the length of the print line as infinite and consequently not out- put an automatic carriage return and line feed in PRINTstate- ments (see Ch. 3). The user may find this advantageous when using the X-Y addressing facilities of a video terminal.\f T_E_x_a_m_p_l_e_ C_o_m_m_e_n_t_ * LIST 0010 FOR I=1 TO 10 0020 PRINT I; 0030 NEXT I * PAGE=30 * RUN 1 2 3 4 5 6 7 8 9 The system outputs a carriage 10 return and line feed when the END page width (length of the AT 0030 print line) is exceeded. * PAGE=20 &_ T_ * RUN 1 2 3 4 5 6 7 8 9 10 END AT 0030 &_* T_ 9.13P_U_N_C_H_ F_o_r_m_a_t_ line n1' TO PUNCH , line n2' TO line n1' , line n2' line n1': the first statement to be punched. line n2': the last statement to be punched. &_ U_s_e_ As a command to output part or all of the currently loaded program in ASCII to the terminal punch (when present). \f R_e_m_a_r_k_s_ 1. A PUNCHed listing is preceded by a leader and followed by a trailer, each containing 120 NUL characters (see App. D). 2. As the PUNCH command does not turn the terminal punch on and off, the following procedure is required: a. Type the desired PUNCH command, press the RETURN key, and immediately press the ON button on the punch. b. A NUL leader will be punched, followed by a listing of the desired lines of the current program, followed by a NUL trailer. c. When punching is completed, press the OFF button on the punch. 3. When part or all of a program is PUNCHed, a listing is output on theterminal simultaneously. 4. The variations of the command have the following effects: PUNCH Punches the entire program starting from the lowest numbered statement. PUNCH line n1' Punches only the single statement at line number line n1'. TO PUNCH , line n2' Punches from the lowest numbered statement through line numberline n2'. TO PUNCH line n1' , line n2' Punches from line number line n1' through line number line n2'. T_ E_x_a_m_p_l_e_ C_o_m_m_e_n_t_ * PUNCH 200 TO 500 Lines 200 through 500 will &_ be punched. \f T_ 9.14R_E_N_U_M_B_E_R_ F_o_r_m_a_t_ line n1' STEP RENUMBER , line n2' STEP line n1' , line n2' line n1': the initial line number in the current program. line n2': the increment between line numbers in the current program. &_ U_s_e_ As a command to renumber the statements in the current program. R_e_m_a_r_k_s_ 1. The variations of the command have the following effects: RENUMBER Renumbers the current program starting with the default line number 0010 and with a default incre- ment of 10 between line numbers. RENUMBER line n1' Renumbers the current program starting with line number line n1' and incrementing by line n1' between line numbers. STEP RENUMBER , line n2' Renumbers the current program starting with the default line number 0010and incrementing by line n2' between line numbers. STEP RENUMBER line n1' , line n2'Renumbers the current\f program starting with line number line n1' and incrementing by line n2' between line numbers. 2. Line numbers are limited to four digits. If a RENUMBER command causes a line number to be greater than 9999, the command will be re-executed as: RENUMBER 1 STEP 1 3. The RENUMBER command will also modify the line numbers in GOSUB, GOTO, ON-GOTO/GOSUB, and RESTORE statements (see Ch. 3) to agree with the new line numbers assigned to the current program. 4. References to non-existent lines are changed to 0000. \f T_E_x_a_m_p_l_e_ C_o_m_m_e_n_t_ * LIST 0001 LET NUMBER=5; I=0 0002 REPEAT 0004 PRINT NUMBER*I; 0007 LET I=I+1 0010 UNTIL I=NUMBER * RENUMBER The default values ofline n1',line n2' are 10,10. * LIST 0010 LET NUMBER=5; I=0 0020 REPEAT 0030 PRINT NUMBER*I; 0040 LET I=I+1 0050 UNTIL I=NUMBER * RENUMBER ,5 *LIST 0010 LET NUMBER=5; I=0 0015 REPEAT 0020 PRINT NUMBER*I; 0025 LET I=I+1 0030 UNTIL I=NUMBER &_* T_ 9.15R_U_N_/_R_U_N_L_ F_o_r_m_a_t_ RUN line no.' RUNL filename' line no.': the line number in the current program from which execution is to begin. filename': a disc file or a device expressed as a string literal. &_ \f U_s_e_ As a command to execute the current program, either from the lowest numbered statement or from the line number specified by line no.', or to load and execute a previously SAVEd program as the current program. R_e_m_a_r_k_s_ 1. Output from PRINT statements (see Ch. 3) will appear on the terminal or, if the RUNL form of the command is used, on the line printer. 2. The variations of the command have the following effects: RUN/RUNL Clears all variables; undimensions all arrays and string variables; executes an implicit RESTORE command (see Ch. 3); resets the random number generator; runsthe c_u_r_r_e_n_t_ _p_r_o_g_r_a_m_ from the lowest numbered statement. RUN/RUNL line no.' Retains all existing information, e.g. the values of variables and dimensioning, resulting from a previous execution of the current program; runs the c_u_r_r_e_n_t_ _p_r_o_g_r_a_m_ from the line number specified by line no.'. This variation of the command allows program execution to be resumed retaining the current values of all variables and para- meters. It may be used after the execution of a STOP statement (see Ch. 3) in the program, after the ESCape key has been pressed, or after an error has occurred, and will incorporate any changes made in the program after the program was stopped. RUN/RUNL filename' LOADs a previously SAVEd program from the disc file or the device specified by filename' (see Sect.\f 9.10), thereby clearing any currently loaded program from core memory; runs the previously S_A_V_E_d_ p_r_o_g_r_a_m_ from the lowest numbered statement. T_ E_x_a_m_p_l_e_s_ C_o_m_m_e_n_t_s_ * RUN Runs the current program from the lowest numbered statement. * RUNL 50 Runs the current program starting at line 50; output will appear on the line printer. * RUN "<PTR" Loads a program from paper tape and runs it from the lowest numbered statement. * RUNL "PROG.SV" Loads a program from the file PROG.SV and runs it from the lowest numbered statement; output will appear on the line printer. &_ T_ 9.16S_A_V_E_ F_o_r_m_a_t_ SAVE filename' filename': a disc file or a device expressed as a string literal or by means of a variable. &_ U_s_e_ As a command or statement to write the currently loaded program, including the current values of all variables and parameters, in binary format to the disc file or the device specified by filename'. R_e_m_a_r_k_s_ 1. If the program is written to a disc file, a new file named filename' is created in the logical disc to which the terminal is connected (see Ch. 8). If filename' already \f exists, the program is written to this file. If an end of file condition is detected during the SAVEing operation, the error message 0107: END OF FILE will be output. 2. In the interests of conserving space on a SAVE device, one should add the statement 1 STOP to the program and RUN it before it is SAVEd. This will cause the core memory area which is used for variables during program execution to be truncated. The 1 STOP statement may then be deleted, before the program is SAVEd (see Ex. 2). 3. A SAVEd program can be LOADed, CHAINed, or RUN (see, respectively, Sect. 9.10, Ch. 3, and Sect. 9.15). 4. SAVEing, rather than LISTing (see Sect. 9.9), is a more efficient way to store large programs. The size of a program in binary format can be determined by means of the SIZE command (see Sect. 9.18). If the indicated size is less than the number of ASCII characters in the program, which may be ascertained by looking at the program, then SAVE should be used rather than LIST. T_E_x_a_m_p_l_e_ _1_ C_o_m_m_e_n_t_ _(_1_)_ * SAVE "<PTP" SAVE commands. * SAVE "PROG1.SV" 200 SAVE "<PTP" SAVE statements. 200 SAVE "PROG1.SV" &_ \f T_E_x_a_m_p_l_e_ _2_ Co_m_m_e_n_t_ _(_2_)_ * LIST Shows how one can save space 0010 DIM A(100) when SAVEing a program. 0020 FOR I=1 TO 100 0030 LET A(I)=I 0040 NEXT I * SIZE 00422 BYTES USED Size before execution. 04578 BYTES LEFT * RUN END AT 0040 * SIZE 00836 BYTES USED Size after execution. 04164 BYTES LEFT * 1 STOP 1 STOP statement inserted. * RUN STOP AT 0001 * SIZE 00428 BYTES USED Size after second 04572 BYTES LEFT execution. * 1 1 STOP statement deleted. * SIZE 00422 BYTES USED 04578 BYTES LEFT * SAVE "<PTP" Program SAVEd on paper * tape. &_ T_ 9.17S_C_R_A_T_C_H_ Used only in batch mode. For description, see Appendix B. &_ \f T_ 9.18S_I_Z_E_ F_o_r_m_a_t_ SIZE &_ U_s_e_ As a command to return the number of bytes used by the current program and the numbers of bytes left. R_e_m_a_r_k_s_ Even though no program is present, the SIZE command will indicate that approximately 350 bytes have been used, as these are always required to administer the execution of running programs. T_E_x_a_m_p_l_e_ * SIZE &_00836 BYTES USED 04164 BYTES LEFT T_ 9.19T_A_B_ F_o_r_m_a_t_ TAB=expr' expr': a numeric expression in the range &_ 1 = expr' = page width specified by the PAGE command. U_s_e_ As a command or statement to set the zone spacing between the print elements output by PRINT statements (see Ch. 3). R_e_m_a_r_k_s_ 1. The default zone spacing (width of a print zone) is 14 columns. This spacing allows five print zones per 72 character print line. \f 2. Since the maximum range of zone spacing depends on the PAGE command setting (see Sect. 9.12), it is wise to specify the page width (length of the print line) first and then specify the setting of the tabulation zones. T_E_x_a_m_p_l_e_ * LIST 0010 FOR I=1 TO 10 0020 PRINT I, 0030 NEXT I * PAGE=30 * TAB=10 * RUN 1 2 3 4 5 6 7 8 9 10 END AT 0030 * TAB=5 * RUN 1 2 3 4 5 6 7 8 9 10 END AT 0030 &_* T_ 9.20T_I_M_E_ Used only in batch mode. For description, see Appendix B. &_ \f A E_R_R_O_R_ _M_E_S_S_A_G_E_S_ A.1 I_n_t_r_o_d_u_c_t_i_o_n_ The errors that can occur during use of the RC BASIC system fall into three categories. 1) E_r_r_o_r_s_ _d_e_t_e_c_t_e_d_ _d_u_r_i_n_g_ _p_r_o_g_r_a_m_ _e_n_t_r_y_ _o_r_ _c_o_m_m_a_n_d_ _e_x_e_c_u_t_i_o_n_ If an error is detected when an RC BASIC statement is entered or when a command is executed, an error message will be output in the following form: ERR : xxxx' text' xxxx': a decimal error code less than 0100. text': a brief description of the error. If an error is detected while a program is being read from a file, RC BASIC will output the erroneous statement followed by the above error message on the current output device. 2) E_r_r_o_r_s_ _d_e_t_e_c_t_e_d_ _d_u_r_i_n_g_ _p_r_o_g_r_a_m_ _e_x_e_c_u_t_i_o_n_ If an error is detected during the execution of a program, an error message will be output in the following form: AT yyyy' : ERR : xxxx' text' yyyy': the line number of the erroneous statement. xxxx': a decimal error code less than 0100. text': a brief description of the error. 3) E_r_r_o_r_s_ _d_e_t_e_c_t_e_d_ _d_u_r_i_n_g_ _f_i_l_e_ _o_p_e_r_a_t_i_o_n_s_ If an error is detected during an input/output operation, an error message will be output in a form similar to that of the messages output for errors of the first or second category; however, the text IOERR will replace the text ERR and the\f decimal error code, xxxx', will be greater than or equal to 0100. E_r_r_o_r_ _m_e_s_s_a_g_e_s_,_ i.e. messages for errors detected during program entry or command execution as well as those detected during program execution, are listed and explained in numerical order in Section A.2. I_/_O_ _e_r_r_o_r_ _m_e_s_s_a_g_e_s_,_ i.e. messages for errors detected during file operations, are listed and explained in numerical order in Section A.3. T_A.2 E_r_r_o_r_ _m_e_s_s_a_g_e_s_ 0000: ILLEGAL COMBINATION OF RELATIONAL OPERATORS &_ The legal combinations are: , =, =, =, '=, =', ', and '. 0001: CHARACTER UNKNOWN A character not used in RC BASIC was input. This message may appear as the result of a transmission error. 0002: SYNTAX ERROR The structure of an RC BASIC statement is incorrect. 0003: NO CORE No core memory is available for additional terminals at the moment. 0004: ILLEGAL KEY The protection key specified in a CONNECT command must be in the interval 0,65535. 0005: ILLEGAL STATEMENT NUMBER A statement number must be in the inverval 1,9999. An illegal statement number may occur as the result of an overflow when the AUTO command is used. \f 0006: TOO MANY NAMES Too many names (variables and procedures) have been declared. The maximum number allowed is 93. The number of names can be reduced by means of the following commands: * LIST filename' * NEW * ENTER filename' 0007: COMMAND NOT EXECUTABLE FROM DEVICE This error will occur, for example, if an ENTER file contains a command or if the attempt was made to execute BYE (and certain other commands) in batch mode. 0008: ILLEGAL PAGE/TAB COMMAND The following rule applies to the two commands PAGE= expr1' and TAB=expr2': 0 = expr1' = 132 and 1 = expr2' = expr1' 0009: LINE TOO LONG A program line (when translated to internal form) is too long. 0010: TIME LIMIT EXCEEDED The time limit specified for a batch job has been exceeded. 0011: NAME TOO LONG A name (variable or procedure name) may not exceed a length of 8 characters. 0012: ILLEGAL COMMAND Attempt to use an RC BASIC statement as a command, but the statement is meaningful only within the context of a program. \f 0013: LINE NUMBER DOES NOT EXIST A line number that was referenced, e.g. by LIST or RUN, does not exist in the program. 0014: PROGRAM TOO LARGE Available core memory is insufficient for the program (statements). Program size may be reduced by deleting REM statements and other nonessentials. 0015: NO MORE DATA FOR READ The last element in the last DATA statement has been read, but the system attempted to execute READ once more. 0016: ARITHMETIC ERROR Either division by 0 or overflow. 0017: UNDEFINED VARIABLE Attempt to use a variable in an expression, but the variable has not been defined, e.g. by LET or DIM. 0018: GOSUB-RETURN DEPTH Nested subroutines (GOSUB statements) or procedures (EXEC statements) may not exceed a depth of 7 levels. 0019: RETURN WITHOUT GOSUB A RETURN or ENDPROC statement was encountered without the previous execution of a GOSUB or EXEC statement. 0020: FOR-NEXT DEPTH Nested FOR-NEXT loops may not exceed a depth of 7 levels. 0021: FOR WITHOUT NEXT Every FOR statement must have a corresponding NEXT statement.\f 0022: NEXT WITHOUT FOR A NEXT statement was encountered without the previous execution of the corresponding FOR statement. 0023: NO MORE ROOM FOR VARIABLES No more core memory is available to assign space for variables. Program size may be reduced by deleting REM statements and other nonessentials. 0024: ILLEGAL USE OF The character may be used in a string literal only in connection with the indication of a decimal value to represent a non-printing or special character. Thus the ASCII character Carriage Return, for example, is represented as 13'. If the character itself is to appear as a character in a text string, it must be represented as 60'. 0025: NOT IMPLEMENTED This message will appear, for example, if the user attempts to execute a BATCH command and the system has no card reader. 0026: ONLY ALLOWED FROM MASTER TERMINAL INIT, LOCK, and certain other commands can only be given from the master terminal. 0027: ILLEGAL FILE NUMBER A user file number must be in the interval 0,7. 0028: ORIGINAL DIMENSIONING EXCEEDED Attempt to dimension an array previously dimensioned to a smaller number of elements. 0029: EXPRESSION TOO COMPLEX An expression contains too many parentheses.\f 0030: ILLEGAL FILE LENGTH The specified length of a sequential access file in blocks or the specified number of records in a random access file must be greater than or equal to 0. 0031: SUBSCRIPT ERROR A subscript of a dimensioned variable exceeds the upper bound of the dimension for the array or is less than 1. 0032: UNDEFINED FUNCTION A user function, i.e. FNa(d), has not been defined in a DEF statement. 0033: Not used. 0034: ILLEGAL FUNCTION ARGUMENT A function containing an illegal argument was called. 0035: FORMAT ERROR IN PRINT USING The format of a PRINT USING statement is incorrect. 0036: PRINT ELEMENT TOO LONG A print element contains more characters than the print line can hold. (The length of the print line can be set by means of the PAGE command.) 0037: DETERMINANT IS ZERO A matrix cannot be inverted if its determinant is equal to zero. 0038: VARIABLE NOT DIMENSIONED A variable which has not been declared was used in the form name'(subscript'). \f 0039: SAME MATRIX ON BOTH SIDES OF EQUAL SIGN Certain matrix operations, such as multiplication, cannot be performed if the same matrix appears on both sides of the equal sign. 0040: DIMENSIONAL ERROR IN MATRIX OPERATION a) In matrix addition or subtraction, the two matrices on the right-hand side of the equal sign must have the same dimensions. b) In matrix multiplication, the rules set forth in Chapter 6, Section 5, must be respected. c) The total number of elements in the matrix on the left-hand side of the equal sign must not be less than the number of elements in the matrix which is the result of the matrix operation on the right- hand side of the equal sign. 0041: MATRIX NOT SQUARE Only square matrices can be inverted. 0042: FILE ALREADY OPEN Attempt to open a user file (numbered from 0 to 7) which is already open. 0043: Not used. 0044: FILE NOT OPENED Attempt to reference a user file which has not been opened. 0045: PROC WITHOUT ENDPROC A procedure (which is introduced by a PROC statement) does not end with an ENDPROC statement. 0046: PROCEDURE DOES NOT EXIST A procedure which was called by means of an EXEC statement does not exist in the program.\f 0047: Not used. 0048: NOT A SAVE FILE A LOAD command was given specifying the name of a file that does not contain a SAVEd program. 0049: Not used. 0050: IF-ENDIF DEPTH Nested IF-ENDIF constructions may not exceed a depth of 7 levels. 0051: ELSE WITHOUT IF An ELSE statement was encountered without the previous execution of an IF statement. 0052: IF/ELSE WITHOUT ENDIF An IF/ELSE statement must have a corresponding ENDIF statement. 0053: WHILE WITHOUT ENDWHILE Every WHILE statement must have a corresponding ENDWHILE statement. 0054: WHILE-ENDWHILE DEPTH Nested WHILE-ENDWHILE loops may not exceed a depth of 7 levels. 0055: ENDWHILE WITHOUT WHILE An ENDWHILE statement was encountered without the previous execution of the corresponding WHILE statement. 0056: ENDIF WITHOUT IF An ENDIF statement was encountered without the previous execution of an IF statement.\f 0057: REPEAT-UNTIL DEPTH Nested REPEAT-UNTIL loops may not exceed a depth of 7 levels. 0058: UNTIL WITHOUT REPEAT An UNTIL statement was encountered without the previous execution of the corresponding REPEAT statement. 0059: CASE WITHOUT WHEN, CASE ERROR A CASE expr' OF statement must either be matched by at least one WHEN expr' statement or, if no match is found between the expression in the CASE statement and an expression in a WHEN statement, be followed immediately by one or more statements. 0060: CASE WITHOUT ENDCASE A CASE statement must have a corresponding ENDCASE statement. 0061: ENDCASE WITHOUT CASE An ENDCASE statement was encountered without the previous execution of a CASE statement. 0062: WHEN WITHOUT CASE A WHEN statement was encountered without the previous execution of a CASE statement. 0063: CASE DEPTH This message will appear when there is a programming error in the user"s program, viz. a loop that causes CASE expr' OF, but not ENDCASE, to be executed. 0064: NOT A DIMENSIONED VARIABLE A simple variable has been used in the form name' (subscript').\f 0065: ILLEGAL TYPE An expression is of the wrong type. 0066: TYPE CONFLICT A variable is not of the same type as that with which the user attempted to equate it. Error codes 0067 through 0076 are all accompanied by the text SYSTEM ERROR. If a SYSTEM ERROR message appears, please fill out an RC Error Report, stating the error code. Error codes 0077 through 0099 are not used. T_ A.3 I_/_O_ _e_r_r_o_r_ _m_e_s_s_a_g_e_s_ I/O errors, i.e. errors detected during file operations, are divided into two groups. &_ T_1) I_/_O_ _e_r_r_o_r_ _m_e_s_s_a_g_e_s_ _0_1_0_0_ _t_h_r_o_u_g_h_ _0_1_1_9_,_ _1_3_5_,_ _a_n_d_ _1_3_6_ This group comprises errors recognized by RC BASIC. &_ T_2) I_/_O_ _e_r_r_o_r_ _m_e_s_s_a_g_e_s_ _0_1_2_0_ _t_h_r_o_u_g_h_ _0_1_3_4_ This group comprises errors recognized by the MUS or DOMUS operating system. &_ The two groups are described in Sections A.3.1 and A.3.2, respectively. T_b_A.3.1 I_/_O_ _e_r_r_o_r_ _m_e_s_s_a_g_e_s_ _0_1_0_0_ _t_h_r_o_u_g_h_ _0_1_1_9_,_ _1_3_5_,_ _a_n_d_ _1_3_6_e 0100: FILE UNKNOWN Attempt to reference a non-existent file. &_ 0101: FILE OPENED INCORRECTLY A file was opened in the wrong mode, e.g. the line printer cannot be opened in a read mode. \f 0102: FILE IN USE Attempt to reference a file already in use. 0103: ILLEGAL FILENAME A d_i_s_c_ filename begins with the illegal character <. 0104: NOT CONNECTED TO LD Attempt to reference a disc file, but the user"s terminal was not connected to a logical disc. 0105: ILLEGAL COMMAND TO LD Attempt to create, delete, rename, copy, or write to a disc file, but the user did not specify the protection key of the logical disc in the CONNECT command. 0106: ILLEGAL FILE OPERATION Attempt to reference an unopened file. 0107: END OF FILE Attempt to read or write outside a file. 0108: FILE TOO LONG The number of free blocks in the logical disc is not sufficient for creation of a file of the specified size. 0109: FILE EXISTS Attempt to create a file that already exists in the logical disc. 0110: LD UNKNOWN The user attempted to connect his terminal to a non-existent logical disc. 0111: DEVICE UNKNOWN Attempt to access a non-existent device.\f 0112: DEVICE INITIALIZED The main catalog in the specified device has already been intialized. 0113: LD RESERVED The user attempted to connect his terminal to a logical disc which another user has reserved for writing. 0114: WRONG KEY The user specified the wrong protection key for a logical disc. 0115: OPEN FILES ON LD The user attempted to release his terminal from a logical disc, but one or more files were open. 0116: LD RESERVED ON DEVICE The main catalog in the device on the specified drive unit cannot be initialized because the device was not locked properly when the disc containing the device was last removed from the drive unit. This device must now be r_e_s_e_t_ _u_s_i_n_g_ _t_h_e_ _s_p_e_c_i_a_l_ f_o_r_m_a_t_t_i_n_g_ _p_r_o_g_r_a_m_ (see the separate publication RC BASIC System Logical Disc Formatting Program Operating Guide). 0117: RECORD TOO LONG Attempt to read or write a record (from or to a random access file) which was longer than the record length specified for the file. 0118: NO MORE FILE DESCRIPTORS Every system configuration has a fixed number of file descriptors, corresponding to the total number of disc files which can be open at one time. One or more disc files must therefore be closed before the file in question can be opened.\f 0119: ILLEGAL RECORDNO The number of a record to be read from or written to a random access file is larger than the total number of records in the file or less than 1. 0135: SYSTEM ERROR Please fill out an RC Error Report, stating the error code. 0136: LD IN USE ON DEVICE Attempt to initialize a device while a logical disc in the device was in use. The logical disc in question must be released before the device can be initialized. T_b_A.3.2 I_/_O_ _e_r_r_o_r_ _m_e_s_s_a_g_e_s_ _0_1_2_0_ _t_h_r_o_u_g_h_ _0_1_3_4_e Messages for I/O errors0120 through 0134 do not include a &_descriptive text, as the meanings of the error codes, which are explained below, depend on the device causing the error. None of the devices makes use of all of the error codes. T_L_i_n_e_ _p_r_i_n_t_e_r_ _e_r_r_o_r_s_ 0120: Unit disconnected. &_ 0121: Unit off line. 0126: Illegal operation. Unit reserved by another process. 0128: Paper fault. For Charaband printer: Overwriting of a line has occurred more than 8 times. 0129: Unit not ready. 0130: Error in paper movement control character. For Charaband printer: Parity error during the loading or printing of a line. 0131: Paper low. End of paper. 0133: Driver process not loaded. 0134: Paper runaway.\f T_P_a_p_e_r_ _t_a_p_e_ _p_u_n_c_h_ _e_r_r_o_r_s_ 0126: Illegal operation. Unit reserved by another process. &_ 0128: Record format conflict. 0131: End of tape. 0133: Driver process not loaded. 0134: Unit not ready. T_P_a_p_e_r_ _t_a_p_e_ _r_e_a_d_e_r_ _e_r_r_o_r_s_ 0123: Defective tape. Wrong number of channels. &_ 0126: Illegal operation. Unit reserved by another process. 0128: Record format conflict. 0130: Parity error. 0131: End of tape. Reader empty. 0133: Driver process not loaded. T_C_a_r_d_ _r_e_a_d_e_r_ _e_r_r_o_r_s_ 0121: Unit not ready. (Check the indicators.) &_ 0122: Feed error. 0126: Illegal operation. Unit reserved by another process. 0128: Block size error. Record format conflict. 0129: Data channel overrun. 0130: Parity error. Data error. 0131: Hopper empty. 0133: Driver process not loaded. 0134: Hardware trouble.\f T_F_l_e_x_i_b_l_e_ _d_i_s_c_ _d_r_i_v_e_ _e_r_r_o_r_s_ 0120: Unit disconnected. &_ 0121: Unit off line. 0123: Address field parity error. 0124: Disc write-protected. 0125: Output: Disc write-protected. 0126: Illegal operation. Unit reserved by another process. 0127: End of file. 0128: Block size error. Record format conflict. 0130: Parity error. 0131: End of medium. 0132: Position error. 0133: Driver process not loaded. 0134: Time out. T_M_o_v_i_n_g_-_h_e_a_d_ _d_i_s_c_ _d_r_i_v_e_ _e_r_r_o_r_s_ 0120: Unit disconnected. &_ 0121: Unit off line. 0126: Illegal operation. Unit reserved by another process. 0128: Block size error. Record format conflict. 0129: Data channel overrun. 0130: Parity error. 0131: End of medium. 0132: Position error. Seek failure.\f 0133: Driver process not loaded. 0134: Time out. T_I_n_c_r_e_m_e_n_t_a_l_ _p_l_o_t_t_e_r_ _e_r_r_o_r_s_ 0126: Illegal operation. Unit reserved by another process. &_ 0128: Block size error. Record format conflict. 0133: Driver process not loaded. 0134: Time out. T_C_a_r_d_ _r_e_a_d_e_r_ _p_u_n_c_h_ _e_r_r_o_r_s_ 0121: Unit not ready: Off line, stopped, disconnected, or in error. (Check the indicators.) &_ 0122: Feed error. 0126: Illegal operation. Unit reserved by another process. 0127: Secondary hopper empty. 0128: Block size error. Record format conflict. 0129: Data channel overrun. 0130: Parity error. Data error. 0131: Primary hopper empty. 0133: Driver process not loaded. 0134: Hardware trouble. T_M_a_g_n_e_t_i_c_ _t_a_p_e_ _u_n_i_t_ _e_r_r_o_r_s_ 0121: Unit off line. &_ 0122: Unit rewinding. 0123: Input: Byte limit conflict. Noise record.\f 0125: Output: Write ring not mounted. 0126: Illegal operation. Unit reserved by another process. 0127: Input: End of file mark. 0128: Block size error. Record format conflict. 0129: Data channel overrun. 0130: Parity error. 0131: Output: End of tape sensed. 0132: Position error. 0133: Driver process not loaded. 0134: Blank tape. Position error. Wrong density. T_C_a_s_s_e_t_t_e_ _t_a_p_e_ _u_n_i_t_ _e_r_r_o_r_s_ 0121: Unit off line or disconnected. Cassette released. &_ 0122: Unit not ready. Rewinding or position to beginning of tape. 0126: Illegal operation. Unit reserved by another process. 0127: Input: End of file mark. 0128: Block size error. Record format conflict. 0129: Buffer overflow. Data late. 0130: Parity or block check error. 0131: Output: End of tape sensed. 0132: Position error. 0133: Driver process not loaded. 0134: Time out. Output: Write-enable plugs removed.\f BB_A_T_C_H_ _M_O_D_E_ _A_N_D_ _P_R_O_G_R_A_M_M_I_N_G_ _O_N_ _M_A_R_K_-_S_E_N_S_E_ _C_A_R_D_S_ B.1B_a_t_c_h_ _j_o_b_s_ The batch mode of operation permits the user to enter and run one or more complete jobs from the mark-sense card reader (when present). RC BASIC source programs, written on mark-sense cards, are placed in the reader; when the BATCH/BATCH "<LPT" command is given from a terminal, the system starts reading the cards. The cards, t_h_e_ _c_o_n_t_e_n_t_s_ _o_f_ _w_h_i_c_h_ _a_r_e_ _i_n_t_e_r_p_r_e_t_e_d_ _e_x_a_c_t_l_y_ _a_s_ _i_f_ t_h_e_y_ _h_a_d_ _b_e_e_n_ _e_n_t_e_r_e_d_ _f_r_o_m_ _a_ _t_e_r_m_i_n_a_l_, can contain all of the RC BASIC statements and commands with few exceptions. A stack of cards for batch entry is typically divided into several jobs. Each job is initiated by a card containing a SCRATCH command (see Sect. B.5) and terminated by a card containing the EOJ command (see Sect. B.4). Between the SCRATCH command and the EOJ command there can be an RC BASIC source program on cards, each of which contains one statement, and following the program there can be one or more cards containing one command each, e.g. LIST and RUN. A RUN command may be followed by cards containing data for the program, which is read by means of INPUT statements (see Ch. 3) in the program. Such data cards are marked only in the FORMULA section of the card (see Sect. B.2). The figure below shows a card stack containing two batch jobs. \f T___ _________________________________________ _ _ _ _E_O_J_ _____________________________________ ____R_U_N_ _____________________________________ ____L_I_S_T_ ____________________________________ _______________________________p_r_o_g_r_a_m_ _c_a_r_d_s_ ___5_ _R_E_M_ _P_R_O_G_R_A_M_ _F_I_N_D_S_ _1_0_0_ _P_R_I_M_E_ _N_U_M_B_E_R_S_ ___ ___S_C_R_A_T_C_H_ _ _W_I_L_K_I_N_S_ _M_I_C_A_W_B_E_R_ _ _7_ _C_ __________ ___E_O_J_ _____________________________________ __________________________________d_a_t_a_ _c_a_r_d_s_ ___4_,_ _-_5_,_ _7_ ________________________________ ___R_U_N__ ____________________________________ ____L_I_S_T_ ____________________________________ ________________________________p_r_o_g_r_a_m_ _c_a_r_d_s_ ____1_0_ _R_E_M_ _P_R_O_G_R_A_M_ _F_O_R_ _2_N_D_ _D_E_G_R_E_E_ _E_Q_U_A_T_I_O_N_ ___ SCRATCH EMMA MICAWBER 7 C &_ ________________________________________________\f T_ B.2M_a_r_k_-_s_e_n_s_e_ _c_a_r_d_s_ The cards used for batch jobs are 37 column mark-sense programming cards. The RC BASIC mark-sense card looks like this: S_T_A_T_E_M_E_N_T_ _2_ F_O_R_M_U_L_A_ S_T_A_T_E_M_E_N_T_ _1_ S_T_A_T_E_M_E_N_T_ _N_U_M_B_E_R_ &_ \f T_ The mark-sense card is not punched; instead, information is written on it simply by marking one or more fields with a_ _s_o_f_t_ p_e_n_c_i_l_, e.g. No. 2. As may be seen from the figure on the preceding page, the RC BASIC mark-sense card is divided into four sections, from left to right: STATEMENT NUMBER section (columns 1-4) STATEMENT 1 section (columns 5-7) FORMULA section (columns 8-36) STATEMENT 2 section (column 37) &_ b_ B.2.1 S_T_A_T_E_M_E_N_T_ _N_U_M_B_E_R_e_ The STATEMENT NUMBER section (columns 1-4) is used for statement numbers. An RC BASIC program consists of statements, each of which begins with a statement number in the range 1 to 9999. A statement number is written by making at the most one mark in each of the columns 1 to 4. \f T_ E_x_a_m_p_l_e_s_ 10 : 1987: &_ T_ b_ B.2.2 S_T_A_T_E_M_E_N_T_ _1_ e_ The STATEMENT 1 section (columns 5-7) permits the user to write one or more RC BASIC words simply by marking one field for each word. &_ None of the three columns in this section may contain more than one mark. Some of the RC BASIC words are commands, e.g. LIST or RUN, and may not be preceded by a line number. Other words, e.g. ENTER or CLOSE, may be used with or without a line number, i.e. either as statements or commands. Still other words can be used only with a line number, e.g. PROC or ENDPROC. Whether a word must have, may have, or may not have a line number can be seen from the statement and command descriptions found in Chapters 3, 6, 7, 8, and 9. \f T_ E_x_a_m_p_l_e_s_ 10 OPEN FILE : LIST : &_ T_b_B.2.3S_T_A_T_E_M_E_N_T_ _2_e_ The STATEMENT 2 section (column 37) is used as follows: &_ The C_O_N_T_ _f_i_e_l_d_ should be marked whenever an RC BASIC statement fills more than one card. The system will then continue reading from the next card, s_k_i_p_p_i_n_g_ _t_h_e_ _S_T_A_T_E_M_E_N_T_ _N_U_M_B_E_R_ _s_e_c_t_i_o_n_ _o_f_ t_h_a_t_ _c_a_r_d_._ A statement can theoreticallybe continued on any number of cards. When the E_O_J_ _f_i_e_l_d_ is marked, the system will terminate the job. No other fields on the card should be marked. The T_H_E_N_,_ _O_F_,_ _a_n_d_ _D_O_ _f_i_e_l_d_s_ are used in conjunction with the words IF, CASE, and WHILE, respectively. E_N_D_P_R_O_C_,_ _R_E_T_U_R_N_,_ _S_T_O_P_,_ _E_N_D_,_ _a_n_d_ _R_A_N_D_O_M_I_Z_E_ are normal RC BASIC statements. \f T_ The STATEMENT 2 section looks like this: T_ b_ B.2.4 F_O_R_M_U_L_A_ e_ &_ The FORMULA section (columns 8-36) is used for that part of an RC BASIC statement which cannot be written in the STATEMENT 1 and STATEMENT 2 sections. Each of the columns 8 to 36 contains twelve vertical fields. The first field from the top is field number 12, the second field from the top is field number 11, and the remaining fields are numbered 0 to 9. T_ B.2.4.1 E_v_e_n_ _n_u_m_b_e_r_e_d_ _c_o_l_u_m_n_s_._ Columns with even numbers (i.e. 8, 10, &_ ..., 36) are used for the letters A to Z, the digits 0 to 9, and the following special characters: = (field 12) , (field 11) . (field 9) T_B.2.4.2O_d_d_ _n_u_m_b_e_r_e_d_ _c_o_l_u_m_n_s_._ Columns with odd numbers (i.e. 9, 11, ..., 35) are used for the digits 0 to 9 and the following characters:\f ( (field 12) ) (field 11) + - * (field 1) / ; (field 2) ' # (field 3) " : < (field 4) ? % Æ (field 5) & ! SP (field 6) @ Ø Å (field 7) CR " (field 8) = , . (field 9) N_o_t_e_: SP is the space character. CR outputs positioning to the leftmost character position on the print line a_n_d_ _a_ _l_i_n_e_ _f_e_e_d_ (see App. D). @, Ø, and Å are letters of the Danish alphabet. T_ B.2.4.3 W_r_i_t_i_n_g_ _c_h_a_r_a_c_t_e_r_s_._ The following characters are (or may be) written by marking only one field: = (field 12, even numbered columns) ( (field 12, odd numbered columns) , (field 11, even numbered columns) ) (field 11, odd numbered columns) &_ 0 to 9 (fields 0 to 9, respectively) All other characters are written by marking two fields: The f_i_r_s_t_ _f_i_e_l_d_ to be marked is the field in which the character itself appears on the card. \f The s_e_c_o_n_d_ _f_i_e_l_d_ to be marked is field 12, 11, or 0. Which second field to mark is determined by the position of the character in the first field, for example: T________ A B 1 _C______ &_ The characters A, B, and C all appear in field 1. Since the character A has the t_o_p_ _p_o_s_i_t_i_o_n_ in field 1, it is written by marking field 1 a_n_d_ _f_i_e_l_d_ _1_2_. Since the character B has the m_i_d_d_l_e_ _p_o_s_i_t_i_o_n_ in field 1, it is written by marking field 1 a_n_d_ _f_i_e_l_d_ _1_1_. Since the character C has the b_o_t_t_o_m_ _p_o_s_i_t_i_o_n_ in field 1, it is written by marking field 1 a_n_d_ _f_i_e_l_d_ _0_. \f T_ E_x_a_m_p_l_e_ The statement 105 PRINT A,B,NAME< is written by marking a card as follows: - < (4 + 0) - E (2 + 11) - M (5 + 12) - A (1 + 12) - N (5 + 11) - , (11) - B (1 + 11) - , (11) - A (1 + 12) - PRINT - 5 - 0 - 1\f N_o_t_e_ 1. Blank spaces must be marked explicitly (the character SP). Columns having no marks whatsoever will be skipped by the card reader. 2. If a column contains more than the legal number of marks, the column will be skipped. (This can be utilized to skip a column containing an incorrectly marked field). Columns 1-7 may contain only one mark. Columns 8-36 may contain two marks. Column 37 may contain a mark in the CONT field and one other mark. 3. RC BASIC words not found in the STATEMENT sections can be written using the FORMULA section. T_B.3B_a_t_c_h_ _m_o_d_e_ b_B.3.1B_A_T_C_H_/_B_A_T_C_H_ _"_<_L_P_T_"_ _c_o_m_m_a_n_d_e A terminal can be placed in batch mode by giving the command &_BATCH or BATCH "<LPT". Before the command is given, the cards should be placed in the card reader and the reader should be ready, as the system will start reading cards at once. If the BATCH form of the command is used, all output from the jobs executed, i.e. listings, output from PRINT statements (see Ch. 3), and error messages, will appear on the terminal. If the BATCH "<LPT" form of the command is used, job output will be directed to the line printer. T_b_B.3.2I_l_l_e_g_a_l_ _s_t_a_t_e_m_e_n_t_s_ _a_n_d_ _c_o_m_m_a_n_d_s_e &_As stated in Section B.1, there are a few RC BASIC statements and commands which cannot be used in batch mode. They are: INIT AUTO LOCK BATCH/BATCH "<LPT" USERS BYE \f b_B.3.3T_i_m_e_ _l_i_m_i_t_ _o_n_ _j_o_b_s_e A time limit can be placed on a job, so that when the job has run for a specified number of seconds, it will be interrupted. &_ The error message 0010: TIME LIMIT EXCEEDED will then be output and the next job started. The next job is assumed to begin with a SCRATCH command. When a job is started, the time limit is set by default to 60 seconds. This time limit can be changed by means of the TIME command (see Sect. B.6). T_b_ B.3.4 E_S_C_a_p_e_ _k_e_y_ e The ESCape key has a special function when the terminal is in batch mode. &_ When the ESCape key is pressed, the system will interrupt all current activity and output the following message on the terminal: NEXT JOB(1), END OF BATCH(2), CONTINUE(3): Here, the user should respond by typing one of the numbers (i.e. 1, 2, or 3) and pressing the RETURN key. All according to the user"s response, the following will now occur: 1 Cards will be read and skipped until a SCRATCH command is encountered or the reader is empty. 2 The terminal will be placed in interactive mode. 3 The next card will be read and its contents interpreted. b_B.3.5 R_e_t_u_r_n_ _t_o_ _i_n_t_e_r_a_c_t_i_v_e_ _m_o_d_e_e When the BATCH/BATCH "<LPT" command has been given, theterminal will remain in batch mode until one of the following occurs: \f 1. The card reader becomes empty. 2. The user presses the ESCape key and then types the number 2. 3. An I/O error on the card reader is detected. T_B.4 E_O_J_ _c_o_m_m_a_n_d_ F_o_r_m_a_t_ &_ EOJ U_s_e_ As a command to terminate a job. R_e_m_a_r_k_s_ 1. The EOJ command executes an implicit NEW command (see Ch. 9). 2. Any logical disc that was connected by the job will be RELEASEd (see Ch. 7). 3. A card containing the EOJ command should always be the last card in a job. T_B.5 S_C_R_A_T_C_H_ _c_o_m_m_a_n_d_ F_o_r_m_a_t_ SCRATCH text' text': a text, i.e. a number of characters, which will be output as a heading. &_ U_s_e_ As a command to initiate a new job. R_e_m_a_r_k_s_ 1. If the command BATCH (see Sect. B.3) has been given, the\f SCRATCH command will clear the display screen on the RC 822 or RC 823 terminal; if the command BATCH "<LPT" has been given, SCRATCH will cause the output of a form feed (see App. D) on the line printer. 2. If text' is specified, text' will be output as the first line displayed on the terminal or the first line on the new line printer page. 3. The job time limit is set to 60 seconds. This time limit can be changed by means of the TIME command (see Sect. B.6). 4. An implicit NEW command is executed (see Ch. 9). 5. Any logical disc that was connected by the previous job is RELEASEd (see Ch. 7). 6. A card containing a SCRATCH command should always be the first card in a job. T_ B.6T_I_M_E_ _c_o_m_m_a_n_d_ F_o_r_m_a_t_ TIME=val' val': a numeric constant (expressing seconds). U_s_e_ As a command to specify how many seconds a job may run. R_e_m_a_r_k_s_ 1. If the TIME command is not used, the system will interrupt the job in 60 seconds, starting from the execution of the SCRATCH command (see Sect. B.5). 2. The maximum specifiable time limit is 3600 seconds (1 hour). 3. The time allotted to a job is real time, i.e. the amount of central processing unit time which the job actually receives will depend on how many programs are being run at the same time from terminals in interactive mode. \f i T_A_B_L_E_ _O_F_ _C_O_N_T_E_N_T_S_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _P_A_G_E_ 1. INTRODUCTION .......................................... 2. DOMUS UTILITY PROGRAMS ................................ 3. CODEPROCEDURES ........................................ 3.1 Getparams ........................................ 3.2 Connectfile ...................................... 3.3 Splitshare ....................................... 3.4 Getname .......................................... 3.5 Geterror ......................................... 3.6 Finis ............................................ A. REFERENCES ............................................ B. EXAMPLE OF A DOMUS UTILITY PROGRAM .................... \f ii \f 1_._ _ _ _ _ _ _ _ _I_N_T_R_O_D_U_C_T_I_O_N_ 1. This manual gives some information to the MUSIL programmes about the conventions for DOMUS utility programs. The reader must be familiar to the MUSIL language. \f F_ 2_._ _ _ _ _ _ _ _ _D_O_M_U_S_ _U_T_I_L_I_T_Y_ _P_R_O_G_R_A_M_S_ 2. A DOMUS utility program is an ordinary MUSIL program, which ful- fils certain conditions: 1) Runtime parameters are transferred to the program in connec- tion with the call of the program. 2) Use of peripheral devices is done by means of device descrip- tors, which are catalog entries containing information about device name, giveupmask, kind, mode, file, and block. 3) Whenever output to a printer is produced, the program will start with a >top of form> command. A >top of form> is not output, when the printout is finished. 4) When a program terminates its execution, all resources used (i.e. workfiles, area processes) must be released. 5) When the program has finished its execution, it sends an in- ternal request to the father process in order to be removed from memory. 6) Any runtime error during program will result in fetch of an error message from the DOMUS message file. This text is output to the operator console, and the program execution is termi- nated. This means that interactive operator communication is not used. In order to ease the programming, a number of codeprocedures have been developed. They are described in chapter 3 of this manual. \f F_ 3_._ _ _ _ _ _ _ _ _C_O_D_E_P_R_O_C_E_D_U_R_E_S_ 3. 3_._1_ _ _ _ _ _ _ _G_e_t_p_a_r_a_m_s_ 3.1 Declaration: procedure GETPARAMS ( descr: string (1); init: string (1); par: string (1); catalog: string (6); var key: integer); codebody p0260; Place the parameters to the utility program in the string >par>. The parameters are syntax checked according to the string >descr>. If a parameter is not specified, a default value is fetched from the string >init>. Furthermore the name of the current catalog and the key that has been used in the CONNECT-command are delivered in the string >catalog> and the integer >key>. The constant string >descr> describes the parameters and must meet the following syntax: DESCR= ><5 bytes parameter name'<type byte' . . . . <5 bytes parameter name'<type byte' <255'>, In case a parameter name is less than 5 characters, zero bytes must be inserted in the end of the parameter name. The >type byte> describes the type of the actual parameter described by the name placed in front of the line. The last byte in the description string is 255, terminating the parameter list. \f Five values of parameter types exist: <128 text (STRING(value)) 129 Boolean (STRING (1)) The string equals <255' if parameter is yes, and <0' if parameter is no. 130 Integer (INTEGER) 134 Name (STRING (6)) 140 Filename (STRING (12)) or as an example: CONST DESCR= >TX<0'<0'<10' COUNT<130' DEV<0'<0'<134' IN<0'<0'<0'<140' OP<0'<0'<0'<129' <255'>, Here five parameters are defined. The first parameter has the name TX and is defined as a string of length 10 bytes. The second parameter has the name COUNT and is defined as an in- teger. The third parameter has the name DEV and is defined as a name, which is contained in a string of length 6 bytes. The fourth parameter has the name IN and is defined as a file- name, which is contained in a string of length 12 bytes. The fifth parameter has the name OP and is defined as a boolean. Parameter type >filename> has three possible formats, which will be stored in the string in the MUSIL program as described below. Not used positions in the string are set to binary zero. \f 1) <name' The name is stored from the seventh byte and on. 2) <name':<number' The name is stored from the seventh byte and on. The value of the number, which must not exceed 255 is inserted in the twelfth byte. 3) <name'/<name' The first name is stored from the first byte and on, and the second name is stored from the seventh name and on. This parameter type is normally used to point out a certain catalog entry and then has the following interpretation: Byte 1-5 : Catalog name (if not specified, the main catalog) Byte 6 : Not used Byte 7-11 : Entry name Byte 12 : Unit number (if not specified, zero) It is not possible to specify both a catalog name and a unit number. The second parameter to the procedure is a constant string defi- ning the default of all defined parameters. These values are ta- ken if some of the parameters are not defined in the utility call. Example of definition of default values: INIT= >HEADLINE<0'<0'>, <2'<128' MT0<0'<0'<0' <0'<0'<0'<0'<0'<0'<PTRN<0' <255'>, The parameters are the same as defined above. \f The default values are: TX: >HEADLINE<0'<0'> COUNT: 640 (= 2*256+128) DEV: MT0 IN: PTRN OP: YES Note that the default value of the parameter COUNT must be com- puted from two bytes, the first byte giving the 8 leftmost bits, and the second giving the 8 rightmost bits. The third parameter is a variable string, which after call holds the parameters typed by the operator, or the assigned default value if the parameter is skipped by the operator. It can be built as a record in MUSIL, and must as the first element contain a string (6), which is set to the loadname of the utility program. Example: VAR PAR: RECORD LNAME: STRING(6); TX: STRING(10); COUNT: INTEGER; DEV: STRING(6); INCAT: STRING(6); INNAME: STRING(5); INUNIT: STRING(1); OP: STRING(1); END; Notice, that the parameter IN has been split into three smaller pieces to ease the access to the fields. The fourth parameter is a variable string of six bytes, in which the name of the current catalog at call time is delivered. If no CONNECT-command has been executed, the name will be >CAT<0'<0'<0'. \f The fifth parameter is an integer, which after call contains the value of the protection key given in the last CONNECT-command. If no key was given or if current catalog is the main catalog, the value is zero. 3_._2_ _ _ _ _ _ _ _C_o_n_n_e_c_t_f_i_l_e_ 3.2 Declaration: Procedure CONNECTFILE (file f; const mode: integer; ident: string(2); var key: integer); codebody p0261; This codeprocedure looks up the catalog entry given by the call parameter >ident>, which consists of 12 bytes, where the first 6 bytes is the name of a catalog, the next 5 bytes is an entry name, and the last byte is a unit number. If the catalog name is empty (consists of 6 binary zeroes), the main catalog is used. If a catalog name is specified, the unit number must be zero. Depending of the entry and the parameter >mode>, different things will happen. 1) The entry is an ordinary disc file, and the mode is input: The disc file will be opened with the given mode, kind=8>36 and positioned at first segment. 2) The entry does not exist, and the mode is output: A disc file with the given name will be created in the given catalog. The file will be opened in the given mode, kind=8>36 and positioned at first segment. In this case the parameter >key> is used. It must be set to the key of the used catalog (key:=0 if main catalog is used). \f In case of incorrect key, the MUSIL giveup procedure will be called with 1b3+1b6. 3) The entry does not exist, and the mode is input: The giveup procedure in the MUSIL program is called. 4) The entry is an ordinary disc file, and the mode is output: The MUSIL giveup procedure is called with 1b3+1b11 in order to prevent overwrite of existing data. 5) The entry is a devicedescriptor (attribute bit 13 and 14 set): The information of device name, mode, kind, file, block, and giveupmask is transferred from the entry to the zone variables. The mode of the zone is set to the or>ed value of the mode specified in the call and the mode from the entry. Then the zone is opened in this mode and positioned at the given file and block. The format of a devicedescriptor is: Byte 0-5 Entry name 6-11 Optional 1 (Reserved for future use) 12-13 Attribute = 2>110 (+ evt. permanent, writeprotect) 14-15 Giveupmask 16-17 Segment number (set by CAT) 18-19 Reserved length (set by CAT) 20-25 Device name 26-27 Device kind 28-29 Device mode 30 Device file 31 Device block An error in one of the catalog operations performed will result in a call of the giveup procedure in the MUSIL program. If at this time zone.zname is empty, the error had occurred at the at- tempt to make a call of NEWCAT. Otherwise the error comes from LOOKUPENTRY, CREATEENTRY, OPEN, or SETPOSITION. \f If the giveup procedure is called, the zone is left in a neutral state. Note: The parameter >key> is always changed at return from the procedure. 3_._3_ _ _ _ _ _ _ _S_p_l_i_t_s_h_a_r_e_ 3.3 Declaration: procedure SPLITSHARE (file f); codebody P0262; This procedure divides the share of a zone into four to get multibuffering. The zone must be declared with only one share with sharelength 512 bytes. A call of this procedure will change the share into four new shares with sharelength 90 bytes. Four extra message buffers will be allocated too. The division will only take place if the zone is declared with kind bit 15 (character oriented) set, otherwise a call of the procedure has no effect. The procedure is to be used in DOMUS Utility Programs, just after a call of CONNECTFILE. 3_._4_ _ _ _ _ _ _ _G_e_t_n_a_m_e_ 3.4 Declaration: procedure GETNAME (catalog: string(6); name: string(6); text: string(18); codebody p0263; \f The procedure builds a text string in parameter >text> from the two call parameters >catalog> and >name>. The procedure can be used in connection with procedure Geterror as an easy way to write error messages on the operator console. If parameter >catalog> contains anything different from binary zero in the first byte, the catalog name is inserted in the string >text> followed by a slash (/). After this the first five bytes of parameter >name> are inserted. If the sixth byte of >name> is nonzero, a colon (:) is inserted followed by the value of this byte as three decimal digits. The unused part of string >text> is filled with binary zeroes. Examples: catalog name text <0'<0'<0'<0'<0'<0' PIP<0'<0'<0' PIP <0'<0'<0'<0'<0'<0' PIP<0'<0'<1' PIP:001 SUB<0'<0'<0' PIP<0'<0'<0' SUB/PIP SUB<0'<0'<0' PIP<0'<0'<1' SUB/PIP:001 not used 3_._5_ _ _ _ _ _ _ _G_e_t_e_r_r_o_r_ 3.5 Declaration: procedure GETERROR (file f; const error: integer text: string(1)); codebody p0264; This procedure will fetch a message from the DOMUS message file and output it on the operator console followed by the text string given in parameter >text>. \f The zone must be declared with sharelength 512 bytes. The zone variables will be destroyed. The parameter >error> is a call parameter defining the DOMUS message number. The string >text> must be terminated by a binary zero byte. It might be produced by codeprocedure Getname. 3_._6_ _ _ _ _ _ _ _F_i_n_i_s_ 3.6 Declaration: procedure FINIS (const result: integer); codebody p0084; A call of this procedure will result in a removal of the calling process, and thereby a release of the core area reserved. The calling process is defined as the one which executes the call of FINIS. The procedure must be called, when the utility program has terminated its execution and released all its ressources. The call parameter >result> is used to give information to the father process about the job execution. A simple convention exists: result <' 0 : job execution OK result = 0 : job execution n_o_t_ OK This information is not used by the DOMUS operating system, but it is used by other programs using internal commands (e.g. EXEC). \f \f A_._ _ _ _ _ _ _ _ _R_E_F_E_R_E_N_C_E_S_ A 1. RCSL No DOMUS User>s Guide, Part 1. 2. RCSL No DOMUS System, Programmer>s Guide. \f B_._ _ _ _ _ _ _ _ _E_X_A_M_P_L_E_ _O_F_ _A_ _D_O_M_U_S_ _U_T_I_L_I_T_Y_ _P_R_O_G_R_A_M_ B \f eksempler.\f eksempler.\f eksempler.\f eksempler.\f eksempler.\f eksempler.\f eksempler.\f eksempler.\f eksempler.\f «eof»