Let's review the different kinds of things that can be stored in an Ox variable. First there are
scalar types, which are things that represent a single concept at any time during a program.
int
: stores a single signed binary integer like 5
double
: stores a single floating-point real (in double precision) like 5.0 or -1.333
pointer
: stores a pointer to an Ox variable (or other data types) using the location of
operator, &
function
: store a pointer-like thing for a function that can be called in the program.
And there are several
array types in Ox. In computer lingo, an
array is a generic term for a data structure that is made up of multiple scalar data types or even multiple other array types. We have already talked about:
vector and matrix
. Vectors are really just a special case of a matrix. Ox does not distinguish between them as different types but sometimes in the syntax it matters if a variable currently holds a vector or non-vector matrix.
string
is a vector of characters (called char
in Ox and in some cases treated like its own scalar type. Your economics-related program may never distinguish between a string of one character and char
. (On the other hand, a program you write may distinguish between a double
and 1\times 1
matrix, which is a close analogy to the char/string
distinction.)
oxarray
which we also call a list
because it is a way to put all sorts of things into a vector- or matrix-like structure.
This section discusses another scalar type in Ox:
file
: holds a pointer-like value that lets the user read and write information from a file on disk. Note that the disk file is information stored in long-term stable area (disk, SD card, USB stick, etc.). On the other hand, the Ox file
is a variable that currently can read or write information to a particular disk file.
You create a
file
and store it in a variable using the
fclose()
function. Then you can read and write to it using functions such as
fprint()
and
fscan()
. For the most part we won't need to open files, but they are important in some types of programs. Please see the Ox documentation on these commands on how to use
formatting strings to make output look good and to read in different kinds of data.