mIRC Homepage
Posted By: Cheech while loops - 25/03/03 01:56 AM
if i am using something like
while ( %t <= %z ) {
dostuff
inc %t
}

is it possible to slow down the loop so it doesnt proccess so quickly ? maybe like pause before it goes back to the top thx in advance for any help smile
Posted By: LO_KEY Re: while loops - 25/03/03 01:59 AM
u can try putting it on a timer

Posted By: Cheech Re: while loops - 25/03/03 02:03 AM
well i tryed a timer on the command like
Code:
  
while ( %t &lt;= %z ) { 
 .timer1 1 4 dostuff 
  inc %t
}



the problem is say %z is 20 well it mght hit on line 1 then line 5 then line 11 then line 17 etc...
? if that makes any sense .. lol
Posted By: LO_KEY Re: while loops - 25/03/03 02:13 AM
more like this, sorry, shoulda been more specific

.timerlk 0 3 do.this

alias do.this {
if ( %t <= %z ) {
do stuff
inc %t
}
if (%t > %z) { .timerlk off }
}
Posted By: Cheech Re: while loops - 25/03/03 02:22 AM
ok sorry but i didnt quite understand that either ? i dont see how that is going to pause the loop ?
i understand seting the timer on the alias but i need to pause the while loop for say 3 secs because if %z is 6 with the script i put above 6 is the only result you will get as it has cycled thru the loop i am assuming to fast for anything else to process ?
Posted By: Collective Re: while loops - 25/03/03 02:32 AM
I'm lost...why exactly do you need to pause the loop? The loop you have looks fine to me.. It would be easier if we knew what you were trying to accomplish.
Posted By: Cheech Re: while loops - 25/03/03 02:41 AM
well what i want to do is send lines of text to a channel i can do this easily in other ways but i hadent used while loops much so i was just trying to work with them a bit to perform this function the script basically works but if the numberof lines is 6 the script only sends line 6 and skips the rest ? so i am just trying to learn/utilize the while loop feature in order to get away from further scripting gogo loops in future scripting ?

Posted By: _D3m0n_ Re: while loops - 25/03/03 03:04 AM
i can think of several reason ud want to pause a while loop ... one i can name offhand would be on my nicklst script ive made ..... ive had to actually set a timer now into the script to allow for certain variables to be setup when the loop starts to execute ... in order for it to actually work and compile my nicklist correctly ...... i know it doesnt sound like it would need to but ...... when u start setting icons into a nicklist using mdx ..... u can also set icons on away nicks ... to get the away nicks u have to do a who of tha chan and look for a G in $7 of the returned nicks ..... in a loop .. then set each nick it finds that g in $7 of its line into a variable ..... then u ned to start to compile the nicklist once u get all those nicks....... now to do this u have to also hold off and sort thru the variable u created with the away nicks ...... so u have to get all the nicks compare each one to whatss in that variable then if it matches set its approriate icon now its not so hard to payse it all if when u set ur event trigger up like on join who $chan | timer 1 1 alias of nicklist compiler

now u would have to do that on each and every possible nicklist change have a timer to hold it off while it compiles away nicks then it starts to sort thru it ... now on nick changes u actually have to set a timer on the who $chan and then increase the timer on the nicklist compiler by one ....... what ive noticed is if there was the ability to pause the loop to allow for some of thsese variable to be set then it would make it alot easier ... as i had to figure these lil tricks out without having clue why things werent setting or compiling correctly ...... so to have the ability to pause a loop for say a second would be a completely awesome idea .. it would allow for certain variavbles to be set and u could include other things inside the loop that uve had to otherwise exclude because of these slight limitations ...... but really if u cant pause ur loop there are other ways around what ur tryin to accomplish ... so i guess in the end its all just a thought of ok should this be like this or should it be left to do alternativly ...... say u wanted to set a variable then read from that variable inside the loop then reset that variable again and perform the loop ... ive had trouble where it actually wont read that variable from the loop because it doesnt set it fast enough to read from inside the loop and ended up with a blank list of nothing ........
Posted By: LO_KEY Re: while loops - 25/03/03 03:11 AM
ahhhhhhhhhhhh


_D3m0n_: can u give me a direct link to mdx please?

