HELP CFTRY/CFCATCH/CFDIRECTORY problem

2001-12-12 Thread Kelly Matthews

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/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists



Re: HELP CFTRY/CFCATCH/CFDIRECTORY problem

2001-12-12 Thread Richard Fantini

Well, I would use DirectoryExists(), but if you really want to use
TRY/CATCH, you could do it like this...


CFTRY
 cfdirectory action=create directory=#FILEPATH##SON#\
 CFCATCH type=ANY
  !--- We dont really care ---
 /CFCATCH
/CFTRY

CFTRY
 cfdirectory action=create
directory=#FILEPATH##SON#\#DATEFORMAT(NOW(),'mmddyy')#\
 CFCATCH type=ANY
  !--- We dont really care ---
 /CFCATCH
/CFTRY

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

-Rich



~~
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/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists



RE: HELP CFTRY/CFCATCH/CFDIRECTORY problem

2001-12-12 Thread Kelly Matthews

makes sense and I didn't even know there was a DirectoryExists() shows you
how much I deal with directory stuff. :) 
I will try both although it still is odd that the cftry/cfcatchs were
working
that way.
Thanks!
Kelly

-Original Message-
From: Richard Fantini [mailto:[EMAIL PROTECTED]] 
Sent: Wednesday, December 12, 2001 8:14 PM
To: CF-Talk
Subject: Re: HELP CFTRY/CFCATCH/CFDIRECTORY problem


Well, I would use DirectoryExists(), but if you really want to use
TRY/CATCH, you could do it like this...


CFTRY
 cfdirectory action=create directory=#FILEPATH##SON#\  CFCATCH
type=ANY
  !--- We dont really care ---
 /CFCATCH
/CFTRY

CFTRY
 cfdirectory action=create
directory=#FILEPATH##SON#\#DATEFORMAT(NOW(),'mmddyy')#\
 CFCATCH type=ANY
  !--- We dont really care ---
 /CFCATCH
/CFTRY

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

-Rich




~~
Your ad could be here. Monies from ads go to support these lists and provide more 
resources for the community. http://www.fusionauthority.com/ads.cfm
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists



RE: SOLVED - HELP CFTRY/CFCATCH/CFDIRECTORY problem

2001-12-12 Thread Kelly Matthews

Thanks Richard. DirectoryExists works great. :)
~~
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/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists