Record Type INTERNAL
1. About Record Type INTERNAL
Files of record type INTERNAL are those in which the records output by WRITE statements can be input by READ statements.
２．OPEN statements
OPEN statements are written in the following form.
`OPEN #Channel_Number NAME File_Name ,RECTYPE INTERNAL
OPEN #Channel_Number NAME File_Name ,ACCESS OUTIN ,RECTYPE INTERNAL
OPEN #Channel_Number NAME File_Name ,ACCESS INPUT ,RECTYPE INTERNAL
OPEN #Channel_Number NAME File_Name ,ACCESS OUTPUT ,RECTYPE INTERNAL
` (Omitting ACCESS-clause means OUTIN)

3. WRITE Statements
To output data to a file of record type internal, use WRITE statements instead of PRINT statements.
Output items are written in a WRITE statement separated by commas.
No semicolon can be written, and no comma can be written on the tail.
Example 1.

    10 OPEN #1: NAME "A:TEST.CSV",RECTYPE INTERNAL
    20 ERASE #1
    30 WRITE #1: 1/7, "ABC"
    40 CLOSE #1
    50 END

4. READ statements
To input data from a file of record type internal, use READ statements instead of INPUT statements.
Example 2.

    10 OPEN #1: NAME "A:TEST.CSV",ACCESS INPUT, RECTYPE INTERNAL
    20 READ #1: A,S$
    30 PRINT A,S$
    40 CLOSE #1
    50 END

5. MAT WRITE, MAT READ
Arrays that was output to a file of record type internal using a MAT WRITE statement can be read using a MAT READ statement.
Example 3. Output

    10 DIM A(4),B$(2,2)
    20 MAT READ A,B$
    30 DATA 1,2,3,4,ABC,DEF,HIJ,KLM
    40 OPEN #1:NAME "A:MAT.TXT",RECTYPE INTERNAL
    50 ERASE #1
    60 MAT WRITE #1: A,B$
    70 CLOSE #1
    80 END

Example 4. Input

    10 DIM A(4),B$(2,2)
    20 OPEN #1:NAME "A:MAT.TXT",RECTYPE INTERNAL
    30 MAT READ #1: A,B$
    40 CLOSE #1
    50 MAT PRINT A,B$
    60 END

An example dealing with a variable length array
Example 5. Output

    10 DIM A(100)
    20 MAT INPUT A(?)      ! The size of A varies
    30 OPEN #1:NAME "A:MAT.TXT",RECTYPE INTERNAL
    40 ERASE #1
    50 WRITE #1:UBOUND(A)  ! Record the number of elements
    60 MAT WRITE #1:A
    70 CLOSE #1
    80 END

Example 6. Input

    10 DIM A(100)
    20 OPEN #1:NAME "A:MAT.TXT",RECTYPE INTERNAL
    30 READ #1:N           ! The number of elements
    40 MAT READ #1:A(N)    ! Read dada after chaging the size of the array
    50 CLOSE #1
    60 MAT PRINT A
    70 END

Notes.
On this BASIC, internal record type is comma-separated values(CSV).
Numeric values are expressed by figures. E-notation may be used.
A String is always put in double quotes. When a string contains a double quote, it shall be duplicated.
The end of record is the characters CR(CHR$(13)) and LF(CHR$(10)).
For example, After the execution of Example 1, the contents of "A:TEST.CSV" becomes

    .142857142857143 ,"ABC" (CR and LF follow)

A MAT WRITE statement outputs all elements of arrays separated by commas.
For example, After execution of Example 3, the contents of "A:MAT.TXT" becomes

    1 , 2 , 3 , 4 ,"ABC","DEF","HIJ","KLM"