Author Topic: printing double-quotes ?  (Read 401 times)

Legacy_MrZork

  • Hero Member
  • *****
  • Posts: 1643
  • Karma: +0/-0
printing double-quotes ?
« on: June 09, 2012, 09:09:56 am »


               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 .
                     
                  


            

Legacy_Shadooow

  • Hero Member
  • *****
  • Posts: 7698
  • Karma: +0/-0
printing double-quotes ?
« Reply #1 on: June 09, 2012, 09:22:14 am »


               create an object with " in its name and use getname
               
               

               
            

Legacy_MrZork

  • Hero Member
  • *****
  • Posts: 1643
  • Karma: +0/-0
printing double-quotes ?
« Reply #2 on: June 09, 2012, 12:03:57 pm »


               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.
               
               

               
            

Legacy_Failed.Bard

  • Hero Member
  • *****
  • Posts: 1409
  • Karma: +0/-0
printing double-quotes ?
« Reply #3 on: June 09, 2012, 01:57:45 pm »


               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 .