TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: BazzaCAD on June 22, 2007, 07:43:35 PM

Title: How do you derturman what type to convert to?
Post by: BazzaCAD on June 22, 2007, 07:43:35 PM
OK, so I'm reading in a .txt file, and of course everything comes in as a string.
Let's say I have ("abc" "123" "1.5")...
How do I leave the "abc" as a string, convert the "123" to an Int, & convert the "1.5" to a Float?

thx,
Barry
Title: Re: How do you derturman what type to convert to?
Post by: Kerry on June 22, 2007, 07:58:16 PM
Hi Barry.
perhaps something like ..
Code: [Select]
(setq
    varlist (list "abc" "123" "1.5")
    newlist '()
    )
(FOREACH var varlist
    (SETQ newlist (CONS (IF (DISTOF var)
                            (READ var)
                            var
                        )
                        newlist
                  )
    )
)
(setq newlist (reverse newlist))
Title: Re: How do you derturman what type to convert to?
Post by: CAB on June 22, 2007, 08:00:04 PM
Looking for another thread but found this one.
http://www.theswamp.org/index.php?topic=9780.msg125334#msg125334
Title: Re: How do you derturman what type to convert to?
Post by: CAB on June 22, 2007, 08:04:54 PM
One more.
http://www.theswamp.org/index.php?topic=3710.0

Title: Re: How do you derturman what type to convert to?
Post by: BazzaCAD on June 22, 2007, 08:07:08 PM
thx guys, works great...