I want to use CFLOCK to guarantee that the file can be written by one user at a time.
OUTFILE is a static name, it is used in a macro therefore the file name can't be changed to be more random.
I want to write over an existing file, so the action must be WRITE, but that would overwrite what was written before by the current user.
But If I use APPEND, it would contain what was written by a different user.
Here's my code.
Thanks,
Longhorn
<CFSET MAX_LINES = 8>
<CFSET TXTOUTPUT1='#Trim(ContactInfo.first_name)# #Trim(ContactInfo.last_name)#'>
<CFSET TXTOUTPUT2='#Trim(ContactInfo.title)#'>
<CFSET TXTOUTPUT3='#Trim(ProjectInfo.company_name)#'>
<CFSET TXTOUTPUT4='#Trim(AddressInfo.addr_line1)#'>
<CFSET TXTOUTPUT5='#Trim(AddressInfo.addr_line2)#'>
<CFSET TXTOUTPUT6='#Trim(AddressInfo.city)#, TEXAS'>
<CFSET TXTOUTPUT7='#Trim(AddressInfo.zip)#-#Trim(AddressInfo.zip_ext)#'>
<CFSET TXTOUTPUT8='#Trim(ProjectInfo.proj_typ_txt)#'>
<cflock NAME=#OUTFILE# TIMEOUT=120 TYPE="Exclusive">
<CFLOOP INDEX="nLpIndx" FROM="1" TO="#MAX_LINES#">
<CFFILE ACTION="Append"
FILE=#OUTFILE#
OUTPUT=#evaluate("TXTOUTPUT#nLpIndx#"#>
</CFLOOP>
</cflock>
OUTFILE is a static name, it is used in a macro therefore the file name can't be changed to be more random.
I want to write over an existing file, so the action must be WRITE, but that would overwrite what was written before by the current user.
But If I use APPEND, it would contain what was written by a different user.
Here's my code.
Thanks,
Longhorn
<CFSET MAX_LINES = 8>
<CFSET TXTOUTPUT1='#Trim(ContactInfo.first_name)# #Trim(ContactInfo.last_name)#'>
<CFSET TXTOUTPUT2='#Trim(ContactInfo.title)#'>
<CFSET TXTOUTPUT3='#Trim(ProjectInfo.company_name)#'>
<CFSET TXTOUTPUT4='#Trim(AddressInfo.addr_line1)#'>
<CFSET TXTOUTPUT5='#Trim(AddressInfo.addr_line2)#'>
<CFSET TXTOUTPUT6='#Trim(AddressInfo.city)#, TEXAS'>
<CFSET TXTOUTPUT7='#Trim(AddressInfo.zip)#-#Trim(AddressInfo.zip_ext)#'>
<CFSET TXTOUTPUT8='#Trim(ProjectInfo.proj_typ_txt)#'>
<cflock NAME=#OUTFILE# TIMEOUT=120 TYPE="Exclusive">
<CFLOOP INDEX="nLpIndx" FROM="1" TO="#MAX_LINES#">
<CFFILE ACTION="Append"
FILE=#OUTFILE#
OUTPUT=#evaluate("TXTOUTPUT#nLpIndx#"#>
</CFLOOP>
</cflock>