Jump to content

insert " symbol in a string


HARRY-PLOTTER

Recommended Posts

How can i insert " symbol in a string? I need a string like 3/16"...and i want to do something like (strcat "3/16" """)- how to do this? Thanks!

Link to comment
Share on other sites

Like this?

(command "_.-scalelistedit" "[color=red]_[/color]D" "1/32[color=red]\[/color]" = 1'-0[color=red]\[/color]""[color=red] "_E"[/color])

A good programming practice is to use "_" in front of both commands and their options to ensure that your code works on localized AutoCAD; you need also to exit that command call.

 

By the way, please edit your previous post to add the required code tags.

Link to comment
Share on other sites

I didn't know about the backslash.

 

In VB/VBA I have used chr$(34) (or similar) and was about to ask if backslash works there before I realised I can check for myself - another day.

Link to comment
Share on other sites

If one want to go with the character approach:

(strcat "3/16" (chr 34))

 

 

Dbroada , regarding Visual Basic 6, the backslash solution will not work; use this instead:

"3/16"""

Link to comment
Share on other sites

Here is some information I have posted in the past about the backslash character:

 

Since the quotation mark (") is the delimiter in AutoLISP to denote a string literal, the backslash escape character must be used to mark quotation characters within the string as literal quotes, not to be interpreted as string delimiters.

 

Similarly, since the backslash is an escape character, backslash characters present in the string must be prefixed with a backslash to mark them as literal characters, not to be interpreted as escape characters.

 

Read the following articles to understand more:

 

String Literal

Escape Character

Delimiter Collision

Leaning Toothpick Syndrome

 

(I particularly like that last one!)

 

For an easy way to determine where the backslash character is required you can use the following simple program:

(defun c:literal ( ) (getstring t "\nEnter string: "))
 

Hence, for your example:

Command: literal

Enter string: 1/32" = 1'-0"
"1/32\" = 1'-0\""
 
Edited by Lee Mac
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...