StrLastError


julius228

Recommended Posts

Posted

In version 16.3 (build 2297) I can not access the content of StrLastError. Is it normal?

This is the error I have.

? StrLastError
C1000 Channel or function not found

 

Many thanks in advantage,

 

Giulio

Posted

strLastError is a private variable and is only created when an error is caught by a try/catch block.  So:

// ? strLastError here will fail because it doesn't exist yet
try
   x = x + 1
catch()
   ? strLastError
endcatch
? strLastError

will work (if x doesn't exist), displaying the error twice because strLastError is created by the catch() statement, but then still exists after the endcatch.  It doesn't exist until an error occurs, so using it before the try, or really before the catch() will fail.  The last ? strLastError will fail if there is no error because strLastError is never created.

So really, as a rule, only use strLastError inside a catch()/endcatch block.

  • 1 month later...

Archived

This topic is now archived and is closed to further replies.