Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

String problem

12 REPLIES 12
Reply
Message 1 of 13
srestmeyer
586 Views, 12 Replies

String problem

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

 

12 REPLIES 12
Message 2 of 13
hmsilva
in reply to: srestmeyer

Scott,

try using the (strcat "(Tabloid (11x17\")"), inside a text command

i.e.
(setq str (strcat "(Tabloid (11x17\")"))
(Command "text" pause "" "" str "")

the text string will be (Tabloid (11x17")

Henrique

EESignature

Message 3 of 13
Lee_Mac
in reply to: srestmeyer

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.

 

Message 4 of 13
srestmeyer
in reply to: srestmeyer

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

Message 5 of 13
srestmeyer
in reply to: Lee_Mac

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

Message 6 of 13
Lee_Mac
in reply to: srestmeyer

What code are you using to output the string?

Message 7 of 13
srestmeyer
in reply to: Lee_Mac

I don't understand the question. Please elaborate.

Message 8 of 13
hmsilva
in reply to: srestmeyer

For testing, copy/paste at the command line

(alert "Tabloid (11x17\")")

Henrique

EESignature

Message 9 of 13
fred
in reply to: srestmeyer

It is working, its just displaying it as its coded...

Try this:

(setq paper_size "Tabloid (11x17\")")

(princ paper_size)(terpri)

 

 

Message 10 of 13
Kent1Cooper
in reply to: hmsilva


@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.

Kent Cooper, AIA
Message 11 of 13
Kent1Cooper
in reply to: srestmeyer


@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.

Kent Cooper, AIA
Message 12 of 13
srestmeyer
in reply to: srestmeyer

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.

 

 

Message 13 of 13


@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")"

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost