0

The following question is about a 3rd party Arduino programming enviroment mBlock and creating extensions for it. I hope that there are some of you out there, who are fammiliar with it.

I was recently making an extensions for mBlock that can be used to write code for Arduino, when I came over this obstacle. I tried to write a function inside the "work":"" statement.

It looked like this:

"work":"Serial.print("Hello world");"

The extensions could not be imported, due to the quotation marks around the Hello world string. I tried removing the quotation marks, the extension was sucessfully added, but the program did not work, beacause quotation marks are needed inside C++ code to define a string.

Is there a way to add them in the extensions, without screwing up the code?

asked Jan 27, 2017 at 16:02

1 Answer 1

1

If that is a JSON format you could try using single quotes instead of double quotes:

"work":'Serial.print("Hello world");'

Alternatively you could escape the internal quotes:

"work":"Serial.print(\"Hello world\");"
answered Jan 27, 2017 at 16:07
3
  • None of the mentioned solutions seem to work. The extensions still do not get uploaded. The extension I am writing has a .s2e extension, if that helps (I am not really familliar with these kinds of files). Commented Jan 27, 2017 at 16:13
  • Looking at existing libraries the escaping should work. This is from serial.s2e: "work":"Serial.print({0});Serial.print(\"=\");Serial.println({1});\n" Commented Jan 27, 2017 at 16:19
  • For some reason it worked this time. I do not not why, but let's just go with it. Thanks. Commented Jan 27, 2017 at 16:24

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.