You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
JoeStrout edited this page Sep 11, 2026
·
3 revisions
Read up to codePointCount characters from the file (or all remaining if -1)
Parameters
Parameter
Default Value
Note
codePointCount
-1
Return value
Condition
Return Value
(always)
string
Notes
Counts characters (Unicode code points), not bytes, so read(4) returns 4
characters however many bytes they occupy. Command-line MiniScript's own file
module counts bytes here instead; this module follows Mini Micro.
Returns null once the position is already at the end of the file. A count of 0
returns the empty string without moving the position.
Example
import"file"fh=file.open("data.txt", "r")
chunk=fh.read(4) // read 4 characters as a stringprintchunkfh.close