Functions without parenthesis Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Gabby
Posts: 28
Joined: 19 Aug 2017, 03:55

Functions without parenthesis

24 Sep 2018, 19:27

Is it possible to have a function (actually a procedure, because the return value is discarded), called without the parentheses, like an inbuilt command or a sub in VBA?

So if we have a function Do_things(X, Y) is it possible to call it with "Do_things X, Y".

The reason I ask this is that functions are very useful to encapsulate the code (with local variables), unlike subs.

Andrew
iseahound
Posts: 1444
Joined: 13 Aug 2016, 21:04
Contact:

Re: Functions without parenthesis  Topic is solved

24 Sep 2018, 20:23

Hey this feature is available in our v2! (alpha)

Code: Select all

Add(2, 3)
Add 2, 3  ; Parentheses can be omitted if used at the start of a line.
https://lexikos.github.io/v2/docs/Functions.htm#intro
Gabby
Posts: 28
Joined: 19 Aug 2017, 03:55

Re: Functions without parenthesis

24 Sep 2018, 20:26

Ahh, I wait with bated breath ...
User avatar
Scr1pter
Posts: 1272
Joined: 06 Aug 2017, 08:21
Location: Germany

Re: Functions without parenthesis

25 Sep 2018, 05:08

What's the difference instead of calling it by
Do_things(X, Y)
?

Regards
Please use [code][/code] when posting code!
Keyboard: Logitech G PRO - Mouse: Logitech G502 LS - OS: Windows 10 Pro 64 Bit - AHK version: 1.1.33.09
Gabby
Posts: 28
Joined: 19 Aug 2017, 03:55

Re: Functions without parenthesis

25 Sep 2018, 05:24

Well, for a start you don't need to remember that the ( can't be preceded by a space.

Seriously though, a few times I've need to replace 'commands' with my own functions (which *use* the command), and found this quite tedious.
User avatar
Scr1pter
Posts: 1272
Joined: 06 Aug 2017, 08:21
Location: Germany

Re: Functions without parenthesis

25 Sep 2018, 05:56

Do you have a concrete example?

Regards
Please use [code][/code] when posting code!
Keyboard: Logitech G PRO - Mouse: Logitech G502 LS - OS: Windows 10 Pro 64 Bit - AHK version: 1.1.33.09
Gabby
Posts: 28
Joined: 19 Aug 2017, 03:55

Re: Functions without parenthesis

25 Sep 2018, 18:35

OK. Consider a block including several Send statements, which we decide to change to a call to a function Fsend to send in a different way, or with delays.

So 'send {F3}' needs to be changed to 'Fsend("{F3}")'. Takes some time to change them, and doesn't read anywhere else as well.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Anput, RandomBoy, RussF and 399 guests