HelloIDistance Posted June 10, 2004 Author Posted June 10, 2004 That's the question you should answer first...I'm not trying to do anything really. I am just messing around with this script trying to figure out how to do it right. There's really no purpose in the script.
pekster Posted June 10, 2004 Posted June 10, 2004 Okay, please start by telling me what you want it to do. Keep it as simple as you can, because you don't want to get complex when you're designing something. For example, come up with something that looks like this:Step 1: I want to start a timer at 0 secondsStep 2: As long as the timer is less than 10 seconds, Do steps 3-5Step 3: Send some stuffStep 4: Show a tooltipStep 5: Send some more stuffStep 5.5: remember, this is the timer, so you'll go to step 3 unles timer is larger than 10 secondsStep 6: Show a message box that 10 seconds has elapsedStep 7: Start over at step 1Once you do that, we can better understand what you are trying to do and show you a simple example to help you see how you could do that. [font="Optima"]"Standing in the rain, twisted and insane, we are holding onto nothing.Feeling every breath, holding no regrets, we're still looking out for something."[/font]Note: my projects are off-line until I can spend more time to make them compatable with syntax changes.
SlimShady Posted June 10, 2004 Posted June 10, 2004 Okay, please start by telling me what you want it to do. Keep it as simple as you can, because you don't want to get complex when you're designing something. For example, come up with something that looks like this:Step 1: I want to start a timer at 0 secondsStep 2: As long as the timer is less than 10 seconds, Do steps 3-5Step 3: Send some stuffStep 4: Show a tooltipStep 5: Send some more stuffStep 5.5: remember, this is the timer, so you'll go to step 3 unles timer is larger than 10 secondsStep 6: Show a message box that 10 seconds has elapsedStep 7: Start over at step 1Once you do that, we can better understand what you are trying to do and show you a simple example to help you see how you could do that.He's right. Give us a detailed list with the things you want accomplish.@pekster: BTW, you're a really helpful person.
pekster Posted June 10, 2004 Posted June 10, 2004 (edited) I'm not trying to do anything really. I am just messing around with this script trying to figure out how to do it right. There's really no purpose in the script.A while loop does everything inside the loop as long as the condition at the top is true. There are 3 ways out of any loop:The loop naturally exits if the condition is false for a while loop, true for a Do-Until loop, or the condition for a For loop is metYou use the ExitLoop command. In this case, it will exit out of the current loop and go to the next command below the corresponding WEndAn AdLib function is called with a hotkey that has been set note: (edit) it occurs to me that this is only partially true. Although it will run the AdLib code, it will resume back into the loop when that code is done, unless the AdLib exits the programPerhaps that helps you understand it a bit better? Edited June 10, 2004 by pekster [font="Optima"]"Standing in the rain, twisted and insane, we are holding onto nothing.Feeling every breath, holding no regrets, we're still looking out for something."[/font]Note: my projects are off-line until I can spend more time to make them compatable with syntax changes.
HelloIDistance Posted June 10, 2004 Author Posted June 10, 2004 Yes, Pek you are a really helpful person, Thanks a lot for helping me out. Okay here is a lsit of things I wanna do: 1. Run timer in the background. 2. Have the timer do a certain function every 30 seconds (Doesn't matter what just trying to figure out this.) 3. Run script that looks like this (With timer in background every 30 seconds it goes to timer.) $Helloworld = 2 While $Helloworld > 1 Send ("Hello") WEnd (Then the timer Func here) 4. Have both the timer and the $Helloworld to loop with the timer doing a timer function every 30 seconds. Lets say every 30 seconds it says Send("I did it!"). Is that possible to do?
pekster Posted June 10, 2004 Posted June 10, 2004 (edited) Sure, check out this commented example:$timer = TimerStart();create a new timer While 1;there is no need for a variable since you want an infinite loop Send("Hello") If TimerStop($timer) > 30 * 1000 Then;only do this if the timer is > 30 seconds Send("I did it!");send the 30 second text $timer = TimerStart();be sure to reset the timer EndIf WEndEdit: Please note, that since there is no pause (a sleep) command in there, it will send the Hello text very very quickly, and also bring the CPU usage up to 100%. You might want to include a sleep(1000) in the main loop somewhere. Edited June 10, 2004 by pekster [font="Optima"]"Standing in the rain, twisted and insane, we are holding onto nothing.Feeling every breath, holding no regrets, we're still looking out for something."[/font]Note: my projects are off-line until I can spend more time to make them compatable with syntax changes.
HelloIDistance Posted June 10, 2004 Author Posted June 10, 2004 That was really cool. It said it like 500 times, lol. Okay now say we added a variable into there like my orginal script. How could you add the timer into that? Would a ExitLoop and ContinueLoop do the trick? I just want my orginal script to do the same thing that did. Thanks!
pekster Posted June 10, 2004 Posted June 10, 2004 Okay now say we added a variable into there like my orginal script.You don't want to just "add a variable" because you can. All variables have a reason for being there, otherwise they should be removed. Please tell me what you want the loop to do and I'll either show you how to use a variable to count the number of times the loop has executed and exit accordingly, or explain why you don't need a variable.You'll notice that you were using a variable before, but it was pointless. So I removed it and repalced it with a statement that is always true (that's the "1") because it's the same thing. [font="Optima"]"Standing in the rain, twisted and insane, we are holding onto nothing.Feeling every breath, holding no regrets, we're still looking out for something."[/font]Note: my projects are off-line until I can spend more time to make them compatable with syntax changes.
HelloIDistance Posted June 10, 2004 Author Posted June 10, 2004 I would just like to see an example of a While $variable being used with a timer in the background that's all. I would just like to see how it works. Could you show a quick example ? Thank you!
pekster Posted June 10, 2004 Posted June 10, 2004 I would just like to see an example of a While $variable being used with a timer in the background that's all. I would just like to see how it works. Could you show a quick example ?If you wish to run something a specific number of times, a For loop is what you want to use instead. That's why I asked what you wanted as the result of the code. Technically, anything you can do with a For can also be done with a While loop, but one is usually a lot eaisier to do in each case. The two examples I have provided below do the exact same thing, but the one with the For loop (shown first) is a bit simplier, and eaisier to understand. For loop $timer = TimerStart() For $i = 1 To 65;do this loop 65 times Send("Hello") Sleep(1000) If TimerStop($timer) > 30 * 1000 Then Send("I did it!") $timer = TimerStart() EndIf Next While loop $timer = TimerStart() $i = 1 While $1 < 66;do this loop 65 times Send("Hello") Sleep(1000) If TimerStop($timer) > 30 * 1000 Then Send("I did it!") $timer = TimerStart() EndIf $i = $i + 1 WEnd [font="Optima"]"Standing in the rain, twisted and insane, we are holding onto nothing.Feeling every breath, holding no regrets, we're still looking out for something."[/font]Note: my projects are off-line until I can spend more time to make them compatable with syntax changes.
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