Jump to content
MrCheese

math related if statement

Recommended Posts

MrCheese

hi all,

Dumb question, but say I have a loop:

dim $i
Do
    sleep(1000)
    
    if $i = ; how do i do a function that enters this IF statement every 10 loops?
        ; do stuff every 10
    EndIf

    
Until $i = 100

 

- what commands in the if statement do I need to use to make it pass, and on every 10th loop, it enters the if statement. ?

 

Thanks

Share this post


Link to post
Share on other sites
Torvig1

I reckon you could probaly make a repeat func in the loop that will repeat 10 times then do your if statement and then because its in the loop it will do it agian.

Does that make sense?

Share this post


Link to post
Share on other sites
Jos

@MrCheese,

You aren't incrementing $i so the posted script makes no sense!

As to you question: just make an if like this:

For $i = 1 to 100
    if mod($i,10) = 0 then
        ConsoleWrite($i & @CRLF)
    EndIf
Next

Jos


Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
MrCheese

oh yeah forgot to add in the increment :P

it was in my script....

as for your statement, thats great! thanks for that!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Similar Content

    • MrCheese
    • JohnNash
      By JohnNash
      I've seen some weird behavior in my code (I log almost everything).

       
         While 1       $WaitingTime = TimerDiff($wtTimer)       sleep(300)       $Data = TCPRecv($MainSocket, $MaxLength)       _FileWriteLog($LogFolder&"info.log", "Wait for answer that Server is ready for step 21")                            If $Data = "ByeBye" Then                                        _FileWriteLog($LogFolder&"info.log", "Server tells me to shutdown")                                        Terminate()                  ElseIf $Data = "Step 20 Finished on Server" Then                                         _FileWriteLog($LogFolder&"info.log", "Server answers it is ready for step 21")                                         ExitLoop                ElseIf $WaitingTime>4000 Then                                          _FileWriteLog($LogFolder&"info.log", "No Answer, we still continue" &$Data)                                          ExitLoop             EndIf    WEnd    _FileWriteLog($LogFolder&"info.log", "Left the WhileLoop")  
       
      And my logs show this:
       

      2016-10-24 00:52:39 : Wait for answer that Server is ready for step 21

      2016-10-24 00:52:39 : (Logline from completely different loop)
      2016-10-24 00:52:39 : (Logline from completely different loop)
      2016-10-24 00:52:39 : (Logline from completely different loop)
      2016-10-24 00:52:39 : (Logline from completely different loop)

      2016-10-24 00:52:40 : Wait for answer that Server is ready for step 21
      2016-10-24 00:52:40 : Server answers it is ready for step 21
       
      How can this happen? (If there was a "Left the Whileloop" log in between I could imagine it could happen... but now?
      I thought AutoIT was singlethreaded...
       
       
       
       
       
    • jrsofsd
      By jrsofsd
      RunningStats calculates running (moving) statistics: Standard Deviation, Variance, and Mean . The single function _RunningStats(), queries, clears, restores, or adds to the running statistics.
      Example.au3 adds 7 samples of data to running statistics and displays the results using _ArrayDisplay().
      Example-Persistent-Storage.au3 adds the first 6 samples to the running statistics and stores the results in an INI file. The data is read from the INI file and restored to the running statistics. The 7th sample is added and the results displayed, matching the results from Example.au3.
      Credits: John D. Cook for his article "Accurately computing running variance" at http://www.johndcook.com/blog/standard_deviation/
      RunningStats.zip
    • scintilla4evr
      By scintilla4evr
      I started writing this UDF a while ago, so I decided to share it here.
      This is an UDF full of advanced mathematical functions. It allows to work with primes, create number sequences, interpolate, calculate values of functions like Riemann zeta.
      Full list of functions:
       
      Changelog:
      Download
×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.