| get-string-n!(3scm) | Scheme Programmer's Manual | get-string-n!(3scm) |
NAME
get-string-n! - read characters into a stringLIBRARY
(import (rnrs)) ;R6RS (import (rnrs io ports)) ;R6RS
SYNOPSIS
(get-string-n! textual-port string start count)
DESCRIPTION
Reads from textual-input-port in the same manner as get-string-n.If count characters are available before an end of file, they are written into string starting at index start, and count is returned.
If fewer characters are available before an end of file, but one or more can be read, those characters are written into string starting at index start and the number of characters actually read is returned as an exact integer object.
If no characters can be read before an end of file, the end-of-file object is returned and the end-of-file condition is consumed.
RETURN VALUES
Returns a single value; an exact positive integer object, or the end of file object.EXAMPLES
(define s (make-string 10 #\space))
(call-with-port (open-input-file "/etc/hostname")
(lambda (p)
(get-string-n! p s 0 10)))
=> 9
s => "darkstar\n "
APPLICATION USAGE
Application usage is rare in practice.COMPATIBILITY
This procedure is unique to R6RS.ERRORS
This procedure can raise exceptions with the following condition types:- &assertion (R6RS)
- The wrong number of arguments was passed or an argument was outside its domain. In particular, start and count must be exact, non-negative integer objects, string must be a string with at least start+count characters.
- &i/o-read (R6RS)
- A read error occurred during an I/O operation.
- &i/o-decoding (R6RS)
- The textual-input-port is associated with a transcoder in the ↵raise error handling mode and a invalid byte sequence was encountered.
SEE ALSO
get-string-n(3scm), get-bytevector-n(3scm)STANDARDS
R6RSHISTORY
This procedure first appeared in R6RS as part of the reworked I/O system.AUTHORS
This page is part of the scheme-manpages project. It includes materials from the RnRS documents. More information can be found at https://weinholt.se/scheme/manpages/.| 2023-07-23 |