PDA

View Full Version : apostrophes and quotation marks



hcrisp
12-09-2009, 04:42 PM
I 'm having some trouble getting apostrophes and quotation marks to be assigned to a string variable. The Programmer's Guide says:


An apostrophe or quotation mark may be represented within a string that is
delimited by the same character, by two apostrophes, or quotation marks.

For example, 'Don''t' produces Don't; or you can write: "Don't" to
produce the same result.


This apparently works unless you want to start the string with an apostrophe, i.e.:



a = ''' This is a "comment" line'
; a = ''' This is a "comment" line'
; ^
;%%%Syntax error.


How to fix?

bads19
12-09-2009, 06:06 PM
This seem to work for what you need.


a = "This is a ""comment"" line"

I am not sure if there is a better fix.

hcrisp
12-10-2009, 07:05 AM
Almost, but not quite. You forgot the initial single quotation mark. Here it is complete:



a = "' This is a ""comment"" line"
print, a
;' This is a "comment" line
info, a
;A STRING = '' This is a "comment" line'


Thanks.