@pagecount: Apparently erroneous documentation

For questions regarding programming in the EViews programming language.

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

Victoria
Posts: 5
Joined: Wed Feb 17, 2010 3:47 am

@pagecount: Apparently erroneous documentation

Postby Victoria » Fri Mar 18, 2011 3:20 am

The documentation (Eviews 7 Command Ref.pdf) states that “@pagecount: returns the number of pages in the current active workfile (0 if no
workfile in memory)”. However, this does not appear to be the behavior of the function in practice. With the following in a program: <if @pagecount = 0 then ...> and no workfile currently opened the program either crashes giving the error message "no workfile" or causes Eviews itself to crash. Is there any way of getting around this unstable behavior or some other way of asking whether there are currently any workfile(s) opened?

(Eviews version 7.1)

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

Re: @pagecount: Apparently erroneous documentation

Postby EViews Gareth » Fri Mar 18, 2011 8:02 am

EViews shouldn't crash, and I can't replicate that behaviour - do you have an example?

As for the more basic question, I personally use @wfname to test whether a workfile is open. If it is empty, there is no workfile open.

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

Re: @pagecount: Apparently erroneous documentation

Postby EViews Gareth » Mon Mar 21, 2011 3:14 pm

The latest patch changes the behaviour of @pagecount to return 0 if there is no workfile open.

Victoria
Posts: 5
Joined: Wed Feb 17, 2010 3:47 am

Re: @pagecount: Apparently erroneous documentation

Postby Victoria » Fri Mar 25, 2011 5:01 am

Great many thanks for the new patch. It solved the problem, so now the following code works :D

Code: Select all

if @pagecount = 0 then wfcreate(wf=test, page=nowf) u 1 %today = @strnow("dd/mm/yyyy") scalar result = -2 result = @uiprompt("No workfile is currently opened. Would you like to create a new workfile?", "OC") if result = 0 then result = -2 %frequencies = """y"" ""m"" ""w"" ""d5""" %wfname = "Untitled" 'name of the workfile %startdate = "03/10/2005" 'start of sample %frequency = "m" result = @uidialog("Caption", "Please enter the detatils for the workfile to be created", "Edit", %wfname, "Name of workfile", _ "List", %frequency, "What frequency would you like for your workfile", %frequencies, _ "Edit", %startdate, "Startdate of workfile (data are only available from October 2005 onwards)") wfcreate(wf={%wfname}, page=untitled) {%frequency} {%startdate} {%today} else stop endif endif
I did also try your proposed solution of using @wfname, however with litle success. Using the code below produced the error "No workfile exists" for every command in the code, but without the unstable behaviour I experienced with @pagecout prior to installation of the new patch

Code: Select all

if @eqna(@wfname,"") then 'create new workfile else %page = @pagename 'something more endif
Thanks alot for your help and for fixing the issue so quickly! :)

Victoria


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 2 guests