how to drop a program variable

For questions regarding programming in the EViews programming language.

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

zezza
Posts: 23
Joined: Fri May 28, 2010 5:27 am

how to drop a program variable

Postby zezza » Fri Aug 13, 2021 7:35 am

I had the following problem, when running programs in a sequence. Let's say that in the first file of the sequence I have:

Code: Select all

for !i = 1 to 200
...
next

and in the second file in my sequence I have the command

Code: Select all

import %myfile range=IMS1!I16:j198 ...


when Eviews gets to the second program, it substitutes !i with the next value from the previous loop, so that it becomes.

Code: Select all

import %myfile range=IMS120116:j198 ...


Is there a way to drop !i after it has been used in the loop?

Meanwhile, I solved the issue by changing !i to !linenumber in the first loop

Thank you

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

Re: how to drop a program variable

Postby EViews Matt » Fri Aug 13, 2021 9:22 am

Hello,

I'm afraid there isn't a way to undefine a variable such that it won't trigger substitution later in an EViews program. However, since you're running multiple programs sequentially, you can isolate the individual programs' variables from one another by using "exec" instead of "run" or "include". Program variables are not shared across an exec invocation, so variables defined in the invoking program do not appear in the invoked program and vice versa. It's an all or nothing proposition, either all variables are shared (run/include) or none are shared (exec), you cannot control sharing on a variable-by-variable basis.


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 26 guests