Naming objects in a loop using spool.append.

For questions regarding programming in the EViews programming language.

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

fnarita
Posts: 15
Joined: Thu Jun 04, 2009 11:15 am

Naming objects in a loop using spool.append.

Postby fnarita » Fri Jun 12, 2009 12:49 pm

Hi,

I have a question on how to program a loop where I can name objects at the same time I append the object to a spool object.

What I like to do is to plot many graphs at once (to check if my data look right).
So, I write a code as follows, according to a suggestion in this "programming" forum.
(Annual.wf1 is attached.)

Code: Select all

' Annual data for all countries available wfopen "Annual.wf1" pageselect Time_Series spool graph_m group g_m ???_m for !i=1 to g_m.@count %name = g_m.@seriesname(!i) graph_m.append(name=%name) {%name}.line next graph_m.display
The problem is the line: graph_m.append(name=%name) {%name}.line.
This line doesn't work well.
The resulting spool object successfully shows all graphs, but the names of the graphs are "untitled01", "untitled02", ... and so forth.

Note that the EViews help file says as follows.
(Index > s > Spool > naming objects by command)
Naming Objects
The default name of an object when it is inserted into a spool is UNTITLED followed by the next available number (e.g. UNTITLED03). When using the Spool::append or the Spool::insert procs may use the "name=" option to specify a name.
So, "name=" option of Spool::append should work.
Could anyone tell me why my code above doesn't work?

Thank you very much for your time,
Futoshi
Attachments
Annual.wf1
(1.56 MiB) Downloaded 429 times

EViews Jason
EViews Developer
Posts: 870
Joined: Tue Sep 16, 2008 3:50 pm

Re: Naming objects in a loop using spool.append.

Postby EViews Jason » Fri Jun 12, 2009 1:34 pm

There is an error in the User Guide. The 'append' command does not have a 'name=' option. So you will need to use the 'name' command after the 'append' command.


Replace:

Code: Select all

graph_m.append(name=%name) {%name}.line
with

Code: Select all

graph_m.append {%name}.line !j = graph_m.@count graph_m.name !j %name

fnarita
Posts: 15
Joined: Thu Jun 04, 2009 11:15 am

Re: Naming objects in a loop using spool.append.

Postby fnarita » Fri Jun 12, 2009 2:09 pm

Thank you so much for your quick reply, QMS Jason!

OK, I understand the error in the User Guide.
And, your code works perfectly!
I really appreciate your help!

Thank you very much,
Futoshi

maxchen
Posts: 191
Joined: Fri Oct 10, 2008 4:03 pm

Re: Naming objects in a loop using spool.append.

Postby maxchen » Thu Aug 11, 2011 6:54 am

There is an error in the User Guide. The 'append' command does not have a 'name=' option. So you will need to use the 'name' command after the 'append' command.


Replace:

Code: Select all

graph_m.append(name=%name) {%name}.line
with

Code: Select all

graph_m.append {%name}.line !j = graph_m.@count graph_m.name !j %name
The 'append' command does have a 'name=' option in EViews 7.2
The following line works

Code: Select all

graph_m.append(name=%name) {%name}.line


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 2 guests