一覧にある関数はとりあえず、使えそうな関数です。
現在のところ、確認は、2.6.10で行っています。
入出力 | ||
---|---|---|
( input-port? v ) | boolean | |
入力ポートか? v が入力ポートなら #t、そうで無ければ #f を返します。 | ||
( output-port? v ) | boolena | |
出力ポートか? v が出力ポートなら #t、そうでなければ #f を返します。 | ||
( port? v ) | boolean | |
ポートか? v が入力ポートか、出力ポートならば #t、そうでなければ #f を返します。 | ||
( close-input-port | ||
入力ポートを閉じる 入力ポート in を閉じます。 | ||
( close-output-port | ||
出力ポートを閉じる 出力ポート in を閉じます。 | ||
( current-input-port ) | port | |
カレント入力ポート。 カレント入力ポートを返します。 | ||
( current-output-port ) | port | |
カレント出力ポート カレント出力ポートを返します。 | ||
( eof-object? v ) | boolean | |
EOFか? v が EOF オブジェクトならば #t、そうでなければ #f 返します。 | ||
( open-input-file | input-port | |
入力ポートを開く 文字列 filename の名前の既存ファイルを開いてその入力ポートを返します。 | ||
( open-output-file | 戻り値 | |
出力ポートを開く。 文字列 filename の名前のファイルを作成してその出力ポートを返します。 | ||
( open-input-output-file | port | |
入出力ポートを開く "COM"のように入出力を同時に行う特殊なデバイスをアクセスするときに使用します。返されるポートは、output-portであり、かつ、input-portでもあります。 | ||
( call-with-input-file | ||
手続きつき入力ポート処理 文字列 filename のファイルを開き、結果のポートを引数として proc を呼び出します。 ←これがファイルの中を読んだ(read)したもの(call-with-input-file "e:\\00temp\\test.txt" (lambda (in) (print (read in)) ) ) "abc" | ||
( call-with-output-file | ||
手続きつき出力ポート処理 文字列 filename のファイルをつくり、結果のポートを引数として proc を呼び出します。
(call-with-output-file "e:\\00temp\\test.txt" (lambda (out) (write "start" out) (newline out)) )
\t
| ||
( with-input-from-file | ||
手続きつき入力ポート処理 文字列 filename のファイルを開き、結果のポートをカレント入力ポートに割り当ててから proc を呼び出します。 (with-input-from-file "e:\\00temp\\test.txt" (lambda () (print (read)) ) ) "start" | ||
( with-output-to-file | ||
手続きつき出力ポート処理 文字列 filename のファイルを作成し、結果のポートをカレント出力ポートに割り当ててから proc を呼び出します。
(with-output-to-file "e:\\00temp\\test.txt" (lambda () (print "newfile") ) )
#t
| ||
( open-input-string | input-port | |
入力ポートを開く 与えられた文字列 str を読み込むように入力ポートを開き、返却する (define myport (open-input-string "linear whale")) myport (read myport) linear (read myport) whale (close-input-port myport) | ||
( open-output-string ) | outport | |
出力ポートを文字列に結びつける 文字列に結び付けられた出力ポートを返す。 | ||
( read-char | char | eof | |
文字読み込み 入力ポート in から一文字読み込み、文字を返します。ファイル末ならば、「eof」を返します。 (define myport (open-input-file "e:\\00temp\\test.txt")) myport (read-char myport) #\" (read-char myport) #\n (read-char myport) #\e (read-char myport) #\w (close-input-port myport) #t | ||
( peek-char | char | eof | |
文字先読み 入力ポート in から1文字先読みして返します。ファイル末ならば、「eof」を返します。 (define myport (open-input-file "e:\\00temp\\test.txt")) myport (peek-char myport) #\" (peek-char myport) #\" (read-char myport) #\" (peek-char myport) #\n (close-input-port myport) #t | ||
( char-ready? | boolean | |
読み込み可能か? 入力ポート in が読み込み可能ならば #t、そうでなければ #fを返します。 | ||
( write-char | ||
文字出力 出力ポート out に文字 c を出力します。 | ||
( newline | ||
改行出力 出力ポート out に改行文字 #\newline を出力します。 | ||
( read | ||
読み込み 入力ポート in から要素をひとつ読み込み返します。 | ||
( write expr | ||
出力 出力ポート out に expr を出力します。 | ||
( display expr | 戻り値 | |
出力 出力ポート out に expr を出力します。 | ||
( print expr | ||
出力 出力ポート out に expr を出力します。 |