Usr Function In A Logical Open Statement - Sharp MZ-80B Basic Manual

Personal computer double precision disc
Hide thumbs Also See for MZ-80B:
Table of Contents

Advertisement

1. 8 USR function in a logical open statement

T he USR function generally calls a subroutine coded in machine language. When it is used in a
logical open statement (WOPEN or ROPEN) , however, logical open is performed with the assump ti on
that the USR function is a logical file which is executed when a subsequent PRIN T # or INPU T #
statement is executed. Data input and output can be controlled in the same m anner as for file access.
After the USR function has been logically opened, the PRIN T # and INPU T # statements are execut­
ed as shoWI in the examples below.
( W ri te)
1 00 WOPEN # I O , USR (n)
200 PRIN T # I 0 , A$
300 CLOSE # 1 0
I
00 : Assigns logical file number I 0 to USR (n)
II 0 : Outputs the contents of string variable A $ to the write data buffer and sets the start address of
the write data buffer in the DE register and the data length in the BC register.
For example, when A $
buffer indicated by the DE register and the number o f ASCII codes ( excluding
stored in the BC register.
T hen, USR (n) is executed.
Program operation after control is returned from the machine language routine determined by
the form of the PRIN T # statement as follows.
(I)
When a semicolon follows the data, the next statement is executed.
(2)
When no semicolon follows the data, a
the DE register and OOO I H is set in the BC register, then USR (n) is executed again.
T herefore , when the machine language routine is, for instance, one for controlling the line
printer, a new line operation can be obtained by placing a semicolon in the PRIN T# statement.
1 20 : Closes logical file # I 0 .
"ABCD ", ASCII codes corresponding to "ABCD " are stored in the
=
''
A ''
(4 1 H)
"B"
(42H)
(43H)
"C"
"D"
(44H)
CR
( ODH)
BC
0 004 (hex.)
+--
code (ODH) is set in the location indicated by
15
codes) is

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents