String variable and @fileexist

For questions regarding programming in the EViews programming language.

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

loulouviews
Posts: 60
Joined: Wed Mar 11, 2015 2:19 am

String variable and @fileexist

Postby loulouviews » Fri Apr 10, 2015 4:29 am

Hi everybody,

I would like to check wether my database exists or not before (re)creating it.
The name of that db is a string variable which depends of an other string variable and I use the support function @fileexist. My problem is that @fileexist always returns 0, saying the file does not exist even if it's actually existing.

More precisely, my code is as follows

Code: Select all

%name1="name1" %name2="\\...\name2{%name1}.edb" if @fileexist(%name2) then dbdelete %name2 dbcreate %name2 else dbcreate %name2 endif
Does someone have any ideas ? I suspect that it's because EViews is actually not replacing {%name1} by name1 when creating %name2.

Thanks a lot !

Loulouviews

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

Re: String variable and @fileexist

Postby EViews Gareth » Fri Apr 10, 2015 5:23 am

Braces inside quotes will not be replaced. Do this:

Code: Select all

%name1="name1" %name2="\\...\name2"+%name1+".edb"

loulouviews
Posts: 60
Joined: Wed Mar 11, 2015 2:19 am

Re: String variable and @fileexist

Postby loulouviews » Fri Apr 10, 2015 6:10 am

Thanks, it works well !


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 1 guest