| View previous topic :: View next topic |
| Author |
Message |
[VxE]
Joined: 07 Oct 2006 Posts: 1128
|
Posted: Wed Dec 12, 2007 3:34 am Post subject: Delayed Break PLZ |
|
|
Props to the AHK devs for the great proggie, but do you suppose you could modify the "Break" command to accept one parameter (coerced to unsigned int) to represent the number of lines of script after the actual break command to be executed within a loop before the loop actually gets broken?
example:
| Code: | loop
{
perform := things + stuff
if ( things && stuff != something )
break 2 ; execute 2 additional lines of code
send %things%
send %stuff% ; this line would be executed before the 'break'
clipboard = %something% ; this line would not be executed if the loop were to break
send ^v
} |
I know that the same functionality can be achieved by using extra variables and more "if"s in other places, but I think having a delayed break would make certain mechanisms much cleaner to code. Also, if someone needed to use a loop to process data of varying formats and didn't need to use every command in the loop to process certain pieces of data, a delayed break would be as convenient as a backwards "GoTo"
[edit:] note: example code is only for illustrating suggested functionality. Example code is not "broken" nor meant to be "corrected", nor is it meant to show a case where the suggested functionality would be necessary or desirable. _________________ My Home Thread
More Common Answers: 1. It's in the FAQ 2. Ternary ( ? : ) guide 3. Post code with [code][/code] tags
Last edited by [VxE] on Sun Dec 16, 2007 1:50 am; edited 1 time in total |
|
| Back to top |
|
 |
Lexikos
Joined: 17 Oct 2006 Posts: 2558 Location: Australia, Qld
|
Posted: Wed Dec 12, 2007 3:58 am Post subject: |
|
|
I tend to think the following would be more intuitive:
| Code: | loop
{
perform := things + stuff
if ( things && stuff != something ) ; do stuff, then break
{
send %things%
send %stuff%
break
}
clipboard = %something% ; this line would not be executed if the loop were to break
send ^v
}
| No need for "extra variables and more ifs".
"break 2" could be interpreted as "break twice," which would be more useful, IMO. |
|
| Back to top |
|
 |
engunneer
Joined: 30 Aug 2005 Posts: 6772 Location: Pacific Northwest, US
|
Posted: Mon Dec 17, 2007 5:45 pm Post subject: |
|
|
wouldn't that be
| Code: |
loop
{
perform := things + stuff
send %things%
send %stuff%
if ( things && stuff != something )
break
clipboard = %something% ; this line would not be executed if the loop were to break
send ^v
}
|
 _________________
Unless otherwise noted, all code is untested.
Common Answers: 1.(Loops, Viruses, etc.) 2. Search 3.RTFM |
|
| Back to top |
|
 |
Tuncay
Joined: 07 Nov 2006 Posts: 384 Location: Berlin
|
Posted: Mon Dec 17, 2007 10:08 pm Post subject: |
|
|
| I think, a delayed break would make the script very unreadable. In such a case, there isnīt any final label to follow on reading of code. That would be a horror to me and not really neccessary. I am against it. Sounds worse than GoTo! Its just a matter of reorganizing the code, if such a request is about to come. |
|
| Back to top |
|
 |
engunneer
Joined: 30 Aug 2005 Posts: 6772 Location: Pacific Northwest, US
|
Posted: Tue Dec 18, 2007 12:26 am Post subject: |
|
|
Tuncay, look up INTERCAL
instead of Goto, it has a Come From command. _________________
Unless otherwise noted, all code is untested.
Common Answers: 1.(Loops, Viruses, etc.) 2. Search 3.RTFM |
|
| Back to top |
|
 |
|