◆今回のプログラムリスト
●Macintosh Future BASIC 1.0.x,2.13,2.3
thePort = _modemPort
END GLOBALS
LOCAL FN initSerial
WINDOW OFF
WINDOW #1,"Let's Communication",(8,40)-(320,400),_doc
TEXT _applFont,12
OPEN "C",#thePort,4800,_noParity,_oneStopBit,_eightBits,16384
END FN
'--------------------------------------------------
' "コマンドを受信する"
'--------------------------------------------------
LOCAL FN getCommand$
moji$ = ""
DO
READ #thePort,a$;0
IF ASC(a$) > &H20 THEN moji$=moji$+a$
UNTIL a$ = CHR$(13)
END FN = moji$
'--------------------------------------------------
' "ファイルを送信する"
'--------------------------------------------------
LOCAL FN fileopen
filename$ = FILES$(_fOpen,"TEXTEPSF",,vRefNum)
LONG IF filename$<>""
OPEN "I",#3,filename$,,vRefNum
WHILE NOT EOF(3)
LINE INPUT #3,sd$
PRINT sd$
PRINT #thePort,sd$
moji$ = FN getCommand$: ' "mz:nextの文字を受信"
WEND
CLOSE #3
END IF
END FN
'--------------------------------------------------
' "ファイルを保存する"
'--------------------------------------------------
LOCAL FN filesave
filename$ = FILES$(_fSave,"保存ファイル名:","",vRefNum)
LONG IF filename$<>""
DEF OPEN "TEXTttxt"
OPEN "O",#3,filename$,,vRefNum
DO
PRINT #thePort,"mac660av:send"
moji$ = FN getCommand$: ' "テキストを受信"
PRINT moji$
PRINT #3,moji$
UNTIL moji$="mz:end"
CLOSE #3
END IF
END FN
'--------------------------------------------------
' "コマンドを処理する"
' "end -> 終了"
' "cls -> 画面消去"
' "open -> ファイルオープン後、内容送信"
'--------------------------------------------------
LOCAL FN main
endFlag = _false
WHILE endFlag = _false
cmd$ = FN getCommand$: ' "コマンド入力を待つ"
PRINT cmd$
IF cmd$="end" THEN endFlag = _true
IF cmd$="cls" THEN CLS
IF cmd$="open" THEN FN fileopen
IF cmd$="save" THEN FN filesave
IF cmd$="shutdown" THEN SHUTDOWN
PRINT #thePort,"mac660av:end"
WEND
END FN
FN initSerial
FN main
CLOSE #thePort
●MZ-2500 BASIC M25
10 init "com1:4800,N81"
20 open "o",#1,"com1:"
30 open "i",#2,"com1:"
40 *LOOP
50 input "Command:";CMD$
60 if CMD$="save" then *SENDTEXT
70 print #1,CMD$
80 repeat
90 line input #2,MSG$
100 print MSG$
110 print #1,"mz:next"
120 until MSG$="mac660av:end"
130 goto *LOOP
140 '------------------------
150 'sendtextfile
160 '------------------------
170 *SENDTEXT
180 input "filename:";FILENAME$
190 open "i",#3,FILENAME$
200 print #1,"save"
210 while not eof(3)
220 input #2,MSG$:'"mac660av:send"command
230 line input #3,A$
240 print #1,A$
250 wend
260 input #2,MSG$:'"mac660av:send"command
270 print #1,"mz:end"
280 close #3
290 goto *LOOP