Page 1 of 1

How to skip to next if there is an error?

Posted: Tue Dec 16, 2008 8:53 am
by cmgconsulting
I'm trying to write a program that will take all of the equation objects and put them into a spool and then name them based on a series called "eqname"

The problem is that I do not ALWAYS have an object called whatever is in eqname(39*!i). How can I tell it to just skip any problems and continue the program? If I tell it to accept say 1000 errors, then it won't name the objects anymore. Not sure why? Any help?

Code: Select all

spool myspool for !i=1 to 320 %cxname = eqname(39*!i) %eqname = %cxname myspool.append {%eqname} if !i<10 then myspool.name untitled0{!i} {%eqname} else myspool.name untitled{!i} {%eqname} endif next

Re: How to skip to next if there is an error?

Posted: Tue Dec 16, 2008 9:04 am
by startz
I'm trying to write a program that will take all of the equation objects and put them into a spool and then name them based on a series called "eqname"

The problem is that I do not ALWAYS have an object called whatever is in eqname(39*!i). How can I tell it to just skip any problems and continue the program? If I tell it to accept say 1000 errors, then it won't name the objects anymore. Not sure why? Any help?

Code: Select all

spool myspool for !i=1 to 320 %cxname = eqname(39*!i) %eqname = %cxname myspool.append {%eqname} if !i<10 then myspool.name untitled0{!i} {%eqname} else myspool.name untitled{!i} {%eqname} endif next
This isn't a direct answer to your question, but the @isobject() function might help you avoid the errors.

Re: How to skip to next if there is an error?

Posted: Tue Dec 16, 2008 9:10 am
by EViews Gareth
As Startz already pointed out, you can use the @isobject function to check whether an object exists before doing something to that object, which should avoid any errors. However you can also crudely program around errors by using the @errorcount function to tell you how many errors have occurred in the program so far. This lets you check whether a line of program has caused an error or not (by seeing if @errorcount is higher after that line).