« AutoCAD 2017 ObjectARX and Managed .NET Documentation | Main | Getting the Current Date/Time with AutoLISP - Part 1 »

Comments

José Luis García Galán

Only a small correction:
(Getenv "ACADPrefix") ";") is erroneous.

Use: (getvar "acadprefix") or (getenv "ACAD")

regards

Lee Ambrosius

Thanks for catching the issue, the sample has been fixed. The original content I had wrote used an environment variable.

BlackBox

I think you'll find this old 'parser' routine offers a substantial boost in efficiency:

https://www.theswamp.org/index.php?topic=42354.msg475130#msg475130

[code]
(defun _Parser (char string / i segments segment)
(while (setq i (vl-string-search char string))
(setq segments (cons (setq segment (substr string 1 i)) segments))
(setq string (substr string (+ 2 i)))
)
(reverse (cons string segments))
)
[/code]

Here's a quick speed test:

[code]
(setq s (getvar "acadprefix"))
(setq d ";")
(bench '(split) (list s d) 10000)
(bench '(_Parser) '(d s) 10000)
[/code]

... And the results from console:

[code]
_$

SPLIT
Elapsed: 2922
Average: 0.2922


_PARSER
Elapsed: 32
Average: 0.0032
[/code]

Now, how often will someone parse a string anywhere near this many times - admittedly seldom - just offering simplicity, and efficiency where I can, based on what I've learned.

Please do with this what you like.

Cheers

Lee Ambrosius

Thanks for sharing! There is always different ways to approach the same solution and performance is key when working with large data sets.

Verify your Comment

Previewing your Comment

This is only a preview. Your comment has not yet been posted.

Working...
Your comment could not be posted. Error type:
Your comment has been saved. Comments are moderated and will not appear until approved by the author. Post another comment

The letters and numbers you entered did not match the image. Please try again.

As a final step before posting your comment, enter the letters and numbers you see in the image below. This prevents automated programs from posting comments.

Having trouble reading this image? View an alternate.

Working...

Post a comment

Comments are moderated, and will not appear until the author has approved them.

Your Information

(Name and email address are required. Email address will not be displayed with the comment.)

My Photo

My Other Accounts

LinkedIn Twitter

Twitter Updates

    follow me on Twitter