Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Oct 2011
    Posts
    6
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Question How to loop to run a piece of code every second?

    Can anyone show me a simple Coldfusion code to loop to run a piece of code every second? Thank you so much.

  • #2
    Regular Coder
    Join Date
    Feb 2009
    Location
    NJ, USA
    Posts
    476
    Thanks
    2
    Thanked 70 Times in 69 Posts
    Not sure why you'd want to, but:
    Code:
    <cfloop from="1" to="5" index="i">
      <cfoutput>#i#</cfoutput>
      <cfset sleep( 1000 )>  <!--- Sleep for 1 second (1000ms) --->
    </cfloop>
    -Greg

  • #3
    Regular Coder
    Join Date
    Feb 2009
    Location
    NJ, USA
    Posts
    476
    Thanks
    2
    Thanked 70 Times in 69 Posts
    Btw, you'll need ColdFusion 8 or higher for that.

    -Greg


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •