running only part of a programme

For questions regarding programming in the EViews programming language.

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

marco.stringa
Posts: 3
Joined: Wed Aug 11, 2010 9:58 am

running only part of a programme

Postby marco.stringa » Wed Aug 11, 2010 10:12 am

I have just started programming in Eviews 6 and I would like to know if there is a way of running only subsections of a code without using the stop command. Eg in Matlab and STATA I can highlight part of a code and run it using a shortcut.

Similarly how can I transform large section of a code in text without manually inputting the character <‘> in each line.

Thanks,
Marco

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

Re: running only part of a programme

Postby EViews Gareth » Wed Aug 11, 2010 10:18 am

You cannot run only part of a program (other than by putting an if condition around the other parts).

EViews 7 lets you block comment text, but EViews 6 does not have that functionality.

fmgoto
Posts: 76
Joined: Thu Jan 15, 2009 5:01 am
Location: Brasilia, Brazil

Re: running only part of a programme

Postby fmgoto » Wed Sep 08, 2010 4:09 pm

If you are talking about running a few lines of code, you might as well just paste them into the command prompt. That is also a nice shortcut for those who (myself included) are comming from Matlab, VBA, etc.

ben123
Posts: 2
Joined: Fri Mar 16, 2012 7:45 am

Re: running only part of a programme

Postby ben123 » Fri Mar 16, 2012 7:59 am

I'm in the same situation as the OP: just starting out in EViews 7 after many years of MATLAB.
I'm have been given some existing code and am working my way through it. Copying a few lines into a new program window has allowed me to run it in sections which was useful.

Now a few more questions:
1. Is it possible to display the values of string and control variables? I'd like to see the values of variables with names starting "%" or "!" so that I can confirm they are as expected.

2. I found the command "stop". Is it possible to restart code again after this?

3. Are there other useful debug commands that would allow me to step through code?

many thanks in advance

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

Re: running only part of a programme

Postby EViews Gareth » Fri Mar 16, 2012 8:09 am

You can assign program variables to workfile variables (strings or scalars) to make them permanent, or you can use the statusline command to send them to the status bar.

EViews doesn't really have useful debug commands :(

ben123
Posts: 2
Joined: Fri Mar 16, 2012 7:45 am

Re: running only part of a programme

Postby ben123 » Fri Mar 16, 2012 9:15 am

Gareth: many thanks for the prompt reply.
Both are helpful.

The statusline does the job for eyeballing the values.
Can I confirm that the easiest way to turn program variables to workfile variables is find & replace on "%" for "string " and "!" for "scalar "?
Or is there a smarter way?

thanks again

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

Re: running only part of a programme

Postby EViews Gareth » Fri Mar 16, 2012 9:34 am

You can't really do a find and replace on it.

With a program variable you would do something like this:

Code: Select all

!i = 10 'some stuff !i=15
With a workfile object, you'd do it this way:

Code: Select all

scalar i = 10 'some stuff i = 15
Note there is no object declaration in the program variable method, but there has to be in the workfile object method.

Also, using workfile objects rather than program variables isn't always better - for a start if you do anything that switches between workfile pages (or closes a workfile, opens one, etc...), you lose reference to the object. Secondly, re-running the program might be problematic if the workfile objects already exist. Thirdly, it can really clutter up your workfile.


When I'm debugging a program and want to keep track of my program variables, I'll often just create a table object in the workfile, and then, at the appropriate time, fill in a cell of the table with the value in the program variables.


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 2 guests