Text files
When dealing with files on disk, they need to be opened. The process establishes a channel to the file that may be for reading, writing, or both.
How this is done depends on the arguments to the open()
call and there are two main (equivalent) syntaxes:
open(filename::AbstractString; keywords...) open(filename::AbstractString, [mode::AbstractString]
The difference is largely historical and inherent in the forms of operating system shell commands.
The keywords consist of a set of five Boolean arguments:
- Read open for read, not write
- Write open for write, truncate, or append
- Create if does not exist; not read and write or truncate or append
- Truncate to zero-size; not read and write
- Append seek to end of file false
Not all of the combinations of the flags are logically consistent, so it is more usual to employ the other form where the mode is passed as an ASCII string:
r
: Readw
: Write, create, truncatea
: Write, create...