WRITEB

Purpose:

Writes a series to a file in binary format, without a file header (as created by the EXPORT routine).

Syntax:

WRITEB("filename", filetype, overwrite, byteswap, series)

"filename"

-

A string. The name of the binary file to write. If no path is given, WRITEB writes the file in the current working directory.

filetype

-

An integer, the binary format type of the data file to store described by either its name or integer code. Valid arguments are:

 

Name

Code

Data Type

Range

INT8

SBYTE

1

8-bit Signed Byte

-128 to +127

UINT8

UBYTE

BYTE

2

8-bit Unsigned Byte

0 to 255

INT16

SINT

3

16-bit (2-byte) Signed Integer

-32768 to +32767

UINT16

UINT

4

16-bit (2-byte) Unsigned Integer

0 to 65535

INT32

LONG

5

32-bit (4-byte) Signed Integer

-2,147,483,648 to +2,147,483,647

FLOAT

6

32-bit (4-byte) Floating Point

-1037 to +1038

DOUBLE

7

64-bit (8-byte) Floating Point

-10-307 to +10308

UINT32

ULONG

8

32-bit (4-byte) Unsigned Integer

0 to 4,294,967,295

INT64

9

64-bit (8-byte) Signed Integer

-9,223,372,036,854,775,808 to +9,223,372,036,854,775,807

UINT64

10

64-bit (8-byte) Unsigned Integer

0 to 18,446,744,073,709,551,615

 

1000 + N

N-byte Signed Integer

-28N-1 to 28N-1-1

 

2000 + N

N-byte Unsigned Integer

0 to 28N-1

 

overwrite

-

Optional. An integer, the overwrite mode:

0:

prompt before overwriting file (default)

1:

overwrite file if it exists without prompting

2:

append data to the specified file

byteswap

-

Optional. An integer. Swap the order of the bytes read.

0:

do not swap bytes (default)

1:

swap bytes

series

-

Optional. A series, the source data. Defaults to the current Window.

Example:

writeb("test.bin", INT16, {1, 2, 3, 4})

W1: readb("test.bin", INT16)

 

returns the series {1, 2, 3, 4}.

Example:

writeb("test.bin", SINT, {1, 2, 3, 4})

W1: readb("test.bin", SINT)

 

returns the series {1, 2, 3, 4}.

Example:

writeb("TEST.DAT", INT8, 2, W4)

 

appends the contents of Window 4 to a binary file named TEST.DAT in a signed-byte format. If using READB to bring the file back into a Worksheet, be sure to use the same binary format, i.e. in this case, INT8.

Example:

sine3 = int(100 * gsin(100, 1/100, 2));

writeb("sine3.dat", 1003, sine3);

W1: readb("sine3.dat", 1003)

 

W1 contains 100 samples of a sinewave saved as 3 byte signed integers. The special filetype value of 1000 + N specifies an N byte signed integer value.

Remarks:

WRITEB exports data to a file, although it does not export a header with series information like the EXPORT Utilities. To minimize disk space, the filetype should be chosen to fit the magnitude and precision of the data.

 

WRITEB also supports N byte integer format to read signed or unsigned multiple bytes as integer values. A filetype value of 1000 + N specifies N byte signed integer values and 2000 + N specifies N byte unsigned integer values. For example:

 

1003

 

implies a 3 byte signed integer values.

 

2005

 

implies a 5 byte unsigned integer values.

 

 

Use READB to read a binary file.

See Also:

BYTE2TYPE

CASTBYTE

EXPORTFILE

FREADB

FWRITEB

IMPORTFILE

READA

READB

TYPE2BYTE

WRITEA

WRITETABLE