Using the %lasterrormsg Variable

Top  Previous  Next

 

The %lasterrormsg variable is initialized to a text description of the last error of the most recently completed script command. This message is the same as what appears in the script log. The corresponding numeric error code is stored in the %lasterror internal variable.

 

The following console window excerpt demonstrates one use of this variable:

 

RCVFILE "does_not_exist"

CMD:        RCVFILE "does_not_exist"

*Receiving to "C:\Program Files\Robo-FTP 3.7\does_not_exist"

*Download failed. [1059]

DISPLAY %lasterrormsg

CMD:        DISPLAY %lasterrormsg

%lasterrormsg = *Download failed.

DISPLAY %lasterrormsg

CMD:        DISPLAY %lasterrormsg

%lasterrormsg =

FTPSETERROR

CMD:        FTPSETERROR

*FTP result code. [450]

DISPLAY %lasterrormsg

CMD:        DISPLAY %lasterrormsg

%lasterrormsg = File opening error [450]

 

IMPORTANT

In the example above, each call to DISPLAY %lasterrormsg shows a different value. On the first execution the value shown is *Download failed from the failed RCVFILE download attempt. On the second execution, the value shown is an empty string which indicates no error on the execution of the first DISPLAY command. The third execution follows a call to FTPSETERROR which sets the value of %lasterrormsg using the value of %ftplastresult (the last response from the remote server) which in this case happens to be File opening error [450].

 

If you want to use this value to report an error via email it is necessary to save the value in a script file variable so that it doesn't get reset by a subsequent command.

 

 

See also: %lasterror, Internal Script Variables