INPUT AND OUTPUT  
Acknowledgements
 
Introduction
 
Character Strings
      Representation of Strings
      Creation of Strings
      Integer-Valued Functions
      Character Conversion
      Boolean Functions
      Parsing Strings
 
Printing
      The print-Statement
      Formatted Printing
      Verbose Printing
      Automatic Printing
      Indentation
      Printing to a File
      Printing to a String
      Redirecting Output
 
Input
      Reading a Complete File
      Reading Command Output
      Interactive Input
 
I/O Objects
      Files
      Pipes
      Sockets
      Other Socket Operations
      A Note on Socket Security
 
I/O Operations
      End of File Marker
      Strings
      Legacy String Operations
      Byte Sequences
      Objects
      Versions
      Positioning
      Other I/O Operations
 
Managing Multiple I/O Objects
 
Asynchronous I/O
      A Note on Files and Pipes
      Strings
      Byte Sequences
      Objects
      Versions
 
Loading Program Files
 
Saving and Restoring Workspaces
 
Logging a Session
 
Memory Usage
 
System Calls
 
Creating Names







 
Introduction

 
Character Strings

      Representation of Strings

      Creation of Strings
            "abc" : -> MonStgElt
            BinaryString(s) : MonStgElt -> BStgElt
            s cat t : MonStgElt, MonStgElt -> MonStgElt
            s cat:= t : MonStgElt, MonStgElt -> MonStgElt
            &cat s : [ MonStgElt ] -> MonStgElt
            s ^ n : MonStgElt, RngIntElt -> MonStgElt
            s[i] : MonStgElt, RngIntElt -> MonStgElt
            s[i] : BStgElt, RngIntElt -> RngIntElt
            ElementToSequence(s) : MonStgElt -> [ MonStgElt ]
            ElementToSequence(s) : BStgElt -> [ BStgElt ]
            Substring(s, n, k) : MonStgElt, RngIntElt, RngIntElt -> MonStgElt

      Integer-Valued Functions
            # s : MonStgElt -> RngIntElt
            Index(s, t) : MonStgElt, MonStgElt -> RngIntElt

      Character Conversion
            StringToCode(s) : MonStgElt -> RngIntElt
            CodeToString(n) : RngIntElt -> MonStgElt
            StringToInteger(s) : MonStgElt -> RngIntElt
            StringToInteger(s, b) : MonStgElt, MonStgElt -> RngIntElt
            StringToIntegerSequence(s) : MonStgElt -> [ RngIntElt ]
            IntegerToString(n) : RngIntElt -> MonStgElt
            IntegerToString(n, b) : RngIntElt, RngIntElt -> MonStgElt

      Boolean Functions
            s eq t : MonStgElt, MonStgElt -> BoolElt
            s ne t : MonStgElt, MonStgElt -> BoolElt
            s in t : MonStgElt, MonStgElt -> BoolElt
            s notin t : MonStgElt, MonStgElt -> BoolElt
            s lt t : MonStgElt, MonStgElt -> BoolElt
            s le t : MonStgElt, MonStgElt -> BoolElt
            s gt t : MonStgElt, MonStgElt -> BoolElt
            s ge t : MonStgElt, MonStgElt -> BoolElt
            Example IO_Strings (H3E1)

      Parsing Strings
            Split(S, D) : MonStgElt, MonStgElt -> [ MonStgElt ]
            Example IO_Split (H3E2)
            Regexp(R, S) : MonStgElt, MonStgElt -> BoolElt, MonStgElt, [ MonStgElt ]
            Example IO_Regexp (H3E3)

 
Printing

      The print-Statement
            print expression;

      Formatted Printing
            printf format, expression, ..., expression;
            Example IO_printf (H3E4)
            Example IO_printf2 (H3E5)
            fprintf file, format, expression, ..., expression;
            Example IO_fprintf (H3E6)

      Verbose Printing
            vprint flag: expression, ..., expression;
            vprintf flag: format, expression, ..., expression;

      Automatic Printing
            ShowPrevious() : ->
            ShowPrevious(i) : RngIntElt ->
            ClearPrevious() : ->
            SetPreviousSize(n) : RngIntElt ->
            GetPreviousSize() : -> RngIntElt
            Example IO_auto-print (H3E7)

      Indentation
            IndentPush() : ->
            IndentPush(C) : RngIntElt ->
            IndentPop() : ->
            IndentPop(C) : RngIntElt ->

      Printing to a File
            PrintFile(F, x) : MonStgElt, Any ->
            WriteBinary(F, s) : MonStgElt, BStgElt ->
            PrintFile(F, x, L) : MonStgElt, Any, MonStgElt ->
            PrintFileMagma(F, x) : MonStgElt, Any ->

      Printing to a String
            Sprint(x) : Elt -> MonStgElt
            Sprintf(F, ...) : MonStgElt, ... -> MonStgElt
            Example IO_Sprintf (H3E8)

      Redirecting Output
            SetOutputFile(F) : MonStgElt ->
            UnsetOutputFile() : ->
            HasOutputFile() : -> BoolElt

 
Input

      Reading a Complete File
            Read(name) : MonStgElt -> MonStgElt
            ReadBinary(name) : MonStgElt -> BStgElt
            Example IO_Read (H3E9)

      Reading Command Output
            Pipe(cmd, input) : MonStgElt, MonStgElt -> MonStgElt
            Pipe(cmds, inputs) : SeqEnum, SeqEnum -> SeqEnum
            Example IO_Pipe (H3E10)
            Example IO_Pipes (H3E11)

      Interactive Input
            read identifier;
            readi identifier;

 
