Page 1 of 1

multiline mathematical calculations

Posted: 19 Jan 2017, 18:06
by jeeswg
Is it possible to split a mathematical calculation across lines?
I thought it was impossible until I realised that ',' then recently ':',
then just now '.' can be used to achieve multiline expressions.
(Btw can any other characters be used to split expressions across lines?)

This works but looks horrendous, is there something better than this?

Code: Select all

vNum := 1 + 2 + 3 + 4 + 5 + (0
. 0) + 6 + 7 + 8 + 9 + 10
MsgBox % vNum

vNum := 1 + 2 + 3 + 4 + 5 + (0
. 0) + 6 + 7 + 8 + 9 + 10 + (0
. 0) + 11 + 12 + 13 + 14 + 15
MsgBox % vNum
Return

Re: multiline mathematical calculations  Topic is solved

Posted: 19 Jan 2017, 18:34
by Helgef
Whitout any reference, this seems ok

Code: Select all

a:=2
b:=	  1
	+ 2
	*-3
	/a
MsgBox, % b

Re: multiline mathematical calculations

Posted: 19 Jan 2017, 19:04
by jeeswg
Thanks so much for this, greatly appreciated! And *embarrassing*!
I spent a good amount of time trying to work out if AutoHotkey
could split a three-line formula I had across lines,
in the end I defined a few variables.

Wow, so all I had to do was this, pretty simple:

Code: Select all

vNum := 1 + 2 + 3 + 4 + 5
               + 6 + 7 + 8 + 9 + 10
MsgBox % vNum
Return
Where in the manual does it say anything about this!?
And just what characters exactly can start a new line!?
Btw I'm working on an AHK v1 command style to AHK v1 expression style converter,
and checking for unusual types of lines.

Re: multiline mathematical calculations

Posted: 19 Jan 2017, 20:39
by wolf_II
https://autohotkey.com/docs/Scripts.htm#continuation
in v1.0.46+, the same is true for all other expression operators except ++ and --
PS:

Code: Select all

a ; inline comment
; comment
:= ; inline comment
; comment
! False ; inline comment
; comment
ListLines
MsgBox, %a%

Code: Select all

a
:=
-2
ListLines
MsgBox, %a%

Re: multiline mathematical calculations

Posted: 19 Jan 2017, 21:29
by jeeswg
Excellent response, thanks so much.