multiline mathematical calculations Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

multiline mathematical calculations

19 Jan 2017, 18:06

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: 4709
Joined: 17 Jul 2016, 01:02
Contact:

Re: multiline mathematical calculations  Topic is solved

19 Jan 2017, 18:34

Whitout any reference, this seems ok

Code: Select all

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

Re: multiline mathematical calculations

19 Jan 2017, 19:04

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

19 Jan 2017, 20:39

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

Re: multiline mathematical calculations

19 Jan 2017, 21:29

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

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Google [Bot] and 154 guests