naming samples in a program

For questions regarding programming in the EViews programming language.

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

miorinnovo
Posts: 199
Joined: Sun Mar 01, 2015 5:01 pm

naming samples in a program

Postby miorinnovo » Tue Feb 27, 2018 8:49 am

This is only a a minor annoyance but when I re-run a program that contains a sample I created, the program stops saying that sample already exists. Is there a way around that other than commenting out the sample creation line?

Thanks

EViews Matt
EViews Developer
Posts: 560
Joined: Thu Apr 25, 2013 7:48 pm

Re: naming samples in a program

Postby EViews Matt » Tue Feb 27, 2018 10:31 am

Hello,

You can condition the sample creation statement with an @isobject check, that way the sample object will only be created if it doesn't already exist:

Code: Select all

if not @isobject("foo") then
   sample foo ...
endif

If the sample is dynamic (possibly changing each time you run the script), you could do something similar to reset or delete and recreate the sample object instead.

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

Re: naming samples in a program

Postby EViews Gareth » Tue Feb 27, 2018 6:31 pm

I always just throw a

Code: Select all

D(noerr) objectname

At the top of the program
Follow us on Twitter @IHSEViews


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 28 guests