Sharp OZ-707 Operation Manual - Page 105

Print

Page 105 highlights

PRINT# P D FORMAT: PRINT# file number, {esxtnpnregSSion} [{';} {esxtrpinregSSion}] [{';}] Abbreviation: P.# See Also: OPEN, INPUT# PURPOSE: Writes values of specified variables into a specified file. REMARKS: PRINT# is valid only for a file opened for OUTPUT or APPEND with the OPEN command. The file number is the number given to the file when opened. The mode does not need to be specified when the device name is COM. When an array variable (one or two dimensions) has been specified in the form of "array name(*)", the entire array is written to the file . Its elements are written in the order of, for example, C$(O,O), C$(O,l), C$(0,2) .. .. C$(1,0) ..... C$(5,5) . It is recommended that the FOR...NEXT statement be used for writing array variable data. When the respective elements of the array are specified, they must be specified in the form of "B(7)", "C$(5,6)", etc. When a character or string element is used, it must not be specified using a comma (,) or semicolon (;): PRINT#2, "ABC" PRINT#2,A$ If PRINT#2,"ABC",A$ is executed, no data delimiter is written and "ABC" and A$ cannot be distinguished. A numeric value is recorded in such a form that the sign (space when it is positive), numeric character string, and space appear in that order. The recording format is shown below: (1) When a comma or semicolon does not tollow the data, CR(&HOD) and LF(&HOA) are provided. 198 Example: PRINT # 2, - 1.2 PRINT #2, "ABC" I- I I1 I 2 I ICR ILF I I A I B I C ICR ILF I (2) When a comma follows the data, 20 bytes are occupied. A numeric value is right justified and a character string is left justified. Example: PRINT #2, - 1.2,3 II I I -I 1 I . I 2 I I I 3 I I CRI LFI ~ 20 bytes .1 PRINT #2, "ABC ", "DEF" I AI BI CI ~ 20 bytes I DIE I F I CRI LF I .j When the character string exceeds 20 bytes, the excess part is written to the next 20-byte area. The maximum size is 254 bytes. (3) When a semicolon follows the data, it is stored without spaces. Example: PRINT #2, - 1.2;3 I - 11 I . I2 I I I3 I ICR ILF I PRINT #2, "ABC";" DEF" [ IA I B I C I 0 I E l F ICR ILF I In this case, character strings "ABC" and "DEF" will not be read as separate strings during an INPUT# command. When character strings are recorded with commas or semicolons, they must be read with the INPUT$ command by specifying the exact format in which they were recorded. EXAMPLE: Transmitting data using device name "PACOM" Sender Receiver 10: DIM C (2,3) 10: DIM C (2,3) 20: OPEN "PACOM: DATA" 20: OPEN ·PACOM: DATA" FOR OUTPUT AS #2 FOR INPUT AS #3 30: FOR 1=0 TO 2 30: FOR 1=0 TO 2 40: FOR J=O TO 3 40: FOR J=O TO 3 50: C(I,J)=I*10+J 50: INPUT#3, C(I,J) 60: PRINT #2, C(I,J) 60: NEXT J: NEXT 1 70: NEXT J: NEXT 1 70: CLOSE 80: CLOSE 80: END 90: END After entering RUN IENTER Ion the receiver, enter RUN IENTER Ion the sender. 199

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87
  • 88
  • 89
  • 90
  • 91
  • 92
  • 93
  • 94
  • 95
  • 96
  • 97
  • 98
  • 99
  • 100
  • 101
  • 102
  • 103
  • 104
  • 105
  • 106
  • 107
  • 108
  • 109
  • 110
  • 111
  • 112
  • 113
  • 114
  • 115
  • 116
  • 117
  • 118
  • 119
  • 120
  • 121
  • 122
  • 123
  • 124
  • 125
  • 126
  • 127
  • 128

PRINT#
FORMAT:
PRINT# file number {expreSSion}
[{'}
{expreSSion}]
[{'}]
, stnng
;
string
;
Abbreviation:
P.#
See
Also:
OPEN, INPUT#
PURPOSE:
Writes values of specified variables into a specified file.
REMARKS:
PRINT# is valid only for a file opened for OUTPUT or APPEND with
the OPEN command. The file number
is
the number given to the file
when opened.
The mode does not need to be specified when the device name is
COM.
When
an
array variable (one or two dimensions) has been specified
in
the form of "array name(*)", the entire array
is
written to the file. Its
elements are written
in
the order of, for example,
C$(O
,
O),
C$(O,l),
C$(0,2)
....
C$(1,0)
.....
C$(5,5).
It
is
recommended that the FOR ... NEXT statement be used for writing
array variable data.
When the respective elements of the array are specified, they must be
specified in the form of "B(7)", "C$(5,6)", etc.
When a character or string element is used, it must not
be
specified
using a comma
(,)
or semicolon (;):
PRINT#2, "ABC"
PRINT#2,A$
If PRINT#2,"ABC",A$ is executed,
no
data delimiter is written and
"ABC" and A$ cannot be distinguished.
A numeric value is recorded in such a form that the sign (space when
it
is
positive), numeric character string, and space appear
in
that order.
The recording format is shown below:
(1)
When
a
comma
or
semicolon
does
not
tollow
the
data,
CR(&HOD)
and LF(&HOA)
are
provided.
198
P
D
Example:
PR
INT # 2, -
1.
2
PRINT
#2
, "ABC"
I -
I
1
I
I 2 I
I
CR
I
LF
I
I A I B I C I
CR
I
LF
I
(2)
When a comma follows the data, 20 bytes are occupied. A numeric
value
is
right justified and a character string
is
left justified.
Example:
PRINT
#2
, -
1.2,3
I
I
I
I
-I
1
I . I 2 I
I
I 3 I
I
CR
I LFI
~
20 bytes
.1
PRINT
#2
, "
ABC
", "DEF"
I A I B I C I
I
DIE
I F I
CR
I LFI
~
20 bytes
.j
When the character string exceeds 20 bytes, the excess part
is
written
to the next 20-byte area. The maximum size is 254 bytes.
(3)
When a semicolon follows the data, it is stored without spaces.
Example
:
PRINT
#2,
- 1.2;3
I -
11
I . I
2
I I I
3
I
ICR
I
LF
I
PRINT
#2
, "
ABC
";"DEF"
[ I
A I B I C I
0
I E l F I
CR
I LF I
In
this case, character strings
"
ABC"
and "DEF" will not be read
as
separate
strings during
an
INPUT# command.
When character strings are recorded with commas or semicolons, they
must be read with the INPUT$ command by specifying the exact
format in which they were recorded.
EXAMPLE:
Transmitting data using device name "PACOM"
Sender
Receiver
1
0:
DIM
C
(2
,
3)
10:
DIM
C
(2
,
3)
20:
OPEN
"PACOM:
DATA
"
20:
OPEN ยท
PACOM
: DATA"
FOR
OUTPUT
AS
#2
FOR
INPUT
AS
#3
30
:
FOR
1=0
TO 2
30:
FOR
1=0
TO
2
40
:
FOR
J=O
TO 3
40:
FOR
J=O
TO
3
50:
C(I
,J)=I*10+J
50:
INPUT#3,
C(I
,
J)
60: PRINT #2, C(I ,
J)
60: NEXT J: NEXT 1
70:
NEXT J: NEXT 1
70: CLOSE
80:
CLOSE
80
:
END
90
:
END
After entering RUN
I
ENTER
Io
n the receiver, enter RUN
I
ENTER
Ion
the sender.
199