 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
Jerry
Joined: 24 Jun 2004 Posts: 39
|
Posted: Thu Jul 01, 2004 5:29 am Post subject: Library Functions |
|
|
I was just reading the topic "Database functions ex: FileWriteLine" and when you Chris, replied with code that would work, I thought, if user functions were added to autohotkey you would not need to put in a new command
just a new user library function.
Functions could be implemented in the way AutoIt 3 has it. E.G. _ColorGetRed
The best way I beleive, would allow multiple variables / parameters passed into the function and multiple variables received.
E.g. x, y = FileWriteLine(c:\some file.txt, Line345) In this example probably only one variable need be returned, this is just an example to get an idea across.
Implementation of functions could also allow autohotkey EXE stay small and new enhancements could focus on new low level / novel functionality.
There is also one wish list item "The ability to run AutoHotkey.exe and pass a single command (or perhaps group of commands) to execute." that could be satisfied with user functions. |
|
| Back to top |
|
 |
Chris Site Admin
Joined: 02 Mar 2004 Posts: 10464
|
Posted: Thu Jul 01, 2004 1:31 pm Post subject: |
|
|
| Quote: | ...allow multiple variables / parameters passed into the function and multiple variables received.
E.g. x, y = FileWriteLine(c:\some file.txt, Line345) In this example probably only one variable need be returned, this is just an example to get an idea across. |
I have thought about supporting functions and return values. Your approach is a good one, though you can see that it is ambiguous due to the question of whether to interpret the text literally or as a function call. This could be solved by using a new operator or syntax, perhaps even extending the Gosub command to pass parameters and accept return values.
You probably know that UDF-like behavior can be implemented by using Gosub. In fact, anything that can be done with UDFs can be done with the existing AHK syntax, just more awkwardly: global variables are set by the caller and other globals are set by the called subroutine as "return values" (if any). Obviously having all global variables isn't good programming practice, but this is after all a scripting language designed for simplicity and (in this case) maximum runtime performance.
| Quote: | | There is also one wish list item "The ability to run AutoHotkey.exe and pass a single command (or perhaps group of commands) to execute." that could be satisfied with user functions. |
I don't think UDFs would solve that. You would need support for dynamic commands, which is another wish list item (one that I'm procrastinating on, due to the complexity and code size involved).
Thanks for your insightful comments. I'm interested in discussing this topic further should you or anyone wish to. |
|
| 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
|