okuma31 0 Posted January 13, 2013 Report Share Posted January 13, 2013 At the moment my bot will run a loop and then it'll use increment to increase the variable at the end of the cycle. What I want to do is figure out how I can use an if statement to evaluate if the bot has reached 50 and if so then sleep, any ideas on how to do this? Quote Link to post Share on other sites
VaultBoss 310 Posted January 13, 2013 Report Share Posted January 13, 2013 Use LOOP WHILE Quote Link to post Share on other sites
okuma31 0 Posted January 13, 2013 Author Report Share Posted January 13, 2013 I'll check that out, I'm still scratching my head trying to figure out how to say that with ubot. Do I throw the variable in and then say = 50 or is there another way, would you mind showing me a quick example please? Quote Link to post Share on other sites
VaultBoss 310 Posted January 13, 2013 Report Share Posted January 13, 2013 LOOP WHILE is a Node, a command in UBot, not a variable. The logic behind it would be... Repeat certain actions as long as a certain condition is met (in your case the incrementing step value is less than 50) The code would be: set(#var_CYC_LoopNO, 50, "Global") loop while($comparison(#var_CYC_LoopNO, ">", 0)) { decrement(#var_CYC_LoopNO) divider comment("Place your own CODE Here") divider }...alternatively: set(#var_CYC_LoopNO, 0, "Global") loop while($comparison(#var_CYC_LoopNO, "<", 50)) { divider comment("Place your own CODE Here") divider increment(#var_CYC_LoopNO) } In the first case you start the cycling from TOP and decrement the looping variable as the first thing inside the loopIn the second case you start at the BOTTOM and increment the cycling variable after you have performed all code, just before the end of the looping sequence. Each has its own benefits depending on what you need to code.For instance, I'd rather use the decrementing from TOP whenever I have to loop through lists/tables, because the number of iterations is usually resulting from the list/table size, which would give a value that at its MAX would exceed the range of the incremental values any reference functions would allow. To make it simple: A table that has 3 rows of data. $total table rows would return the value 3 A looping upto 3 cycles is in order. Each row in the table is referenced though starting from 0, then 1, then 2 is max (corresponding to the 3rd row) A reference to any $table cell depending on the looping incremental variable of the LOOP node cannot be 3 though, as the $table cell(&table, #var_CYC_LoopNO, 0) would return an error when #var_CYC_LoopNO = 3 !!! As such, it's better to evaluate the max number of rows: set(#var_CYC_LoopNO, $total table rows(&table), "Global")and thendecrement(#var_CYC_LoopNO)thus being able to LOOP from TOP to BOTTOM between the values 2, 1, 0 respectively and safely referencing the table cells with the table cell related functions. 1 Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.