AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Delayed Break PLZ

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Wish List
View previous topic :: View next topic  
Author Message
[VxE]



Joined: 07 Oct 2006
Posts: 1128

PostPosted: Wed Dec 12, 2007 3:34 am    Post subject: Delayed Break PLZ Reply with quote

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
View user's profile Send private message
Lexikos



Joined: 17 Oct 2006
Posts: 2558
Location: Australia, Qld

PostPosted: Wed Dec 12, 2007 3:58 am    Post subject: Reply with quote

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
View user's profile Send private message
engunneer



Joined: 30 Aug 2005
Posts: 6772
Location: Pacific Northwest, US

PostPosted: Mon Dec 17, 2007 5:45 pm    Post subject: Reply with quote

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
}

Question
_________________
Unless otherwise noted, all code is untested.
Common Answers: 1.(Loops, Viruses, etc.) 2. Search 3.RTFM
Back to top
View user's profile Send private message Visit poster's website
Tuncay



Joined: 07 Nov 2006
Posts: 384
Location: Berlin

PostPosted: Mon Dec 17, 2007 10:08 pm    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail
engunneer



Joined: 30 Aug 2005
Posts: 6772
Location: Pacific Northwest, US

PostPosted: Tue Dec 18, 2007 12:26 am    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Wish List All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group