Problem with include in if-statement

For notifying us of what you believe are bugs or errors in EViews.
Please ensure your copy of EViews is up-to-date before posting.

Moderators: EViews Gareth, EViews Moderator

pelleenglund
Posts: 24
Joined: Fri Sep 16, 2016 6:35 am

Problem with include in if-statement

Postby pelleenglund » Thu Nov 17, 2016 5:07 am

Hello!

I sometimes use "Include" to include another EViews-program in a main EViews-program. It works just fine except when you use it in an if-statement, for example like this

If ..... Then
Include "C:\Temp\Example.prg"
EndIf

Then you get the error message "Endif found outside of loop or IF statement". The code will run without error if you include it without putting it in the if-statement, and it works fine if you change "Include" to "Run" or "Exec" instead.

I just wonder if this may be a bug?

Best regards,
Pelle

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

Re: Problem with include in if-statement

Postby EViews Gareth » Thu Nov 17, 2016 5:17 am

Probably just the way you have the included program written.

It is easy to show that in general it works ok:

myfile.prg:

Code: Select all

series a = @nrnd


parent program:

Code: Select all

create m 1990 2000
if 3>2 then
include myfile.prg
endif
Follow us on Twitter @IHSEViews

pelleenglund
Posts: 24
Joined: Fri Sep 16, 2016 6:35 am

Re: Problem with include in if-statement

Postby pelleenglund » Thu Nov 17, 2016 6:20 am

Well, I have tried to write the code in different ways (for example with and without "" around the program that should be included) but it doesn't work. Thanks anyway, and it is okey since I can always use "Run" instead.

Best regards,
Pelle

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

Re: Problem with include in if-statement

Postby Alfred123 » Thu Jul 22, 2021 7:59 am

EViews Gareth wrote:Probably just the way you have the included program written.

It is easy to show that in general it works ok:

myfile.prg:

Code: Select all

series a = @nrnd


parent program:

Code: Select all

create m 1990 2000
if 3>2 then
include myfile.prg
endif


Dear Gareth, I have the same problem, and I don't understand your point here. How can we use "if 3>2 then" to make the child program work?

Even it works, I think you can't just use this example to prove that there's no such problem with the "include" command.

I do believe there is a very annoying bug in the "include" command. Hope the EViews team can fix it as soon as possible.

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

Re: Problem with include in if-statement

Postby EViews Gareth » Thu Jul 22, 2021 8:35 am

Can you provide an example that doesn’t work?

I’m not suggesting there isn’t an issue, just that the issue is impossible to diagnose without having information on what the issue is.
Follow us on Twitter @IHSEViews

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

Re: Problem with include in if-statement

Postby Alfred123 » Thu Jul 22, 2021 6:43 pm

EViews Gareth wrote:Can you provide an example that doesn’t work?

I’m not suggesting there isn’t an issue, just that the issue is impossible to diagnose without having information on what the issue is.


Dear Gareth, thanks for the quick reply.

Just now, I had tried some relatively simple sample parent-child programs, they do work well.

However, my own actual parent-child programs are not.

On the one hand, they are a little longer, on the other hand, they are confidential. So I can't post them directly here.

Can I email my programs only to you, and hope you can fix the problem. And please keep my programs confidential. Thank you very much.

At here, I can give a brief illustration of the problem:

In my parent program, I declare a little complex dialog box using the @uidialog command.
In my child program, I use the string/numerical variables input or declared in the parent program to run many commands. The big structure of my parent program is like this:

if [some conditions] then
[...some more commands...]
include child-program
endif

This structure doesn't work, and it prompts a dialog and tells me: "Endif found outside of loop or IF statement."

However, when I change the structure like this, it works:

if [some conditions] then
[...some more commands...]
endif
include child-program

It works, but it also brings another problem: I use the first structure because I want to tell my program that when I press the "Cancel" button on the dialog box, the whole program will stop and the child program will not be executed. However, when I use the second structure to replace the first one, even I press the "Cancel" button, the child program will still be executed.

Above all is my problem. And actually, this is already the second time that I find this bug in the "include" command.

Anyway, I am a fan of the EViews, so I do hope the EViews team could fix it for me.

If you need my actual programs, I can email them only to you, Gareth. AND PLEASE KEEP THEM CONFIDENTIAL FOR ME. Thank you.

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

Re: Problem with include in if-statement

Postby Alfred123 » Sat Jul 24, 2021 6:34 am

EViews Gareth wrote:Can you provide an example that doesn’t work?

I’m not suggesting there isn’t an issue, just that the issue is impossible to diagnose without having information on what the issue is.


Dear Gareth,

I revised my program structure, and it seems to work well now.

So, now I believe it may be the problem of the program structure rather than the "include" command bug.

Thanks.

EViews Matt
EViews Developer
Posts: 560
Joined: Thu Apr 25, 2013 7:48 pm

Re: Problem with include in if-statement

Postby EViews Matt » Mon Jul 26, 2021 10:27 am

Hello,

Just a little extra information about include statements that might help in the future, such statements are functionally equivalent to copying the EViews code from the included file into the including file at the inclusion point. Consequently, the program will be ill-formed if the included file contains statements that are not allowed to appear within if statements, such as subroutine definitions. This is just one of the features that differentiates include statements from the similar run/exec statements.

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

Re: Problem with include in if-statement

Postby Alfred123 » Tue Jul 27, 2021 9:52 pm

EViews Matt wrote:Hello,

Just a little extra information about include statements that might help in the future, such statements are functionally equivalent to copying the EViews code from the included file into the including file at the inclusion point. Consequently, the program will be ill-formed if the included file contains statements that are not allowed to appear within if statements, such as subroutine definitions. This is just one of the features that differentiates include statements from the similar run/exec statements.


Thanks Matt!


Return to “Bug Reports”

Who is online

Users browsing this forum: No registered users and 21 guests