try...catch and XS0165 (Use of unassigned local variable...)
Posted: Fri Sep 07, 2018 2:01 pm
Hi!
This:
LOCAL oSR as StreamReader
TRY
oSR := StreamReader(cFile)
do while....
enddo
CATCH ex...
FINALLY
oSR:Close()
END TRY
creates error XS0165 for variable oSR.
My question is, how to handle this.
Is oSR already created before exceptions arise? The I consider it OK to do it like that and the message is wrong.
If oSR is NOT already created before exceptions occur, then must I use a separate TRY around the creation of oSR?
This:
LOCAL oSR as StreamReader
TRY
oSR := StreamReader(cFile)
do while....
enddo
CATCH ex...
FINALLY
oSR:Close()
END TRY
creates error XS0165 for variable oSR.
My question is, how to handle this.
Is oSR already created before exceptions arise? The I consider it OK to do it like that and the message is wrong.
If oSR is NOT already created before exceptions occur, then must I use a separate TRY around the creation of oSR?