Continuation section and expression assignment Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
SunAndSuch
Posts: 46
Joined: 05 Oct 2015, 12:11

Continuation section and expression assignment

27 Oct 2018, 10:53

Hi. I am trying to store a chunk of ahk code in a variable. When I use:

Code: Select all

var=
(% `
Multiline text,
containing:
	percent signs, backticks, brackets, braces, double quotes, parentheses etc.
)
, it works fine. But can I achieve this using an expression assignment (like var:=, or var.=) and without having to edit the text (e.g. doubling the double quotes, or similar)?
Windows 10, Ahk v1 x64-bit.
aifritz
Posts: 301
Joined: 29 Jul 2018, 11:30
Location: Germany

Re: Continuation section and expression assignment

27 Oct 2018, 12:07

Very interesting, I was not aware that this is working ;)

Code: Select all

c ;var c is assigned via continuation section
:= "Hello"
. " World"
msgbox % c
swagfag
Posts: 6222
Joined: 11 Jan 2017, 17:59

Re: Continuation section and expression assignment

27 Oct 2018, 12:30

u can FileRead it into a var
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

Re: Continuation section and expression assignment  Topic is solved

27 Oct 2018, 12:39

- Unfortunately, a completely verbatim string in AHK v1 requires an = assignment.
- The closest you can get with an := assignment requires doubling up double quotes (" replaced with "").
- See ANSI (CP-1252) CHARACTERS (VERBATIM) (WYSIWYG) (CONTINUATION SECTIONS) for the best current solutions:
jeeswg's characters tutorial - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=7&t=26486
- I have asked for some solution, see ASSIGN TEXT (MULTI-LINE) (CONTINUATION SECTIONS), here:
Wish List 2.0 - AutoHotkey Community
https://autohotkey.com/boards/viewtopic ... 13&t=36789
Last edited by jeeswg on 27 Oct 2018, 13:41, edited 1 time in total.
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

Re: Continuation section and expression assignment

27 Oct 2018, 12:58

Here's a workaround:

Code: Select all

q:: ;verbatim text workaround
vLine1 := A_LineNumber + 2
/*
!"#$%&'()*+,-./0123456789:;<=>?
@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_
`abcdefghijklmnopqrstuvwxyz{|}~
€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ
 ¡¢£¤¥¦§¨©ª«¬­®¯°±²³´µ¶·¸¹º»¼½¾¿
ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞß
àáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ
*/
vLine2 := A_LineNumber - 2
if !vIsReady
{
	vOutput := ""
	Loop, % vLine2 - vLine1 + 1
	{
		FileReadLine, vTemp, % A_ScriptFullPath, % vLine1 + A_Index - 1
		vOutput .= vTemp "`r`n"
	}
	vIsReady := 1
}
MsgBox, % vOutput
return
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
SunAndSuch
Posts: 46
Joined: 05 Oct 2015, 12:11

Re: Continuation section and expression assignment

27 Oct 2018, 13:35

Thanks for your answers. I think I will go with the "PREPARE TEXT FOR STORING IN A VARIABLE" at the "jeeswg's characters tutorial" page. Verbatim string would be good, hope it will happen :).
Windows 10, Ahk v1 x64-bit.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: AlFlo, Bing [Bot] and 121 guests