# MATWRITE

Updated: 10/19/2021, 9:29:48 PM
Created: 10/19/2021, 9:29:48 PM
Last Updated By: Kevin Munoz
Read Time: 1 minute(s)

Tags: dimensioned arrays record handling

# Description

The MATWRITE statement transfers the entire contents of a dimensioned array to a specified record on disc. It takes the general form:

MATWRITE array ON { variable,}expression {SETTING setvar} {ON ERROR statements}
1

Where:

  • array should be a previously dimensioned and initialized array.
  • If specified, variable should be a previously opened file variable (i.e. the subject of an OPEN statement). If variable is not specified the default file variable is used.
  • expression should evaluate to the name of the record in the file.
  • If the SETTING clause is specified and the write succeeds, setvar will be set to the number of attributes read into array. If the SETTING clause is specified and the write fails, setvar will be set to one of these values.
  • If ON ERROR is specified, the statements following the ON ERROR clause will be executed for any of these values except error 128.

The compiler will check that the variable specified is a dimensioned array before its use in the statement.

An example of use is as:

dim sample_arr(20)
mat sample_arr = 99

matwrite sample_arr on "New array" setting response_code on error
    crt "Error : " : response_code : " Record could not be written."
end
1
2
3
4
5
6

Go back to jBASE BASIC

Go back to Programmers' Reference Guide