Open read-only?

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

Open read-only?

Postby paues » Fri May 18, 2012 3:54 am

Is it possible to open databases and workfiles read-only? If not, is this something you might consider including?

EViews Chris
EViews Developer
Posts: 161
Joined: Wed Sep 17, 2008 10:39 am

Re: Open read-only?

Postby EViews Chris » Fri May 18, 2012 8:29 am

I'm not sure exactly what you have in mind here.

EViews uses read-only file handles whenever it reads from a database or workfile, and read-write file handles when it writes to a database/workfile.

This means that you are able to set read only permissions on files at the operating system level (including by user, where available) and that would stop either all users or a selected group of users writing to the file.

You can also toggle these file permissions from within an EViews program using a DOS command:

shell attrib +r myfile.wf1

makes the file read only.

shell attrib -r myfile.wf1

makes it writeable again.

Is there something else you have in mind?

EViews Chris
EViews Developer
Posts: 161
Joined: Wed Sep 17, 2008 10:39 am

Re: Open read-only?

Postby EViews Chris » Fri May 18, 2012 8:33 am

I should add that for and EViews database, setting the permissions on the file with the .edb extension should be sufficient.

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

Re: Open read-only?

Postby paues » Mon May 21, 2012 4:22 am

I see now that it works just fine setting the file permissions to read-only with databases. However, with workfiles this does not help me. I would like to not be able to alter a workfile when it is read-only. And have some syntax enabling me to open a file as read-only, even if the file permissions are not set to read-only.

The code below disregards that the workfile is read-only. Thus the second series (tmp2) is created in the final row, eventhough that row should return an error.

Code: Select all

wfcreate a 1980 2012 series tmp=0 wfsave c:\temp\test.wf1 close @all shell attrib +r c:\temp\test.wf1 wfopen c:\temp\test.wf1 series tmp2=0

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

Open read-only?

Postby EViews Gareth » Mon May 21, 2012 6:55 am

You will be unable to save the workfile though, so the version on disk will remain unchanged.


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 2 guests