Aller au contenu

Photo

printing double-quotes ?


  • Veuillez vous connecter pour répondre
3 réponses à ce sujet

#1
MrZork

MrZork
  • Members
  • 942 messages
It's probably and old and stupid question and I've already worked around it anyway. But, for future reference...

How do I print a string with a double-quote in it? Assume I want to print to the client log using PrintString(), but I'm not sure how to do it in float text or message text, either.

In other words, I want the following string to appear, exactly, in the log
This character " is a double-quote.
What argument do I pass to PrintString()?

I am used to doing this in C-like languages using \\" or \\x22 or something similar. What's the easy way to do it in NWScript? Hopefully avoiding defining a string variable with a double-quote in it and having to concatenate that with another string...

Modifié par MrZork, 09 juin 2012 - 08:11 .


#2
Shadooow

Shadooow
  • Members
  • 4 472 messages
create an object with " in its name and use getname

#3
MrZork

MrZork
  • Members
  • 942 messages
Thanks, ShaDoOoW. I thought of that approach, and of setting a string variable on the module or on an object in it using the toolset, and of getting one from a string in the talk table, and so on. But, though that approach works, it's still a variation of defining a string variable with the double-quote in it that's gotten from outside the script. Is there no other way to do this, inside the script itself?

BTW, I am not against using the toolset to add an object with a string on it somewhere. It's a good workaround (the same sort of thing we use for colored text code characters, as I recall). I was just wondering if maybe I was missing something and using a workaround when one wasn't needed, since most languages have a way of getting a string literal with a quote.

#4
Failed.Bard

Failed.Bard
  • Members
  • 774 messages
You could use the apostrophe - ' - twice, to make your - '' -. It looks nearly identical in game both in an item name or "spoken" text.

Edit:  I'm assuming your PrintString line was just an example, and not the actual intended use for it.

Modifié par Failed.Bard, 09 juin 2012 - 01:00 .