basic.weof

Statement/BASIC Program, Releases: AP and R83

Writes an end-of-file mark to tape.

Syntax

weof variable [then | else | onerr statement.block]

Description

writes an 'end of file' mark to the currently attached magnetic media.

The 'then' clause is executed if the operation was successful. If the operation was unsuccessful, the 'else' or 'onerr' clause is executed.

The 'onerr' clause may be used to check for tape error conditions by interrogating the 'system(0)' function. Either 'else' or 'onerr' may be specified, but not both.

See the 'then/else construct' for an explanation on the use of 'then' and 'else' clauses in statements that allow or require them.

Example

In this 'subroutine', a series of tapes files are written using items
in a previously formatted disk file. The items represent tape blocks and the
ids are numbered 1 though M, where M is the block count. When a null item is
encountered, the logic assumes that an 'eof' is to be written to
tape. Two 'eof's indicate an end-of-data condition.

subroutine outtape
execute 't-att ':blocksize
if system(0) = '1' then ; * tape not attached
err=system(0)
return
end
ctr=1; eot=0 ; err=0
loop
read block from tape.hold.file,ctr then
if block='' then ;* a null block in the file
;* write an eof.
weof else err=system(0)
end else
writet block else err=system(0)
end
end else eot=1
until eot or err do
ctr=ctr+1
repeat
if eot then ;* at end-of-tape
weof then ; * write 2 eof's
weof else err=system(0)
end else err=system(0)
end
return

See Also

Command Name Type Description
basic.statements Definition Definition of statements and functions.
basic.rewind Statement Rewinds magnetic media.
basic.readt Statement Reads one tape record.
basic.onerr Definition Takes 'error' path when media error encountered.
basic.then/else.construct Definition provide program flow change based upon a boolean condition.
tcl.t-att Verb: Access Attaches magnetic media unit to current process.
statement.block Definition one or more statements that follow a Pick/BASIC decision-path related token such as, but not limited to, 'then', 'else', 'locked' and 'onerr'.
basic.system Function Displays status of system-controlled variables.
basic.writet Statement Writes a string to magnetic media.

User Comments

What do you think?

Share your experience or ask a question by using the form below.

Login to leave your comments.