Check if workfile is open

For questions regarding programming in the EViews programming language.

Moderators: EViews Gareth, EViews Jason, EViews Moderator

J_Gascoigne
Posts: 13
Joined: Wed Apr 10, 2013 8:56 am
Location: London, UK

Check if workfile is open

Postby J_Gascoigne » Fri Feb 23, 2018 6:36 am

Hi - apologies for what is quite a basic question - what is the simplest way to check if a given workfile is open?

I can use @fileexist to see if a workfile is saved to a given location, but I couldn't see an equivalent option to check if it is open in the current instance of EViews (running 8.1 by the way).

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

Re: Check if workfile is open

Postby EViews Gareth » Fri Feb 23, 2018 7:07 am

There isn’t a way. Why do you need to know?
Follow us on Twitter @IHSEViews

J_Gascoigne
Posts: 13
Joined: Wed Apr 10, 2013 8:56 am
Location: London, UK

Re: Check if workfile is open

Postby J_Gascoigne » Fri Feb 23, 2018 7:35 am

It's not absolutely essential but for user friendliness of a self contained program I've written for my team at work. It goes roughly like this:

Check if a workfile exists if it does not then:
1) Create one and load in some data from a csv file, then run an estimation subroutine.
else
2) just run the estimation sub, as I don't want an existing workfile overwritten. The user can tweak specifications settings, with a view that once the workfile has been created they will run several different estimations.

The problem there arises if the workfile exists and the program is run the workfile isn't open so the rest of the code won't run. I could of course just tell it to open the workfile if it exists but then I expect it open another instance of the workfile (which won't include current specification tweaks) or if you are re-running estimations following the creation.

I realise that it's not that difficult for the user to open a workfile first but that just feels a bit clunky and disappointing.

The best work around I can think of is to do an error count check, attempt to use @isobject for a component of the workfile, and see if the error count has gone up - which it will if the workfile isn't open, and then in that case, open it.

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

Check if workfile is open

Postby EViews Gareth » Fri Feb 23, 2018 8:04 am

Wfuse is close
Follow us on Twitter @IHSEViews

J_Gascoigne
Posts: 13
Joined: Wed Apr 10, 2013 8:56 am
Location: London, UK

Re: Check if workfile is open

Postby J_Gascoigne » Fri Feb 23, 2018 8:09 am

Ah, thanks. I missed wfuse when checking for options and having read that I think it will do the trick in this case.


Return to “Programming”

Who is online

Users browsing this forum: Baidu [Spider] and 9 guests