if thats to much, jus a link where i can get it ?
thx.
Posted By: Collective Re: while loops - 25/03/03 03:13 AM
I didn't say there were no reasons to pause I loop, I asked why he was doing it...
Posted By: _D3m0n_ Re: while loops - 25/03/03 03:15 AM
MDX IS LOCATED HERE
Posted By: _D3m0n_ Re: while loops - 25/03/03 03:17 AM
granted ..... but i figured id add my 2 cents in to give a few reasons of why i thought while loops should be able to have a pause in them........ again its just a discussion .... just sharing my ideas
Posted By: Cheech Re: while loops - 25/03/03 03:19 AM
well that last part is what i am talking about
Quote:

say u wanted to set a variable then read from that variable inside the loop then reset that variable again and perform the loop ... ive had trouble where it actually wont read that variable from the loop because it doesnt set it fast enough to read from inside the loop and ended up with a blank list of nothing ........


Code:
  
 var %z = $lines(blah.txt)
  var %t = 1
  while ( %t &lt;= %z ) {  
  .timer1 1 4 msg $active $read(blah.txt,%t)   
  inc %t
}
}


now lets say %z = 6
if your lucky you get line 6 because it is inc'd to 7 before anything can happen
thats the best i can figure out as to what the problem is
Posted By: Collective Re: while loops - 25/03/03 03:30 AM
With that code you posted everytime it goes through the loop it resets timer "1" and tells it to msg the channel with line %t. Because of that the timer can only ever finish once (because the only time you don't reset it is when the loop has finished), so I guess that there are 6 lines in your text file?
Posted By: Cheech Re: while loops - 25/03/03 03:31 AM
correct 6 lines in the file but even if i take the timer out it only responds with one line ? i added the timer thinking it would help but it didnt
Posted By: LO_KEY Re: while loops - 25/03/03 03:32 AM
can u give me a good tutorial link if there is one for the mdx dll please

thx again.

smile
Posted By: LO_KEY Re: while loops - 25/03/03 03:34 AM
var %z = $lines(blah.txt)
var %t = 1
while ( %t <= %z ) {
.timer $+ %t 1 4 msg $active $read(blah.txt,%t)
inc %t
}
}

should work for ya
Posted By: Collective Re: while loops - 25/03/03 03:38 AM
Why name the timers at all? They might disrupt other timers that have been automatically assgined numbers by mIRC...

And for the record your (cheech) script worked fine when I took out the timer so I have no idea why it didn't work for you.
Posted By: Cheech Re: while loops - 25/03/03 03:39 AM
well that would probably work but if the file had 75 lines you would flood out beacuse they will all trigger at once
Posted By: Cheech Re: while loops - 25/03/03 03:44 AM
well thats weird i took the timer out aswell and it works now ? but just to make sure i understand after al this ? there is actually no pause for the loop ?
Posted By: Collective Re: while loops - 25/03/03 03:51 AM
Code:
alias pastefile {
  var %z = $lines(blah.txt)
  var %t = 1 
  while ( %t &lt;= %z ) {
    .timer 1 $calc(%t - 1) msg $active $read(blah.txt,%t)
    inc %t
  }
}


There isn't a command built into mIRC to pause a loop, but the /sleep snippet might do the job..never used it to do that myself.
Posted By: Cheech Re: while loops - 25/03/03 03:59 AM
ok thx everyone for the input perhaps as a future suggestion the could add a /resume or something then you could just /break /resume to slow it down .. lol thx again i will check out the /sleep snippet smile
Posted By: Cheech Re: while loops - 25/03/03 04:11 AM
Code:
  
alias pastefile {  
 var %z = $lines(blah.txt)  
 var %t = 1   
 var %x = 0
 while ( %t &lt;= %z ) {    
 .timer 1 $calc(%t + 3) msg $active $read(blah.txt,%t)   
 inc %t 
 inc %x 3
 }
}


thx again that last one worked i just changed it slightly to get a 3 sec delay smile
Posted By: _D3m0n_ Re: while loops - 25/03/03 06:12 AM
i had tried to use that sleep snippet to pause my loop at one point and i could seem to figure it out how to make it work inside of that ..... unfortunatly the best i could come up with to do was to make the loop have a timer delay on its command ..... altho im sure there is someone out there who can come up with the correct usage of how to do that ..... im just not that good yet with scripting ......
Posted By: qwerty Re: while loops - 25/03/03 02:48 PM
What you want can be done with a single command:
/.play $active blah.txt 3000
Posted By: Cheech Re: while loops - 26/03/03 01:05 AM
i know i can use /play but i was just working with the loops specifically thx anyhow smile
© mIRC Discussion Forums