Author Topic: Strings  (Read 3040 times)

0 Members and 1 Guest are viewing this topic.

ImaJayhawk

  • Guest
Strings
« on: September 23, 2004, 11:41:29 AM »
How can I delete all of the spaces out of this string?

Code: [Select]

"EF-1                "



Thanks.


--ImaJayhawk

SMadsen

  • Guest
Strings
« Reply #1 on: September 23, 2004, 11:52:28 AM »
Check out the VL-STRING-RIGHT-TRIM function in the online help.

M-dub

  • Guest
Strings
« Reply #2 on: September 23, 2004, 11:53:20 AM »
How many are there in your drawing?  Could you select each string you want to change?  If so, Edit -> Find...
Find " " (without quotation marks)
Replace with "" (nothing) and hit replace all.

The only thing is if you do this on the whole drawing, it will take every single space out of every string.  That's why you'd have to select each one.

I know what I'd have to do to code it, but I'm really new to VB and it would take me too long to get it figured out properly.  :oops:
HTH,
Mike

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
Strings
« Reply #3 on: September 23, 2004, 12:45:38 PM »
Try this ....
Code: [Select]

(while (=(substr STRVAR (strlen STRVAR) 1)" ")(setq STRVAR (substr STRVAR 1 (1-(strlen STRVAR)))))
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

ImaJayhawk

  • Guest
Strings
« Reply #4 on: September 23, 2004, 01:23:21 PM »
Both of the below seemed to work like I needed.

Code: [Select]

(while (=(substr STRVAR (strlen STRVAR) 1)" ")(setq STRVAR (substr STRVAR 1 (1-(strlen STRVAR)))))

(vl-string-right-trim " " STRVAR)


But I'm not sure why
Code: [Select]

(setq strvar "EF 1          ")
returns
"EF 1"


I would have thought if the "-" was left out it would return just "EF"

But "EF 1" is what I would want it to return.......

Thanks.


--ImaJayhawk :shock:

ImaJayhawk

  • Guest
Strings
« Reply #5 on: September 23, 2004, 01:46:34 PM »
M-dub I should have clarified these strings are being extracted from a text file generated by another program


--ImaJayhawk

daron

  • Guest
Strings
« Reply #6 on: September 24, 2004, 10:48:30 AM »
You get that from excel, I assume. When I bring anything in from excel, I create a new tab in excel, set each cell with =TRIM('tabname'!cellname(A1)), that way all extra stuff is not there when I copy it. Might or might not work, but that's what I do. Then I don't have to worry about it in autocad. Another thing that tends to happen is empty cells sometimes have spaces in them and they come up as ghosted images in autocad that you can't get rid of by selection. My solution takes care of that from happening.

M-dub

  • Guest
Strings
« Reply #7 on: September 24, 2004, 10:50:42 AM »
Good tip, Daron! :)