Page 1 of 1

Try and Except in EViews

Posted: Fri Sep 27, 2024 12:20 pm
by justincn
Mac user here, but I am using Eviews through Parallels Desktop. One issue that I encounter frequently is a changing drive. For example

fetch(d="x:\<path-to-a -database\somedatabase.edb") {%CONCEPTS}

Will work sometimes, but randomly “x” will change to the “w” drive (or even sometimes "y") and I don’t know why that is. So I’m forced to just hard code it to

fetch(d="w:\<path-to-a -database\somedatabase.edb") {%CONCEPTS}

The behavior is quite inconsistent. Is it possible to execute some form a try and except?

Something along the lines of

try:
fetch(d="x:\<path-to-a -database\somedatabase.edb") {%CONCEPTS}

except:
fetch(d="w:\<path-to-a -database\somedatabase.edb") {%CONCEPTS}


Is there a way to do this in EViews?

Re: Try and Except in EViews

Posted: Fri Sep 27, 2024 3:23 pm
by EViews Matt
Hello,

EViews doesn't provide exception-style error handling, but a program can detect that an error has occurred and react rather than simply stopping. For example:

Code: Select all

setmaxerrs 2 fetch(d="x:\<path-to-a -database\somedatabase.edb") {%CONCEPTS} !error_occurred = @errorcount > 0 clearerrs setmaxerrs 1 if !error_occurred then fetch(d="w:\<path-to-a -database\somedatabase.edb") {%CONCEPTS} endif
The basic idea is to increase the allowed error limit before EViews halts the program, run the statement that may generate an error, detect whether an error occurred, and then react if necessary.

Re: Try and Except in EViews

Posted: Mon Sep 30, 2024 8:57 am
by justincn
Thanks for the response, Matt! I will try to fold this in.