Out # Command

Purpose

Writes a value to an already opened file.

Syntax

Out # n, a [,b,c...]

Out| # n, a [,b,c...]

Out& # n, a [,b,c...]

Out% # n, a [,b,c...]

n:integer expression; channel number

a,b,c...:aexp

Description

Out # n writes one or more bytes to a previously opened file. The numerical expression n contains the channel number (from 0 to 511) used to access the file.

Out| # is synonym with Out #. Out& # writes a 16-bit integer (word) and Out% # writes a 32-bit integer.

Example

OpenW 1

Local a%, b&, i%

Open "C:\TEST.DAT" for Output As # 1

For i% = 1 To 20

Out& # 1, 128

Next i%

Close # 1

OpenW # 1

Print "The file C:\TEST.DAT was written using only Out& #n ()" _

+ "out and will be read back now."

Print

Open "C:\TEST.DAT" for Input As # 1

For i% = 1 To 20

b& = Inp&(# 1)

Print b&`

Next i%

Close # 1

// Now use Out|, Out and Out% to produce the same result

Open "C:\TEST.DAT" for Output As # 1

For i% = 1 To 5

Out| # 1, 128

Out # 1, 0

Out% # 1, $00800080

Out& # 1, 128

Next i%

Close # 1

Print : Print

Print "The file C:\TEST.DAT was written using all four versions of Out #n ()" _

+ " and will be read back now."

Print

Open "C:\TEST.DAT" for Input As # 1

For i% = 1 To 20

b& = Inp&(# 1)

Print b&`

Next i%

Close # 1

// Tidy up line

Kill "c:\test.dat"

Opens the file TEST.DAT on drive C and writes the word value 128 to it 20 times from inside a For...Next loop.

See Also

Inp

{Created by Sjouke Hamstra; Last updated: 21/10/2014 by James Gaite}