24092

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

Question:

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

MyVar = ( this is a string with multiple lines )

But is there a way to assign the above string to an object property? I tried doing it like this but I received an error:

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

The error says:

<blockquote>

The following variable name contains an illegal character <br /> "this <br /> is <br /> a<br /> string"<br />

</blockquote>

I just want to be able to open my script in a text editor and copy and paste multiple-line strings directly into the editor as properties of objects.

Answer1:

You have to use the proper assignment operator := with Objects, likewise your text needs be enclosed by Quotes.

Try:

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

Or you can do this below:

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

You can also build a multi-line object like so:

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

Answer2:

Using a raw multiline string assignment like the following it tends to defeat any indenting you may have cultivated in your script.

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

Although that will work. If you're looking to preserve your code indenting then you can create a multiline string by delimiting the lines with `n like this:

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

Recommend

  • Spring Integration. Unknown host and tcp-connection-factory
  • how to solve access denied when using UWP GetFolderFromPathAsync
  • Custom url support in Android email
  • 3d object recognition for AR android app
  • Sql Alchemy cannot run inside a transaction block
  • JQuery Adding link to a table cell
  • Contact us email sending is not working in codeigniter php
  • What is the difference between 'import' and 'require' in JavaScript?
  • Switching backgrounds, while switching text
  • CSS button not styling
  • Master makefile which runs make files in subdirectories
  • iOS Today Extension created as .app rather than .appex
  • Migrating MOSS 2007 from SQL 2000 to SQL 2005 [closed]
  • DocuSign API Replace template document but keep fields
  • Parallelization via JDBC - Pyspark - How does parallelization work using JDBC?
  • Special characters (ë) in JSON-response
  • Finding all XML nodes between each two processing instructions
  • Implementing and using MinMax with four in row (connect4) game
  • date changes on export kendoGrid
  • characters not allowed in DOM ids by spec, and by browser
  • Use PHP to Replace HTML with HTML
  • jQuery Ajax call to WCF service returning “Method not allowed (405)”
  • How to display youtube video on HTML page? [closed]
  • How to get the Owner of the ContextMenu (from Silverlight 4 toolkit)?
  • how to add dashed border on highcharts “area” graph for every point
  • What does “T extends Junk” mean in a generic class in Java?
  • How to use Typescript with libraries like Ampersand.js that parse configs to build prototypes
  • Set SelectedIndex of ListView in FlipView_SelectionChanged event
  • 'Edit' function for forum posts and such
  • How do I use libcurl to printf a remote FTP directory listing?
  • JQuery: Infinite input select
  • How to clear a browser cache in Protractor
  • Stacked bar chart with continuous time-axis as x-axis
  • matrix multiplication apache pig
  • Background transfer download task failed when app was closed
  • ssh remote server login script
  • multiple button click in asp.net MVC 3
  • Running R's aov() mixed effects model from Python using rpy2
  • convert json to excel in java
  • ReferenceError: TextEncoder is not defined