 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
a_h_k
Joined: 02 Feb 2008 Posts: 626
|
Posted: Wed Dec 16, 2009 10:03 am Post subject: Single-line subroutine |
|
|
Recently i wanted to use a really simple subroutine
But of course it didn't work (error)
Hotkeys can have them
So why not subroutines also ?? |
|
| Back to top |
|
 |
Tuncay n-l-i mobile Guest
|
Posted: Wed Feb 24, 2010 6:14 pm Post subject: |
|
|
| yes why not |
|
| Back to top |
|
 |
ruespe
Joined: 17 Jun 2008 Posts: 243
|
Posted: Wed Mar 03, 2010 9:33 am Post subject: |
|
|
Mmmhhh... why should it be easier to write
| Code: | Gosub Sendi
:
:
:
Sendi:Send i | than to write  _________________ Greetings
Rog |
|
| Back to top |
|
 |
Lexikos
Joined: 17 Oct 2006 Posts: 7295 Location: Australia
|
Posted: Thu Mar 04, 2010 8:59 am Post subject: |
|
|
Why should
| Code: | 0or1: v := !v
Send %v%
return | be equivalent to
| Code: | 0or1:
v := !v
return
Send %v%
return
| and not | Code: | 0or1:
v := !v
Send %v%
return
| ???
Labels should be nothing more than a way to mark (or label) a particular line. Allowing same-line subroutines by automatically inserting return would be counter-intuitive, especially for users of other languages which have goto/same-line labels, or if goto is used with that particular label. Perhaps this ambiguity is why it is not allowed.
C and some similar languages allow same-line labels, but limit the characters allowed in label names (i.e. to alphanumeric characters/underscore). OTOH, AutoHotkey allows virtually anything besides whitespace, comma or operators like =. Supporting same-line labels while still allowing this freedom would require more complicated parsing methods and might introduce other conflicts.
That aside, I suppose that Gui and Menu would be better examples of where single-line subroutines would be convenient; i.e. because the code must be in a separate subroutine, not in-line.
| Code: | Menu, M, Add, Help
Menu, M, Show
ExitApp
Help: MsgBox feature not implemented
| OTOH, others have requested capabilities like:
| Code: | Menu, M, Add, Help, MsgBox("feature not implemented")
Menu, M, Show
ExitApp
| ... which would lessen the need for same-line subroutines. |
|
| Back to top |
|
 |
Guest
|
Posted: Thu Mar 04, 2010 1:47 pm Post subject: |
|
|
Likewise (& however useful), perhaps single-line Hotkeys should be removed...cuz there are alot of people making this mistake...
| Code: | F9::msgbox, This works...
msgbox, ...but it don't continue? why? |
...but maybe instead of removing single-line Hotkeys...AutoHotkey could, by default (& overridably), complain about "stranded code", code that can never be reached, based on positioning... |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|