Are there any plans to improve EViews' variable handling? Right now it seems that the only way to pass variables assigned in a parent program to child programs is by saving the variables as objects in a workfile or by using the include command. However, both these methods have the unfortunate side effect that variable changes in children are passed back to parents.
Ideally, children would inherit variables declared in their parents. Variables declared in children would by default not be accessible in their parents, but it would be possible to specify upon declaration whether a variable is passed back to the parent (and/or ancestors).
Taking the current variable handling together with the fact that it is not possible to use variables in the include command, programming in EViews is starting to require complex/creative solutions to operations that should be relatively straightforward.
Variable handling
Moderators: EViews Gareth, EViews Moderator, EViews Jason, EViews Matt
-
EViews Gareth
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13604
- Joined: Tue Sep 16, 2008 5:38 pm
Re: Variable handling
Have you tried using Exec rather than Include?
Re: Variable handling
Indeed I have. Using the exec command at least leaves variables declared in a parent unaltered after the execution of a child. But variables declared in the parent are not inherited by the child, which seems odd to me. Moreover, it is, to my best knowledge, not possible to force variables declared in children to be passed back to parents.
But just now I realized that my frustration might be ill-conceived. (Which might have been what you were trying to hint with your reply about the exec command.) When programming in e.g. Python (which is a very pleasant experience), variables are handled in much the same way as in EViews. That is, variables can indeed be passed from parent to child if they are specified as arguments when calling the child (in EViews with the run or exec commands).
However, this begs the question, (how) can I pass a variable back from a child to its parent (and/or ancestors)?
But just now I realized that my frustration might be ill-conceived. (Which might have been what you were trying to hint with your reply about the exec command.) When programming in e.g. Python (which is a very pleasant experience), variables are handled in much the same way as in EViews. That is, variables can indeed be passed from parent to child if they are specified as arguments when calling the child (in EViews with the run or exec commands).
However, this begs the question, (how) can I pass a variable back from a child to its parent (and/or ancestors)?
Re: Variable handling
On a side note, it is very bad that the two dialog boxes in the code below read the same.
Indeed, the first should read "abc" (as it does). But the second one should be blank. That is, loop variables should not be accessible outside of the loop.
Code: Select all
for %1 %2 %3 "a b c"
@uiprompt(%1+%2+%3)
next
@uiprompt(%1+%2+%3)-
EViews Gareth
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13604
- Joined: Tue Sep 16, 2008 5:38 pm
Re: Variable handling
By passing them in as arguments.Indeed I have. Using the exec command at least leaves variables declared in a parent unaltered after the execution of a child. But variables declared in the parent are not inherited by the child, which seems odd to me. Moreover, it is, to my best knowledge, not possible to force variables declared in children to be passed back to parents.
But just now I realized that my frustration might be ill-conceived. (Which might have been what you were trying to hint with your reply about the exec command.) When programming in e.g. Python (which is a very pleasant experience), variables are handled in much the same way as in EViews. That is, variables can indeed be passed from parent to child if they are specified as arguments when calling the child (in EViews with the run or exec commands).
However, this begs the question, (how) can I pass a variable back from a child to its parent (and/or ancestors)?
-
EViews Gareth
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13604
- Joined: Tue Sep 16, 2008 5:38 pm
Re: Variable handling
Doesn't seem "bad" to me. It is just the way the language is structured.On a side note, it is very bad that the two dialog boxes in the code below read the same.Indeed, the first should read "abc" (as it does). But the second one should be blank. That is, loop variables should not be accessible outside of the loop.Code: Select all
for %1 %2 %3 "a b c" @uiprompt(%1+%2+%3) next @uiprompt(%1+%2+%3)
It would be a terrible idea to change that behaviour.
Re: Variable handling
Could you give me an example?By passing them in as arguments.
You are probably right, if not else then for backward compatibility. It's just that I have not seen this behaviour in any other language. To me, it seems like an odd choice to begin with.It would be a terrible idea to change that behaviour.
-
EViews Gareth
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13604
- Joined: Tue Sep 16, 2008 5:38 pm
Re: Variable handling
Could you give me an example?By passing them in as arguments.
Ah, I read your first point a little too early after waking up. You can pass from parent to child as argument, but you can't pass from child to parent that way. You can only do that through workfile objects.
You are probably right, if not else then for backward compatibility. It's just that I have not seen this behaviour in any other language. To me, it seems like an odd choice to begin with.It would be a terrible idea to change that behaviour.
Run the following in Visual Basic (I did this in VB for Excel, hence the cell reference):
Code: Select all
For j = 1 To 10 Step 1
Next j
ActiveCell.FormulaR1C1 = j
Re: Variable handling
The VB behavior was news to me. Thank you for enlighting me! And please pardon my rash judgment.
But could you give me an example of how I in EViews can pass a variable back to a parent from a child that has been called with the exec command?
But could you give me an example of how I in EViews can pass a variable back to a parent from a child that has been called with the exec command?
-
EViews Gareth
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13604
- Joined: Tue Sep 16, 2008 5:38 pm
Variable handling
I misspoke. The only way to go from child to parent is through a workfile object.
Who is online
Users browsing this forum: No registered users and 2 guests
