| View previous topic :: View next topic |
| Author |
Message |
Tuncay
Joined: 07 Nov 2006 Posts: 384 Location: Berlin
|
Posted: Mon Dec 17, 2007 11:17 pm Post subject: A_Break and A_Continue |
|
|
Its not directly a wish, currently. Just a thought.
New built-in variables A_Break and A_Continue, updated on every continue or break command. They could hold the argument given from that command.
The default, if no argument was specified, the value of last A_Index (that was also requested) could be used.
Example:
| Code: | Loop
{
if a_index = 10
break
}
msgbox %a_break% ; shows "10"
Loop
{
if a_index = 10
break 2 * 4
}
msgbox %a_break% ; shows "8" |
But I am not sure what to do, if the Loop is nested and if they should resetted on every new loop or whatever.
edit: ups corrected a small error in code above. |
|
| Back to top |
|
 |
engunneer
Joined: 30 Aug 2005 Posts: 6804 Location: Pacific Northwest, US
|
Posted: Tue Dec 18, 2007 12:32 am Post subject: |
|
|
is the reason to try and tell whether it continued or broke last? if they are two variables, you have no way of knowing which one was more recent. I think it's good to come up with ideas like this. What can you see it being used for? _________________
Unless otherwise noted, all code is untested.
Common Answers: 1.(Loops, Viruses, etc.) 2. Search 3.RTFM |
|
| Back to top |
|
 |
Titan
Joined: 11 Aug 2004 Posts: 5107 Location: eth0 ::1
|
Posted: Tue Dec 18, 2007 9:05 am Post subject: |
|
|
Loops are often used to count things such as the number of files in a folder so a variable like A_Break (or A_LastIndex which I prefer) would be helpful. _________________
RegExReplace("irc.freenode.net/ahk", "^(?=(.(?=[\0-r\[]*((?<=\.).))))(?:[c-\x73]{2,8}(\S))+((2)|\b[^\2-]){2}\D++$", "$u3$1$3$4$2") |
|
| Back to top |
|
 |
Tuncay
Joined: 07 Nov 2006 Posts: 384 Location: Berlin
|
Posted: Tue Dec 18, 2007 7:45 pm Post subject: |
|
|
This could us help to determine why and if a Loop command is exit. I dont think, that it is essential, but it would be used quite frequently often. The last A_Index (A_LastIndex) count is just one often asked or needed example.
What would you await A_Break should hold, if Loop exits without a break? I am also not sure how to tell, if a new iteration started from a continue or not. |
|
| Back to top |
|
 |
|