Author Topic: question about "strcat"  (Read 1417 times)

0 Members and 1 Guest are viewing this topic.

MeasureUp

  • Bull Frog
  • Posts: 462
question about "strcat"
« on: February 04, 2013, 01:01:46 AM »
From somewhere I get the following:
Code: [Select]
(strcat "\n123 \"" Part "\"\n")where "Part" is defined as
(setq Part "789")

I know what strcat does but the one about doesn't make sense to me.
Could you please explain it?

Thanks for your help.

irneb

  • Water Moccasin
  • Posts: 1794
  • ACad R9-2016, Revit Arch 6-2016
Re: question about "strcat"
« Reply #1 on: February 04, 2013, 01:42:59 AM »
That would simply result in a new string of the form:
Code - Auto/Visual Lisp: [Select]
  1. "\n123 \"789\"\n"
Basically if you princ that string it would result in something like this:
Code: [Select]

123 "789"␤
 
You might be getting confused due to the escaped " - they do make the appearance of the code a bit garbled. Remember that the \ character is used as an indication that the next character has special meaning. E.g. in your code the \ is used in 2 scenarios:
  • \" - means there's a double quote inside the sting. If it wasn't escaped with the back-slash, then there would be no way to add a " into a string.
  • \n - means add a new line (␤) character to the string.
Common sense - the curse in disguise. Because if you have it, you have to live with those that don't.

Lee Mac

  • Seagull
  • Posts: 12914
  • London, England
Re: question about "strcat"
« Reply #2 on: February 04, 2013, 07:39:07 AM »
...they do make the appearance of the code a bit garbled.

I've always loved the term 'Leaning Toothpick Syndrome (LTS):-D

MeasureUp

  • Bull Frog
  • Posts: 462
Re: question about "strcat"
« Reply #3 on: February 04, 2013, 05:24:45 PM »
Thanks to Lee and irneb.
Now I've learned the meaning of "\".