Why is the leading white space of the first line removed ?

Get help with using AutoHotkey and its commands and hotkeys
User avatar
SpeedMaster
Posts: 397
Joined: 12 Nov 2016, 16:09

Why is the leading white space of the first line removed ?

23 Dec 2016, 12:07

Hello,
Why is the leading white space of the first line removed in msgbox ?
How to solve this problem ? :think:
Any suggestions are welcome.
Thanks.

Code: Select all

Myvar=
(
           1                    Why is the leading white space of this line removed ?
           2
           3
           4
           5
)
msgbox, %  Myvar . "`r                      How to solve this problem? Thanks."
User avatar
SpeedMaster
Posts: 397
Joined: 12 Nov 2016, 16:09

Re: Why is the leading white space of the first line removed ?

23 Dec 2016, 12:45

Thanks for your answer but it still doesn't work

Code: Select all

AutoTrim, off
Myvar=
(
           1                    Why is " AutoTrim, off  " not working ?
           2
           3
           4
           5
)

msgbox, % Myvar . "`r                      How to solve this problem? Thanks."
garry
Posts: 2456
Joined: 22 Dec 2013, 12:50

Re: Why is the leading white space of the first line removed ?

23 Dec 2016, 14:48

Code: Select all

Myvar:="
(
           1
           2
           3
           4
           5"
)
msgbox,%myvar%
return
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

Re: Why is the leading white space of the first line removed ?

23 Dec 2016, 15:34

I only finally figured this out yesterday, after going through my AHK queries text file,
I was going to report it as a bug, but did some double-checking on the forums to be sure:
'why is leading whitespace in a (non-expression) continuation section removed?'
I found:
Continuation sections, left tabs in the first line - Ask for Help - AutoHotkey Community
https://autohotkey.com/board/topic/1047 ... irst-line/
it was also the first time I realised you could do an expression mode continuation section (':=' style)

Code: Select all

vText1 =
(
	1
	2
	3
)
vText2 =
(
`t1
	2
	3
)
vText3 =
(
%A_Tab%1
	2
	3
)
imagine the continuation section was 'unfolded' into one line

Code: Select all

vText1 =	1`n	2`n	3
vText2 = `t1`n	2`n	3
vText3 = %A_Tab%1`n	2`n	3
clearly in vText1 you would lose the tab, because it is a literal tab typed by the keyboard
(in non-expression mode leading/trailing literal whitespace is always removed, whether AutoTrim is off or on)
(literal: when it was typed as invisible characters you can't see rather than say `t, %A_Space%, %A_Tab%)
but in vText2 and vText3 the leading tab is kept

if you did

Code: Select all

AutoTrim, On
vText2 = %vText2%
vText3 = %vText3%
then vText2 and vText3 would now lose the leading tab
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”

Who is online

Users browsing this forum: hasantr, sadasada, Syzygy and 48 guests