Is there a way to assign a multi-line string to an object property?

I know that you can assign a multi-line string to such a variable:

MyVar = 
(
this
is 
a 
string with multiple
lines
)

But is there a way to assign the above string to an object? I tried to do it like this, but I got an error message:

Array := {}
Array["key"] = 
(
this
is 
a 
string with multiple
lines
)

The error says:

The following variable name contains an invalid character "this is a
string"

I just want to open my script in a text editor and copy and paste lines from several lines directly into the editor as properties of the objects.

+4
source share
2 answers

You must use the correct assignment operator: = with objects, also your text should be enclosed in Quotes.

Try:

obj := {}

obj["key"] := 
( 
"this
is 
a 
string with multiple
lines"
)

MsgBox % obj["key"]

Or you can do it below:

x = 
(
this
is 
a 
string with multiple
lines
)

obj["key"] := x

MsgBox % obj["key"]

:

obj := {"key": 
(
"this
is 
a 
string with multiple
lines"
)}

MsgBox % obj["key"]
+1

, , , , , script.

str := {"Lines":
(
"first
second
third"
)}

. , , "n" :

str := {"Lines": "first`nSecond`nThird"}
0

All Articles