Page 1 of 1

String variable and @fileexist

Posted: Fri Apr 10, 2015 4:29 am
by loulouviews
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

Re: String variable and @fileexist

Posted: Fri Apr 10, 2015 5:23 am
by EViews Gareth
Braces inside quotes will not be replaced. Do this:

Code: Select all

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

Re: String variable and @fileexist

Posted: Fri Apr 10, 2015 6:10 am
by loulouviews
Thanks, it works well !