TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: Andrea on April 03, 2006, 03:43:52 PM

Title: list manipulation...
Post by: Andrea on April 03, 2006, 03:43:52 PM
Hi all..
I have this..

Code: [Select]
(setq lstttf (vl-registry-descendents "HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Windows NT\\CurrentVersion\\Fonts" ""))
result =
Code: [Select]
("AMGDT (TrueType)" "AmdtSymbols (TrueType)" "AIGDT (TrueType)"......)
after use this.
Code: [Select]
(foreach n lstttf
   (setq eet (vl-string-right-trim " \(TrueType)" n))
   (setq lstttf1 (append lstttf1 (list eet)))
)

result =
Code: [Select]
("AMGD" "AmdtSymbols" "AIGD" .......)
the question is...

AMGD ??
AIGD ??

the T is missing..
so how do i get the name of truetype without "(TrueType)" ??

 :|
Title: Re: list manipulation...
Post by: Jeff_M on April 03, 2006, 03:51:26 PM
Here's one way:
Code: [Select]
(setq lstttf (vl-registry-descendents "HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Windows NT\\CurrentVersion\\Fonts" ""))
(setq lstttf (mapcar '(lambda (x)
(vl-string-subst "" " (TrueType)" x)
)
     lstttf))
Title: Re: list manipulation...
Post by: zoltan on April 03, 2006, 04:36:48 PM
The VL-String-Right-Trim and VL-String-Left-Trim remove all charcaters that are included in the pattern string:

$ (vl-string-right-trim "bc" "abababcbcbcbcb")
"ababa"

Title: Re: list manipulation...
Post by: Andrea on April 03, 2006, 05:06:53 PM
vl-string-subst  !!!

OOOOUUUIIINNN !!!
why i didn't think more some time !! :ugly:

thanks.