Error handling

For questions regarding programming in the EViews programming language.

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

paues
Posts: 218
Joined: Fri Apr 15, 2011 7:16 am
Location: Stockholm, Sweden

Error handling

Postby paues » Thu Mar 08, 2012 5:38 am

I am trying to catch an error that might occur if the user of the program does not have Macrobond installed. I have modelled the code below on the example given on page 133 in the EViews 7 command reference:

Code: Select all

!max_before=@MaxErrs SetMaxErrs !max_before+1 !err_before=@ErrorCount DbOpen(type=macrobond) macrobond as mb !err_after=@ErrorCount If !err_after>!err_before Then @UiPrompt("Could not open the Macrobond database. The program requires Macrobond to be installed.") Stop EndIf SetErrCount !err_before SetMaxErrs !max_before
But the first line generates an error message: '@MAXERRS is an illegal or reserved name in "!MAX_BEFORE=@MAXERRS" in MyFile.prg'. What am I doing wrong?

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

Re: Error handling

Postby EViews Gareth » Thu Mar 08, 2012 8:53 am

Looks like @maxerrs isn't working at the moment. I'll see if we can fix it.

In the mean time, you could just set the max errors to something arbitrarily high without worrying about what it was before hand.

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

Re: Error handling

Postby EViews Gareth » Thu Mar 08, 2012 8:56 am

Actually, it looks like it is a slight documentation error. The command is @maxerrcount, not @maxerrs. So you can just change your program to use that.

paues
Posts: 218
Joined: Fri Apr 15, 2011 7:16 am
Location: Stockholm, Sweden

Re: Error handling

Postby paues » Thu Mar 08, 2012 9:16 am

Great! Thank you!


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 1 guest