A little bug in the commands "include" and "exec"

For questions regarding programming in the EViews programming language.

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

Alfred123
Posts: 31
Joined: Fri Jul 19, 2019 8:00 pm

A little bug in the commands "include" and "exec"

Postby Alfred123 » Thu Apr 15, 2021 10:34 pm

Hi all,

I found a little bug in the commands "include" and "exec".

Below are two codes named "testa1" and "testa2" repectively:
The first one "testa1" is:

Code: Select all

%freq = "q"
exec .\testa2
'include testa2


The second one "testa2" is:

Code: Select all

if %freq = "q" then
   wfcreate(wf=evp, page=simcast) {%freq} 1970q1 2050q4
else
   wfcreate(wf=evp, page=simcast) {%freq} 1970m01 2050m04
endif


When I use the "exec" command to execute the testa2.prg, EViews cannot work and tells me the sentence of "wfcreate(wf=evp)..." is incomplete. I believe it means the "%freq" I declared in the testa1.prg cannot transmit into the testa2.prg.

When I use the "include" command to execute the testa2.prg, EViews works perfectly. However, based on the programming instruction about the "include", the "%freq" I declared in the testa1.prg should not transmit into the testa2.prg.

I would like to ask why?

If I want to transmit a program variable in the parent program to the child program, which command should I use?

Thanks!

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

Re: A little bug in the commands "include" and "exec"

Postby EViews Gareth » Fri Apr 16, 2021 6:04 am

Not a bug - that’s how they are supposed to work. Include inherits variables, exec doesn’t.
Follow us on Twitter @IHSEViews

Alfred123
Posts: 31
Joined: Fri Jul 19, 2019 8:00 pm

Re: A little bug in the commands

Postby Alfred123 » Sat Apr 17, 2021 8:34 am

EViews Gareth wrote:Not a bug - that’s how they are supposed to work. Include inherits variables, exec doesn’t.


Thank you for the reply. Maybe you are right.

However, the Command and Programming Reference doesn't say like that:
Note that in contrast to using exec to execute another program, include simply inserts the child program into the parent. This insertion is done prior to executing any lines in either program. One important consequence of this behavior is that any program variables that are declared in the parent program will not be available in the child/included program, even if they are declared prior to the include statement.


This cited from the Command and Programming Reference of the EViews version 11.

So, I mean, if the command is right, then the reference is wrong.

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

Re: A little bug in the commands "include" and "exec"

Postby EViews Gareth » Sat Apr 17, 2021 8:27 pm

Ouch, that should be rewritten.

A better explanation is here:

http://eviews.com/download/whitepapers/ExecInclude.pdf
Follow us on Twitter @IHSEViews

Alfred123
Posts: 31
Joined: Fri Jul 19, 2019 8:00 pm

Re: A little bug in the commands

Postby Alfred123 » Sat Apr 17, 2021 10:19 pm

EViews Gareth wrote:Ouch, that should be rewritten.

A better explanation is here:

http://eviews.com/download/whitepapers/ExecInclude.pdf


Thank you very much.

I like EViews very much and I hope it will be better in the future.

Especially, I STRONGLY suggest the EViews developers can consider adding more beautiful themes in the program editor. Such as, change the background color of the editor and the characters.

Thanks again.


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 36 guests