Jump to content
Sign in to follow this  
TomWolfstein

Dosen't print the variable I want..

Recommended Posts

TomWolfstein

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

Share this post


Link to post
Share on other sites
erebus

Because of *= and += I guess.

Maybe you mean this?

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

Share this post


Link to post
Share on other sites
TomWolfstein

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.

:-)

Share this post


Link to post
Share on other sites
erebus

A For...Next loop wouldn't do the job?

For $i = 1 To 1000
    Sleep(5)
    $i = $i + 1
Next

MsgBox(0, "The End", $i)

Share this post


Link to post
Share on other sites
TomWolfstein

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

Share this post


Link to post
Share on other sites
Danny35d

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

Share this post


Link to post
Share on other sites
erebus

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

Share this post


Link to post
Share on other sites
Misha

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

Share this post


Link to post
Share on other sites
enaiman

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

Share this post


Link to post
Share on other sites
erebus

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.

Share this post


Link to post
Share on other sites
TomWolfstein

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%?

Share this post


Link to post
Share on other sites
PsaltyDS

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

Share this post


Link to post
Share on other sites
TomWolfstein

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.

Share this post


Link to post
Share on other sites
erebus

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.

Share this post


Link to post
Share on other sites
TomWolfstein

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

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
Sign in to follow this  

×