Jump to content

Dosen't print the variable I want..


Recommended Posts

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

Link to comment
Share on other sites

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
Link to comment
Share on other sites

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
Link to comment
Share on other sites

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 :)

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Download and run Folding@Home and you can get something useful done at the same time!

:)

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

I don't think you are correct about the GPU thing. Anyway, try the following example (it occupies 50% CPU time on my system):

Do
    $list = ProcessList()
Until Not ProcessExists("explorer.exe")

The idea is to poll your CPU very fast with no delays.

regarding the GPUs: http://folding.stanford.edu/FAQ-FPI.html

I will try the process polling you suggested. Thanks :-)

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...