%if exists expressions in .pcf files

I am trying to create an expression in a .pcf file which looks to see if a folder exists and if it does, sets the project data variable to it.  If it fails to find the folder, th eproject data variable should be set to another folder.

I am using the _USTN_PROJECTNAME variable as our project folders are named after these and the expression I am trying to use is as follows:

%if exists (P:\3210\_CAD\$(_USTN_PROJECTNAME)\13-rit\)

_USTN_PROJECTDATA = P:\3210\_CAD\$(_USTN_PROJECTNAME)\13-rit\

%else

_USTN_PROJECTDATA = C:\3210\_CAD\$(_USTN_PROJECTNAME)\13-rit\

%endif

What is happening is that the expression fails to detect the folder in the %if statement even though it exists and goes instead to the folder on C:.  If I replace the %if statement with a hard coded location such as

%if exists (P:\3210\_CAD\ProjectXXX\13-rit\)

_USTN_PROJECTDATA = P:\3210\_CAD\$(_USTN_PROJECTNAME)\13-rit\

%else

_USTN_PROJECTDATA = C:\3210\_CAD\$(_USTN_PROJECTNAME)\13-rit\

%endif

Then it works perfectly but I lose the ability to change the folder location through the _USTN_PROJECTNAME variable!!

Has anyone any tips about what I could be doing wrong?

/James

AECOsim Building Designer Select Series 3