I/O Objects
      IOType(I) : IO -> MonStgElt

      Files
            Open(name, mode) : MonStgElt, MonStgElt -> IO
            OpenTest(name, mode) : MonStgElt, MonStgElt -> BoolElt, IO

      Pipes
            POpen(cmd, mode) : MonStgElt, MonStgElt -> IO
            Example IO_GetTime (H3E12)

      Sockets
            Socket(H, P : parameters) : MonStgElt, RngIntElt -> IOSocket
            Socket( : parameters) : -> IOSocket
            WaitForConnection(S) : IO -> IO

      Other Socket Operations
            SocketInformation(S) : IO -> Tup, Tup
            IsServerSocket(S) : IO -> BoolElt
            Example IO_Sockets (H3E13)

      A Note on Socket Security

 
I/O Operations

      End of File Marker
            Eof() : -> MonStgElt
            IsEof(S) : MonStgElt -> BoolElt
            AtEof(I) : IO -> BoolElt
            Example IO_EOF (H3E14)

      Strings
            Read(I : parameters) : IO -> MonStgElt
            ReadCheck(I : parameters) : IO -> BoolElt, MonStgElt
            Read(I, n) : IO, RngIntElt -> MonStgElt
            ReadCheck(I, n) : IO, RngIntElt -> BoolElt, MonStgElt
            Write(I, s) : IO, MonStgElt ->
            WriteCheck(I, s) : IO, MonStgElt -> BoolElt

      Legacy String Operations
            Put(I, s) : IO, MonStgElt ->
            Puts(I, s) : IO, MonStgElt ->
            Getc(I) : IO -> MonStgElt
            Gets(I) : IO -> MonStgElt
            Ungetc(I, c) : IO, MonStgElt ->
            Example IO_LineCount (H3E15)

      Byte Sequences
            ReadBytes(I : parameters) : IO -> SeqEnum
            ReadBytesCheck(I : parameters) : IO -> BoolElt, SeqEnum
            ReadBytes(I, n) : IO, RngIntElt -> SeqEnum
            ReadBytesCheck(I, n) : IO, RngIntElt -> BoolElt, SeqEnum
            WriteBytes(I, S) : IO, SeqEnum ->
            WriteBytesCheck(I, S) : IO, SeqEnum -> BoolElt

      Objects
            ReadObject(I) : IO -> Any
            ReadObjectCheck(I) : IO -> BoolElt, Any
            WriteObject(I, x) : IO, Any ->
            WriteObjectCheck(I, x) : IO, Any -> BoolElt

      Versions
            GetMOTPMaxVersion() : -> MonStgElt
            GetMOTPVersion() : -> MonStgElt
            SetMOTPVersion(v) : MonStgElt ->
            SetMOTPVersion(I, v) : IO, MonStgElt ->
            NotifyVersion(I) : IO ->
            ExpectVersion(I) : IO ->
            ExchangeVersions(I) : IO ->
            Example IO_ObjectExchange (H3E16)

      Positioning
            Tell(I) : IO -> RngIntElt
            Seek(I, offset) : IO, RngIntElt ->
            Rewind(I) : IO ->

      Other I/O Operations
            Flush(I) : IO ->

 
Managing Multiple I/O Objects
      WaitForIO(R : parameters) : SeqEnum -> SeqEnum
      WaitForIO(R, W : parameters) : SeqEnum -> SeqEnum, SeqEnum
      Example IO_ChatServer (H3E17)

 
Asynchronous I/O

      A Note on Files and Pipes

      Strings
            AsyncRead(I : parameters) : IO ->
            AsyncRead(I, n) : IO, RngIntElt ->
            AsyncWrite(I, s) : IO, MonStgElt ->

      Byte Sequences
            AsyncReadBytes(I : parameters) : IO ->
            AsyncReadBytes(I, n) : IO, RngIntElt ->
            AsyncWriteBytes(I, S) : IO, SeqEnum ->

      Objects
            AsyncReadObject(I) : IO ->
            AsyncWriteObject(I, x) : IO, Any ->

      Versions
            AsyncNotifyVersion(I) : IO ->
            AsyncExpectVersion(I) : IO ->
            AsyncExchangeVersions(I) : IO ->
            Example IO_Collatz (H3E18)

 
Loading Program Files
      Load(F) : MonStgElt ->
      Load(Q) : [MonStgElt] ->
      load "filename";
      iload "filename";

 
Saving and Restoring Workspaces
      save "filename";
      restore "filename";

 
Logging a Session
      SetLogFile(F) : MonStgElt ->
      UnsetLogFile() : ->
      SetEchoInput(b) : BoolElt ->

 
Memory Usage
      GetMemoryUsage() : -> RngIntElt
      GetMaximumMemoryUsage() : -> RngIntElt
      ResetMaximumMemoryUsage() : ->

 
System Calls
      Alarm(s) : RngIntElt ->
      ChangeDirectory(s) : MonStgElt ->
      GetCurrentDirectory() : ->
      Getpid() : ->
      Getuid() : ->
      Fork() : -> RngIntElt
      System(C) : MonStgElt -> RngIntElt
      Example IO_GetDate (H3E19)
      %! shell-command

 
Creating Names
      Tempname(P) : MonStgElt -> MonStgElt

[Next][Prev] [Right] [____] [Up] [Index] [Root]


Version: V2.29 of Fri Nov 28 15:14:01 AEDT 2025