Hello,
First time poster. I have an issue with the support command @fileexist in a loop. I need to check if a database exists before I (re)create it, but it seems like my code interprets @fileexist as = 0 and overwrites existing databases at all times. My code:
%blu2011 = "path\blu2011.edb"
%blu2012 = "path\blu2012.edb"
%blu2013 = "path\blu2013.edb"
%blu2014 = "path\blu2014.edb"
for !j = 1 to 4
if @fileexist(%blu201{!j})=0 then
dbcreate blu201{!j}
endif
next
Anyone see the problem here? Would be most grateful for any help.
Best, Matt
@fileexist in if loop
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: @fileexist in if loop
Try:
Code: Select all
for !j=1 to 4
%fileref = "%blu201"+@str(!j)
if @fileexist({{%fileref}})=0 then
...
-
jaghetermattis
- Posts: 7
- Joined: Tue Apr 21, 2015 5:48 am
Re: @fileexist in if loop
Thank you Gareth, much appreciated. However that gives me a "Syntax error in control statement". Does that give you any leads?
I'm using Eviews 8 btw.
I'm using Eviews 8 btw.
-
EViews Gareth
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13604
- Joined: Tue Sep 16, 2008 5:38 pm
Re: @fileexist in if loop
Code: Select all
if @fileexist({%fileref})=0 then
-
jaghetermattis
- Posts: 7
- Joined: Tue Apr 21, 2015 5:48 am
Re: @fileexist in if loop
Worked like a charm - thank you so much Gareth.
Who is online
Users browsing this forum: No registered users and 2 guests
