Question

I am going through the following code:

<cfset x_dt = LSDateFormat(Now(), 'yyyy-mm-dd') &" "& 
                  LSTimeFormat(Now(), 'HH:mm:ss')>

<cfif VerboseDebug gt 0>x_dt = #x_dt#<BR><cfflush></cfif> 

I didn't understand the usage of <cfflush> here. Wondering since I haven't defined interval here, how does it works here?

I read the documentation.

Was it helpful?

Solution

Normally when you run a CF script, the server does not return any output to the client until after all of the CF code has executed. CFFlush allows you to return output as it is becomes available, rather than waiting until the end. Useful in cases where you want to display results incrementally, such as for some sort of progress indicator.

I didn't understand the usage of here. Wondering since I haven't defined interval here, how does it works here?

When you do not specify an interval, CF automatically flushes any new output when you invoke the tag. From the docs:

The first occurrence of this tag on a page sends back the HTML headers and any other available HTML. Subsequent cfflush tags on the page send only the output that was generated after the previous flush.

It looks like your code is using that technique for debugging purposes. When that line of code is reached, the server returns that date string to the client if VerboseDebug is enabled.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top