Syntactic simplification for hotstring multiline Topic is solved

Propose new features and changes
concepter
Posts: 47
Joined: 24 Aug 2017, 13:02

Syntactic simplification for hotstring multiline

28 Sep 2017, 08:56

I propose to omit the return directive at the end of a multi-line hotstring definition when there is only one calling line to a function.
One case is that shown in the following link:
https://autohotkey.com/boards/viewtopic.php?t=36262
In fact, when we have only one call line to a function, the return directive could be considered implicit and therefore superfluous to have a compact and readable code.
From:

Code: Select all

::word::
	functionX(var)
	return
To:

Code: Select all

:F:word:: functionX(var)
introducing a directive F (or equivalent) at the beginning of the hotstring :F:word:: to interpret the right part not as a string but as a function.
If it was possible to introduce this modification even in AHK v1, for testing, it would be great!
_3D_
Posts: 277
Joined: 29 Jan 2014, 14:40

Re: Syntactic simplification for hotstring multiline

04 Oct 2017, 07:03

Evolution of language going to opposite and in the future maybe can`t be possible to write more that one command in the same line.
v2.0-a081-cad307c
if expression, expression ;no longer possible
AHKv2.0 alpha forever.
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

Re: Syntactic simplification for hotstring multiline

04 Oct 2017, 08:31

I don't have a personal need for this, but the idea is potentially useful, and the syntax proposal of a new letter, although not necessarily the letter 'F' or 'f', is a good one.

I did think of 'F'/'f' at first, before seeing that you suggested it, but this could be made more general, possibly 'X' or 'x' for expression.

Code: Select all

;E.g. you could do:
:X:word::Func1(), Func2(), Func3()

;You can already do:
q::Func1(), Func2(), Func3()
At present, a workaround would be:

Code: Select all

oArray := {abc:1, def:2, ghi:3}
:*:abc::
:*:def::
:*:ghi::
MsgBox, % A_ThisHotkey
vFunc := oArray[SubStr(A_ThisHotkey, 4)]
Func%vFunc%()
return

Func1()
{
	MsgBox, % A_ThisFunc
}
Func2()
{
	MsgBox, % A_ThisFunc
}
Func3()
{
	MsgBox, % A_ThisFunc
}
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
lexikos
Posts: 9583
Joined: 30 Sep 2013, 04:07
Contact:

Re: Syntactic simplification for hotstring multiline  Topic is solved

26 Mar 2018, 03:40

The 'X' option was implemented in v1.1.28 and v2.0-a089.

Return to “Wish List”

Who is online

Users browsing this forum: No registered users and 23 guests