Page 1 of 1

Naming objects in a loop using spool.append.

Posted: Fri Jun 12, 2009 12:49 pm
by fnarita
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

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

Posted: Fri Jun 12, 2009 1:34 pm
by EViews Jason
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

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

Posted: Fri Jun 12, 2009 2:09 pm
by fnarita
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

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

Posted: Thu Aug 11, 2011 6:54 am
by maxchen
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