Page 1 of 1

@wfindnc - bug?

Posted: Thu Dec 17, 2015 2:47 am
by tvonbrasch
Hi

try and run the following code where you open the attached workfile:

close @all
%dir=@runpath
cd %dir'"C:\tvb\articles\labour_services\eviews"

wfopen wfindnc

for !i=570 to 571

%eq=kvartstroll.@line(!i)

if @isobject("test")=1 then
delete test
endif
model test
test.append {%eq}
'generate text file with equations where endogenous variable has already been defined
text problemequations


'TRY TO UNCOMMENT THE FOLLOWING LINE:
scalar a_{!i}_=@wfindnc(kvarts.@endoglist,@trim(test.@endoglist))
'-------------------------------------------------------------------------------------------

if @wfindnc(kvarts.@endoglist,@trim(test.@endoglist)) = 0 then
kvarts.append {%eq}
else
problemequations.append {%eq}
problemequations.append {!i}
endif

next


This creates a blank textfile problemequations. However, if you comment out the scalar a_{!i}_.... line and rerun the program, the textfile problemequations is filled with some text, for some reason. Do you understand what is causing this?

THomas

Re: @wfindnc - bug?

Posted: Thu Dec 17, 2015 10:32 am
by EViews Gareth
We shall investigate.

Re: @wfindnc - bug?

Posted: Thu Dec 17, 2015 11:26 am
by EViews Gareth
Looks like it is to do with whether the model has been compiled or not - calling @endoglist before compiling isn't going to work very well.

If you modify your code to be:

Code: Select all

for !i=570 to 571 %eq=kvartstroll.@line(!i) if @isobject("test")=1 then delete test endif model test test.append {%eq} 'generate text file with equations where endogenous variable has already been defined text problemequations kvarts.update test.update 'TRY TO UNCOMMENT THE FOLLOWING LINE: 'scalar a_{!i}_=@wfindnc(kvarts.@endoglist,@trim(test.@endoglist)) '------------------------------------------------------------------------------------------- if @wfindnc(kvarts.@endoglist,@trim(test.@endoglist)) = 0 then kvarts.append {%eq} else problemequations.append {%eq} problemequations.append {!i} endif next
it should work as expected.

Re: @wfindnc - bug?

Posted: Fri Dec 18, 2015 6:21 am
by tvonbrasch
Excellent, that worked!

thanks
t