Error Handling: WFCLOSE and TRY

For questions regarding programming in the EViews programming language.

Moderators: EViews Gareth, EViews Moderator, EViews Jason, EViews Matt

BrsG
Posts: 18
Joined: Thu Aug 29, 2013 3:20 am

Error Handling: WFCLOSE and TRY

Postby BrsG » Thu Aug 29, 2013 3:59 am

[Using version 8]

Hi there,

I am missing a few essential features in Eviews related to error handling, in particular an equivalent to the "try" command common to many programming languages.

First, I am aware that there is the possibility of using the error count. But this is often cumbersome.

WFCLOSE: wouldn't it be possible to change this command for Eviews to try to close any open WF? Currently I have to comment it in an out while debugging. Would it be possible to extend the "noerr" option to the case where no name is given? Btw, even in the case where a name is given the "noerr" options doesn't seem to work for me (in the code below). Am I doing something wrong?

Code: Select all

cd %path wfclose(noerr) pr wfcreate(wf=pr,page=raw) M 1980M1 2020M12
Equation estimation: It happens sometimes that I want to estimate a large number of equations with the same structure, without checking beforehand whether all the data involved are well behaved. I would ideally want to use something like

Code: Select all

for !k = 1 to K try eq{!k}.ls {eqstructure} next
In the above using error counts might still be workable (although it also doesn't seem to work for every error), but if I have block of instructions which I want to "try" it quickly gets cumbersome to wrap each instruction with the error count syntax.

Cheers,
Boris

EViews Gareth
Fe ddaethom, fe welon, fe amcangyfrifon
Posts: 13600
Joined: Tue Sep 16, 2008 5:38 pm

Re: Error Handling: WFCLOSE and TRY

Postby EViews Gareth » Thu Aug 29, 2013 7:47 am

As you point out, there is no TRY in EViews.

I'll look into the wfclose issue.

BrsG
Posts: 18
Joined: Thu Aug 29, 2013 3:20 am

Re: Error Handling: WFCLOSE and TRY

Postby BrsG » Thu Aug 29, 2013 8:16 am

Thanks for looking into the wfclose issue.

Regarding "try". The point I was trying to make was that it would be great to have "try".

EViews Glenn
EViews Developer
Posts: 2682
Joined: Wed Oct 15, 2008 9:17 am

Re: Error Handling: WFCLOSE and TRY

Postby EViews Glenn » Thu Aug 29, 2013 11:16 am

We had a brief discussion of this and the question came up. What exactly is it that you'd like "try" to do?

mboldin
Posts: 10
Joined: Wed Sep 11, 2013 7:53 am

Re: Error Handling: WFCLOSE and TRY

Postby mboldin » Tue Feb 11, 2014 8:00 am

Let me make a suggestion in this regard

I think it would be useful to have a conventional try - except - else type ability (the Pythonic way is worth looking at http://docs.python.org/2/tutorial/errors.html as an example)

While the method below can be adopted to probably handle 90% or more of the applications or error ahandling, it would be better to use error catching by type and to have a try part that handles a block of code, as opposed to having error checking after every line of code that needs checking. I.e., I would prefer to write code as in the second example

'Current way
fetch (d=mydata) {%x} ' %x from from loop
if @lasterrnum=0 then
'no fetch error, so skip ahead or do something such as compute mean of %X or add to an accumulating sum
else
genr {%x}= @na 'set all series values as missing
'more error handling
endif


'Better way IMHO
try
fetch (d=mydata) {%x} ' %x from from loop
!amean= @mean({%x}
genr y_{%x} = y / !amean
except fetch_error_code
genr {%x}= @na 'set all series values as missing
genr y_{%x}= @na
'more error handling
except divide_by_zero_error
genr y_{%x}= @na 'set series as missing
else
'no error, so do something or not ...
endtry


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 2 guests