It's been a long time since I have done any LiSP programming but I can't seem to get a simple string command to work.
When I enter
(strcat "(Tabloid (11x17\")")
it returns
"(Tabloid (11x17\")"
How do it get it to return?
"(Tabloid (11x17")"
Any help would be appreciated.
Thanks
Scott
Scott,
In AutoLISP, the double-quote character is the string delimiter character, hence, to use this character within a string, it must be prefixed with an escape character in the form of a backslash in order to mark it as a literal double-quote.
Observe:
_$ (progn (princ "(Tabloid (11x17\")") (princ)) (Tabloid (11x17")
Note also that the strcat function is not required since you are not concatenating strings.
Thanks, but that doesn't work. I need it to return "Tabloid (11 x 17")".
I keep getting "Tabloid (11x17\")"
I don't know why the backslash keeps showing as text when I enter (setq paper_size "Tabloid (11x17\")")
Scott
Thanks, but that doesn't work. I need it to return "Tabloid (11 x 17")".
I keep getting "Tabloid (11x17\")"
I don't know why the backslash keeps showing as text when I enter (setq paper_size "Tabloid (11x17\")")
the only reason I put in the strcat was because I couldn't get the text to come out right.
Thanks
Scott
What code are you using to output the string?
It is working, its just displaying it as its coded...
Try this:
(setq paper_size "Tabloid (11x17\")")
(princ paper_size)(terpri)
@hmsilva wrote:
For testing, copy/paste at the command line
(alert "Tabloid (11x17\")")
And, to further illustrate the point, try that without the backslash:
(alert "Tabloid (11x17")")
The alert that comes up ends with the 7, because without the backslash to tell it to read the double-quote as a character in the string, it reads it as the marker for the end of the string.
@srestmeyer wrote:
.... I keep getting "Tabloid (11x17\")"
I don't know why the backslash keeps showing as text when I enter (setq paper_size "Tabloid (11x17\")")
....
Another way to think about it: the backslash isn't "showing" as a character, but rather, the backslash and the double-quote, combined, are one character in AutoLisp string-formatting terms. When you apply that string within something else [a Text or Mtext command as textual content, an (alert) or (prin...) or (prompt) function, etc.], the combination goes back to being just the double-quote character, because the "clue" that the backslash provides has done its job and is no longer part of the string in those applications.
Sorry for the false alrm guys. It turns out my troubleshooting skills were to blame. I was only looking at the string returned, not running that string thru the program. When I realized that I needed the backslash It all came back to me.
Thanks again for all the quick responses. As usual, this forum did not disappoint me.
@srestmeyer wrote:Thanks, but that doesn't work. I need it to return
I keep getting "Tabloid (11x17\")"
I don't know why the backslash keeps showing as text when I enter (setq paper_size "Tabloid (11x17\")")
the only reason I put in the strcat was because I couldn't get the text to come out right.
Thanks
Scott
If I'm following correctly try the following
(setq paper_size "\"Tabloid \(11 x 17\"\)\"")
that will return "Tabloid (11 x 17")"