Results 1 to 3 of 3

Thread: Count up to 1000 and reset function?

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2003
    Posts
    830

    Count up to 1000 and reset function?

    I apoligize for double posting this here and in the C++ forum, but I am in one of those binds that we tend to get into and this would seem to be a simple thing that could be done in either C# or C++.

    I have had a course in C#, but am somewhat limited. I need some kind of loop that will cause a variable to increase in value. Here is what I am trying to do...

    Believe it or not, I need to create a webpage that will have textbox on it. This text box will show the RPM's of a machine. So the webpage is an interface to the machine. I am able to call C++ functions from the webpage because of the hardware I am using. Right now I just to to "simulate" the RPM's by using a C++ function. I just want a function that counts up repeatedly and maybe resets after 1000 RPM's. Once I have a function like that I can call it from the webpage to check the current value. I intend to call it every second or so.

    To shorten the above...I just need a short function that will count to 1000 and then reset. I know this should be easy for me, but.....

    Thanks!

  2. #2
    Lively Member Bolerophone's Avatar
    Join Date
    Dec 2003
    Location
    Himalayas
    Posts
    123
    I am puzzld why you want to do this but still here is the code:


    Code:
    for(i=0; i<1000; i++)
    {
       //your code here
    
       if (i=999)
        {
          i = 0;
          // reset the counter
          // however it will go in an infinite 
        }
    }
    Rater i would suggest you to use:


    Code:
    for(i=0; i<1000; i++)
    {
       //your code here
    
    } 
    
    if (i=999)
    {
          i = 0;
          // reset the counter
    }
    -Bolerophone-

  3. #3
    Lively Member Bolerophone's Avatar
    Join Date
    Dec 2003
    Location
    Himalayas
    Posts
    123
    what I meant was:

    if (i=999)
    {
    i = 0;
    // reset the counter
    // however it will go in an infinite
    }

    if (i=999)
    {
    i = 0;
    // reset the counter
    // however it will go in an infinite loop
    }

Posting Permissions

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



Click Here to Expand Forum to Full Width