Ok here's the scenario.
We have to place a file into a directory structure.
The end result would be
D:\FILES\SONNUMBER\TODAYSDATE\SOCIALSECURITYNUMBER\ACTUALFILE.TXT

These folders SONNUMBER, TODAYSDATE, and SOCIALSECURITYNUMBER would be
created on the fly if they aren't already there.

Most of the time the SONNUMBER (which is actually 1 of 600+ numbers) will
already be there.  TODAYSDATE would be there the first time I file comes
through that day for that SONNUMBER and 
SOCIALSECURITYNUMBER will always be new.

Now if I create a <CFDIRECTORY> tag to create the SONNUMBER folder and it
already exists it of course throws and error, which it should. So using
CFTRY I did the following:

<CFTRY> 
<cfdirectory action="create" directory="#FILEPATH##SON#\">      
<cfdirectory action="create" directory="#FILEPATH##SON#\#DATEFORMAT(NOW(),
'mmddyy')#\"> 
<cfdirectory action="create" directory="#FILEPATH##SON#\#DATEFORMAT(NOW(),
'mmddyy')#\#SSN#\"> 
<CFCATCH type="ANY">
<cfdirectory action="create" directory="#FILEPATH##SON#\#DATEFORMAT(NOW(),
'mmddyy')#\"> 
<cfdirectory action="create" directory="#FILEPATH##SON#\#DATEFORMAT(NOW(),
'mmddyy')#\#SSN#\"> 
</CFCATCH>      
<CFCATCH type="Any">
<cfdirectory action="create" directory="#FILEPATH##SON#\#DATEFORMAT(NOW(),
'mmddyy')#\#SSN#\"> </CFCATCH> 
<CFCATCH type="Any">
An Error has occurred
</CFCATCH>
</CFTRY> 

So if it gets an error on the first set (meaning it can't create the SON
folder) then it goes to the next cfcatch and tries to start from the DATE
folder. If that throws an error that it exists it tries the last one which
is simply creating the SocialSecurityNumber folder.

However if I run this code and the SON folder does already exist but the
date and socialsecurity number do not it skips the next 2 cfcatchs and goes
to the last one "an error has occurred". To make sure it was doing that I
removed the LAST CFCATCH and then it would try to run the last one skipping
the one before it. If I removed that LAST one then it would finally work. Am
I just missing soemthing here with the way CFTRY and CFCATCH work? I figured
if it errored on the first process it would automatically try the next one
NOT the last one.

Any suggestions??
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Get the mailserver that powers this list at http://www.coolfusion.com
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to