Skip navigation
All Places > ArcGIS AppStudio > Blog > 2019 > April

1. Mary had a little lamb


AppStudio 3.3 is based on Qt5.12.1 which includes a new JavaScript engine supporting ECMAScript 6 and ECMAScript 7. In this blog we will be looking at multiline string literals, specifically, different ways of realizing the following nursery rhyme:


Mary had a little lamb, little lamb, little lamb
Mary had a little lamb
Whose fleece was white as snow.


2. The 1 liner example


var str = "Mary had a little lamb, little lamb, little lamb\nMary had a little lamb\nWhose fleece was white as snow.\n"


The above code gives us what we want. A 3 line rhyme stored in a string. It's short, but, it is hard to read and maintain. The newline \n character makes reading the first word in the following sentence awkward.


3. String lists


var list = [ "Mary had a little lamb, little lamb, little lamb",
             "Mary had a little lamb",
             "Whose fleece was white as snow." ]
var str = list.join("\n") + "\n"


Using a staging list means we don't need to remember to put \n to break every line. It's looks nicer in code and easier to maintain the rhyme since we can now split the code over multiple lines. It does suffer from the fact that we need to ensure the syntax of lists is correct (i.e. the commas needed to be correctly placed). It has the advantage that we can make use of array functions such as appending to the end of the list. The joining line does look awkward but it's always the same pattern so you'll get used to it. Because we are using join, we must remember to append the last \n.


4. Using the files


var str = app.folder.readTextFile("rhyme.txt")


By storing strings in files, we can dramatically reduce the code that appears in your program. This reduces error significantly, and, maintenance on your rhyme can be done in a regular text edit without worrying about the Javascript side of things.


5. ECMAScript 6 multiline string


var str = `Mary had a little lamb, little lamb, little lamb
Mary had a little lamb
Whose fleece was white as snow.

As of AppStudio 3.3 (and Qt 5.12.x) we can now use backticks ` to surround a multiline string element. This is incredibly easy to read and maintain. Backticks also introduces a new feature called expression interpolation. Here's a simple example involving our poem:


var name = 'Mary';
var str = `${name} had a little lamb, little lamb, little lamb
${name} had a little lamb
Whose fleece was white as snow.


Here's a more extended form which includes operators:


var customer = { name: "Foo" }
var card = { amount: 7, product: "Bar", unitprice: 42 }
var str = `Hello ${},
want to buy
${card.amount} ${card.product} for
a total of
${card.amount * card.unitprice} bucks?`





Send us your feedback to


Become an AppStudio for ArcGIS developer! Watch this video on how to sign up for a free trial.


Follow us on Twitter @AppStudioArcGIS to keep up-to-date on the latest information and let us know about your creations built using AppStudio to be featured in the AppStudio Showcase.


The AppStudio team periodically hosts workshops and webinars; please click on this link to leave your email if you are interested in information regarding AppStudio events.

We are pleased to announce the release of AppStudio for ArcGIS version 3.3. This release includes many exciting new features and enhancements to help you write apps faster and easier than ever. Please click on this link to learn what's new.  


Bug Fixes and Enhancements



Salesforce ID
AppStudio for ArcGIS app is German yet Map Tour Templates are in English
Title for Make tool is not localized (AppStudio)
MOR_I18N: "Sign In" string is not correctly centered / truncated on some languages
In AppStudio for ArcGIS Desktop, when the app auto-signs in using Enterprise logins while accessing a secured service, the Map Viewer template returns the error "Client_id not specified".
Android build fails in AppStudio for ArcGIS (Desktop Edition) when a valid Java KeyStore (JKS) is supplied with Cloud Make.
AppStudio for ArcGIS Map Viewer applications fails to load secured maps using Portal for ArcGIS.
AppStudio for ArcGIS app is German yet Map Viewer Templates are in English
AppStudio for ArcGIS app is German yet Quick Report Templates are in English
Enable the ability in AppStudio for ArcGIS app to access and use the GPS while the screen is locked or if another app is currently enabled in the app stack on the device.
Unable to add more than one feature layer in AppStudio Quick Report template