## multiline mathematical calculations Topic is solved

Get help with using AutoHotkey and its commands and hotkeys
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

### multiline mathematical calculations

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
``````
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
Helgef
Posts: 4459
Joined: 17 Jul 2016, 01:02
Contact:

### Re: multiline mathematical calculations  Topic is solved

Whitout any reference, this seems ok

Code: Select all

``````a:=2
b:=	  1
+ 2
*-3
/a
MsgBox, % b
``````
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

### Re: multiline mathematical calculations

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.
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
wolf_II
Posts: 2688
Joined: 08 Feb 2015, 20:55

### Re: multiline mathematical calculations

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%
``````
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

### Re: multiline mathematical calculations

Excellent response, thanks so much.
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA