Jump to content

Recommended Posts

Posted

Hi.

Can someone please help me make this work? I am tryign to write a very simple endless loop that will keep the CPU busy.

Why does it print 0 all the time in the message box?

$result = 1
$counter = 0
While 1
    Sleep(5)
    $result *= 2
    $counter +=1
    If $counter == 1000 Then
        MsgBox(0, "So far..", $result, 2)
        $counter = 0
    EndIf
WEnd

I wonder how obvious the solution is :-)

10x

Posted

Because of *= and += I guess.

Maybe you mean this?

$result = $result * 2
$counter = $counter + 1
Posted

It's the same thing.

If I try and print the result outside of the IF statement it works fine, and you can also see from the intervals between the MsgBoxes that it does count to 1000 every time.

:-)

Posted (edited)

Hi.

Can someone please help me make this work? I am tryign to write a very simple endless loop that will keep the CPU busy.

Why does it print 0 all the time in the message box?

There is nothing wrong with your script. I don't know what are the limits of AutoIt, but if you change if statement from 1000 to 62 you will get $result value. After 62 times the value change to a negative and then to zero and anything after that get multiply by 0. Edited by Danny35d
AutoIt Scripts:NetPrinter - Network Printer UtilityRobocopyGUI - GUI interface for M$ robocopy command line
Posted

It will of course, but it wont quite be endless anymore..

Maybe I cannot understand what you are trying to do but this would be endless:

While 1
Wend
Posted (edited)

Well for me it didnt show the msgbox inside the If at all, I transfered it out and the code works so just remove the message box and use it.

oh and the limit seems to be 2^62 from what you are saying danny.

erebus he is trying to keep the CPU busy, read his first post.

Edited by Misha
Posted (edited)

Yep - Danny is right. I've tested the script myself and after 62 it returns 0 I guess the resulting number is simply too big. :)

If you change this:

Dim $result = 1e0

you will get a result at $counter = 1000 (which is something e301)... after that it would be impossible ... from Help:

The following table shows the range of values that a variant datatype can hold.

Data Sub-type Range and Notes

Numeric A "double precision" number which is a 15 digit precision number in the range 1.7E-308 to 1.7E+308. (Stored internally as 8 bytes)

String Can contain strings of up to 2 billion characters.

Edited by enaiman

SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script

wannabe "Unbeatable" Tic-Tac-Toe

Paper-Scissor-Rock ... try to beat it anyway :)

Posted

erebus he is trying to keep the CPU busy, read his first post.

*Clap clap*. He can do anything inside a While...Wend loop to keep his CPU busy (like running ANY AU3's function). It was just an example.

Posted

True. I could run ANY AU3 function. I just thought that math would be the most consuming.

As it turns out I was wrong and it's not. The CPU dosent notice this at all.

Any suggestions on how to keep the CPU at 80%-90%?

Posted

Great. Thanks. I will D/L this @ home.

Unfortunately, this does nto help my CPU problem because Folding@Home uses the GPU.

Any other ideas? I am sure there are tools that do just what I ask out there, but I am curious about how to do this with AutoIt.

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
×
×
  • Create New...