Flow Control

edit

Tags and functions for controlling execution flow, including loops, conditionals, exception handling, timeouts, and thread synchronization

Functions

  • Location()

    Stops execution of the current request and redirect to another location.

  • Sleep()

    Causes the current thread to stop processing for a specified period of time.

  • Throw()

    Throws a developer-specified exception, which can be caught with a cfcatch tag - Application Do not enter another predefined type; types are not generated by CFML applications. If you specify Application, you need not specify a type for cfcatch.

Tags

  • <cfabort>

    Stops processing of a page at the tag location. CFML returns everything that was processed before the cfabort tag. The cfabort tag is often used with conditional logic to stop processing a page when a condition occurs.

  • <cfbreak>

    Used to break out of a cfloop,cfwhile or cfforeach.

  • <cfcase>

    Handle one case of a cfswitch

  • <cfcatch>

    Used only inside a cftry, the cfcatch tag catches and process exceptions.

  • <cfcontinue>

    Used within a cfloop tag. Returns processing to the top of a loop.

  • <cfdefaultcase>

    Defines a default action inside a cfswitch statement, when none of the cfcase condition statements are true.

  • <cfexit>

    Used to: Abort the processing of the currently executing CFML custom tag, exit the template within the currently executing CFML custom tag and re-execute a section of code within the currently executing CFML custom tag

  • <cffinally>

    Used inside a cftry tag. Code in the cffinally block is processed after the main cftry code and, if an exception occurs, the cfcatch code. The cffinally block code always executes, whether or not there is an exception.

  • <cfforward>

    Leads the request to a different page. This tag acts like the tag cflocation except that the relocation is done directly on the server.

  • <cflock>

    Provides two types of locks to ensure the integrity of shared data: Exclusive lock and Read-only lock.

  • <cfloop>

    Looping is a very powerful programming technique that lets you repeat a set of instructions or display output repeatedly until one or more conditions are met. cfloop supports five types of loops.

  • <cfrethrow>

    Rethrows the currently active exception. Preserves the exception's cfcatch.type and cfcatch. agContext information.

  • <cfretry>

    used to jump from a catch block, back to the beginning of the try block.

  • <cfreturn>

    Returns result values from a component method. Contains an expression returned as result of the function.

  • <cfsleep>

    Pauses the execution of the page for a given interval

  • <cfswitch>

    Used with cfcase and cfdefaultcase. Evaluates a passed expression and passes control to the cfcase tag that matches the expression result. You can optionally code a cfdefaultcase tag, which receives control if there is no matching cfcase tag value.

  • <cfthrow>

    The cfthrow tag raises a developer-specified exception

  • <cftimeout>

    Whilst similar to a tag-thread, code run inside the tag-timeout executes within the same scope as the current page

  • <cftry>

    Used with one or more cfcatch tags, the cftry tag lets you catch and process exceptions in CFML pages.

  • <cfwhile>

    Simplification of the tag cfloop-condition, analog to the cfscript &quot;while&quot; loop.

Guides

  • Loop Labels

    Lucee supports labels for all loop tags and statements, allowing you to control the flow of nested loops more precisely.

  • Request Timeout

    Learn how to use request timeout correctly with Lucee.

  • Retry

    This document explains how to use retry functionality with some simple examples.

  • Tag Islands

    Tag islands allow you to switch into tag mode from inside cfscript

  • Timeout

    Learn how to use the tag in Lucee. This guide demonstrates how to define a timeout specific to a code block, handle timeouts with a listener, and handle errors within the timeout block.