Browse Source

Added standard error io stream.

Brucey 2 years ago
parent
commit
a6b29abeb2
1 changed files with 27 additions and 1 deletions
  1. 27 1
      standardio.mod/standardio.bmx

+ 27 - 1
standardio.mod/standardio.bmx

@@ -42,6 +42,18 @@ Type TCStandardIO Extends TStream
 
 End Type
 
+Type TCStandardErrIO Extends TStream
+
+	Method Flush() Override
+		fflush_ stderr_
+	End Method
+
+	Method Write:Long( buf:Byte Ptr,count:Long ) Override
+		Return fwrite_( buf,1,count,stderr_ )
+	End Method
+
+End Type
+
 Rem
 bbdoc: BlitzMax Stream object used for Print and Input
 about: The #Print and #Input commands can be redirected by setting the @StandardIOStream Global to an alternative Stream Object.
@@ -49,7 +61,12 @@ End Rem
 Global StandardIOStream:TStream=TTextStream.Create( New TCStandardIO,ETextStreamFormat.UTF8 )
 
 Rem
-bbdoc: Write a string to the standard IO stream
+bbdoc: BlitzMax Stream object used for #ErrPrint
+End Rem
+Global StandardErrIOStream:TStream=TTextStream.Create( New TCStandardErrIO,ETextStreamFormat.UTF8 )
+
+Rem
+bbdoc: Write a string to the standard errIO stream
 about: A newline character is also written after @str.
 End Rem
 Function Print( str$="" )
@@ -57,6 +74,15 @@ Function Print( str$="" )
 	StandardIOStream.Flush
 End Function
 
+Rem
+bbdoc: Write a string to the standard error IO stream
+about: A newline character is also written after @str.
+End Rem
+Function ErrPrint( str$="" )
+	StandardErrIOStream.WriteLine str
+	StandardErrIOStream.Flush
+End Function
+
 Rem
 bbdoc: Receive a line of text from the standard IO stream
 about: The optional @prompt is displayed before input is returned.