TomWolfstein Posted May 9, 2007 Share Posted May 9, 2007 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 More sharing options...
erebus Posted May 9, 2007 Share Posted May 9, 2007 Because of *= and += I guess. Maybe you mean this? $result = $result * 2 $counter = $counter + 1 Link to comment Share on other sites More sharing options...
TomWolfstein Posted May 9, 2007 Author Share Posted May 9, 2007 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. :-) Link to comment Share on other sites More sharing options...
erebus Posted May 9, 2007 Share Posted May 9, 2007 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) Link to comment Share on other sites More sharing options...
TomWolfstein Posted May 9, 2007 Author Share Posted May 9, 2007 It will of course, but it wont quite be endless anymore.. Link to comment Share on other sites More sharing options...
Danny35d Posted May 9, 2007 Share Posted May 9, 2007 (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 May 9, 2007 by Danny35d AutoIt Scripts:NetPrinter - Network Printer UtilityRobocopyGUI - GUI interface for M$ robocopy command line Link to comment Share on other sites More sharing options...
erebus Posted May 9, 2007 Share Posted May 9, 2007 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 Link to comment Share on other sites More sharing options...
Misha Posted May 9, 2007 Share Posted May 9, 2007 (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 May 9, 2007 by Misha Link to comment Share on other sites More sharing options...
enaiman Posted May 9, 2007 Share Posted May 9, 2007 (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 May 9, 2007 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 More sharing options...
erebus Posted May 9, 2007 Share Posted May 9, 2007 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 More sharing options...
TomWolfstein Posted May 15, 2007 Author Share Posted May 15, 2007 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%? Link to comment Share on other sites More sharing options...
PsaltyDS Posted May 15, 2007 Share Posted May 15, 2007 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 More sharing options...
TomWolfstein Posted May 16, 2007 Author Share Posted May 16, 2007 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 More sharing options...
erebus Posted May 16, 2007 Share Posted May 16, 2007 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. Link to comment Share on other sites More sharing options...
TomWolfstein Posted May 16, 2007 Author Share Posted May 16, 2007 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 More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now