Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.

Due to spam on this forum, all posts now need moderator approval.

 Entire forum ➜ MUSHclient ➜ General ➜ How to put quotes within a quoted string?

How to put quotes within a quoted string?

It is now over 60 days since the last post. This thread is closed.     Refresh page


Posted by David Berthiaume   (202 posts)  Bio
Date Tue 07 Feb 2006 06:50 AM (UTC)
Message
How do I put "" into a Note?

Note "Bob said to sharon "You know, we should go see a movie tonight....""
Top

Posted by David Haley   USA  (3,881 posts)  Bio
Date Reply #1 on Tue 07 Feb 2006 08:18 AM (UTC)
Message
I think that VB script uses "" to mean ". So if you wanted to post the below, you'd have to write:

Note "Bob said to sharon "You know ... """. That way, of the three quotation marks, two will be interpreted to mean "insert a quotation mark into the string here".

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

http://david.the-haleys.org
Top

Posted by Nick Gammon   Australia  (23,165 posts)  Bio   Forum Administrator
Date Reply #2 on Tue 07 Feb 2006 09:25 PM (UTC)
Message
In some languages you can escape the quote with backslash. Lua and Jscript spring to mind.

eg.

Note "Bob said to sharon \"You know, we should go see a movie tonight....\""

This is really a language-specific issue. Read the documentation for the language you are using to see how to put quotes within quotes.

In Lua, you can use the other quote, like this:

Note 'Bob said to sharon "You know, we should go see a movie tonight...."'

This assumes, of course, you don't want single quotes inside the string too. If you did, you would then need to resort to the backslash trick.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by WillFa   USA  (525 posts)  Bio
Date Reply #3 on Wed 08 Feb 2006 05:26 AM (UTC)
Message
In any language you can also concatenate Chr(34) into the string:

VBScript: Note "WillFa thought " & chr(34) & "This is a tedious way to do it." & chr(34)

In Python you can use triple quotes to give formatted text:

world.Note("""WillFa thought "This way
I can even insert new lines without escaping them."""")
Top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


24,049 views.

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.