StrokesPlus.net
Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Options
Go to last post Go to first unread
kuer  
#1 Posted : Wednesday, January 19, 2022 9:34:13 PM(UTC)
kuer

Rank: Member

Reputation:

Groups: Approved
Joined: 6/8/2019(UTC)
Posts: 8
Czech Republic

Thanks: 1 times
I'm trying to create a list of text that I can type quickly when I need it,but encountered a problem,

1、When there are quotation marks in the text,The text will be invalid, how to describe it correctly?
with quotation marks



2、How to describe correctly when there are multiple paragraphs in the text?
multiple paragraphs


Thanks my brothers and sisters 👍
Rob  
#2 Posted : Thursday, January 20, 2022 6:58:10 AM(UTC)
Rob

Rank: Administration

Reputation:

Groups: Translators, Members, Administrators
Joined: 1/11/2018(UTC)
Posts: 1,359
United States
Location: Tampa, FL

Thanks: 28 times
Was thanked: 419 time(s) in 356 post(s)
The scripting engine is JavaScript, so the same rules apply.

See here for some basic information:

https://www.w3schools.com/js/js_strings.asp

Code:
// Use double-quotes around the main text so single ticks can be used within
sp.SendUnicodeString("Whether it's a faster route to work");

// Escape the single tick
sp.SendUnicodeString('Whether it\'s a faster route to work');

// Use backticks instead of single or double-quotes
sp.SendUnicodeString(`Whether it's a faster route to work`);

// Add a new line escape (\n) at the end of each paragraph
sp.SendUnicodeString("first paragraph first paragraph first paragraph first paragraph\nsecond paragraph second paragraph second paragraph\nthird paragraph third paragraph third paragraph");

// Use backticks to create a literal string
sp.SendUnicodeString(`first paragraph first paragraph first paragraph first paragraph
second paragraph second paragraph second paragraph
third paragraph third paragraph third paragraph`);


Actually - since it looks like you're already using the menu script inside of backticks, it would be best to use one of the other methods above which aren't using backticks.

Things can get very complicated with nested strings!
thanks 1 user thanked Rob for this useful post.
randomConstant on 1/25/2022(UTC)
Users browsing this topic
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.