LastErrorCode

Hello all,

Am in the process of updating a console app that was created in 2019R1.1 to 2023R3.1.

I get error messages about the use of .LastErrorCode when using it with a TextOutputStream

The docs say it is depreciated yet the intellisense show it clearly in the drop down.

Dim fileStream As TextOutputStream
fileStream.WriteLine (TextLine)
fileStream.Close

RetVal = fileStream.LastErrorCode  <<===
``
I thought that the intellisense would have shown the alternative and not the depreciated but it does.

So the question is, what should be used to check the last error code??

Thanks,
Tim

As of 2019r2, I think, TextOutputStream will raise an exception instead of returning a code. You would write your code as

Dim fileStream as TextOutputStream
try
   fileStream.WriteLine(TextLine)
   fileStream.Close
   // code that would run if LastErrorCode is zero
catch ioe as IOException
   RetVal = ioe.ErrorNumber   // if you still need this
end try

Thanks Tim!
Tim